2017-12-14 03:34:52 +00:00
---
title: About the aws_iam_role Resource
2018-02-14 01:42:39 +00:00
platform: aws
2017-12-14 03:34:52 +00:00
---
2018-02-15 02:23:29 +00:00
# aws\_iam\_role
2017-12-14 03:34:52 +00:00
2018-02-14 01:42:39 +00:00
Use the `aws_iam_role` InSpec audit resource to test properties of a single IAM Role. A Role is a collection of permissions that may be temporarily assumed by a user, EC2 Instance, Lambda Function, or certain other resources.
2017-12-14 03:34:52 +00:00
<br>
## Syntax
# Ensure that a certain role exists by name
describe aws_iam_role('my-role') do
it { should exist }
end
2018-02-14 01:42:39 +00:00
<br>
2017-12-14 03:34:52 +00:00
## Resource Parameters
2018-02-15 02:23:29 +00:00
### role\_name
2017-12-14 03:34:52 +00:00
2018-02-14 01:42:39 +00:00
This resource expects a single parameter that uniquely identifies the IAM Role, the Role Name. You may pass it as a string, or as the value in a hash:
2017-12-14 03:34:52 +00:00
describe aws_iam_role('my-role') do
it { should exist }
end
# Same
describe aws_iam_role(role_name: 'my-role') do
it { should exist }
end
2018-02-14 01:42:39 +00:00
<br>
## Properties
### description
A textual description of the IAM Role.
describe aws_iam_role('my-role') do
its('description') { should be('Our most important Role')}
end
<br>
2017-12-14 03:34:52 +00:00
## Matchers
2018-02-16 03:07:18 +00:00
This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
2018-02-15 04:31:56 +00:00
2017-12-14 03:34:52 +00:00
### exist
2018-02-14 01:42:39 +00:00
Indicates that the Role Name provided was found. Use should_not to test for IAM Roles that should not exist.
2017-12-14 03:34:52 +00:00
describe aws_iam_role('should-be-there') do
it { should exist }
end
describe aws_iam_role('should-not-be-there') do
it { should_not exist }
end