title |
---|
About the aws_rds_instance Resource |
Use the aws_rds_instance
InSpec audit resource to test detailed properties of an individual RDS instance.
RDS gives you access to the capabilities of a MySQL, MariaDB, PostgreSQL, Microsoft SQL Server, Oracle, or Amazon Aurora database server.
An aws_rds_instance
resource block uses resource parameters to search for an RDS instance, and then tests that RDS instance. If no RDS instances match, no error is raised, but the exists
matcher will return false
and all properties will be nil
. If more than one RDS instance matches (due to vague search parameters), an error is raised.
describe aws_rds_instance('test-instance-id') do
it { should exist }
end
# Can also use hash syntax
describe aws_rds_instance(db_instance_identifier: 'test-instance-id') do
it { should exist }
end
This resource accepts a single parameter, the user-supplied instance identifier. This parameter isn't case-sensitive.
This can be passed either as a string or as a db_instance_identifier: 'value'
key-value entry in a hash.
See also the AWS documentation on RDS.
For a comprehensive list of properties available to test on an RDS Instance see the AWS Response Object
describe aws_rds_instance(db_instance_identifier: 'awsrds123') do
its ('engine') { should eq 'mysql' }
its ('engine_version') { should eq '5.6.37' }
end
describe aws_rds_instance(db_instance_identifier: 'awsrds123') do
its ('storage_type') { should eq 'gp2' }
its ('allocated_storage') { should eq 10 }
end
describe aws_rds_instance(db_instance_identifier: 'awsrds123') do
its ('master_username') { should eq 'db-maintain' }
its ('db_instance_class') { should eq 'db.t3.micro' }
end
This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our matchers page.
The control will pass if the describe returns at least one result.
Use should_not
to test the entity should not exist.
describe aws_rds_instance(db_instance_identifier: 'AnExistingRDS') do
it { should exist }
end
describe aws_rds_instance(db_instance_identifier: 'ANonExistentRDS') do
it { should_not exist }
end
Your Principal will need the rds:DescribeDBInstances
action with Effect set to Allow.
You can find detailed documentation at Actions, Resources, and Condition Keys for Amazon RDS.