aws_cloudfront_cache_policies resource
Use the aws_cloudfront_cache_policies InSpec audit resource to test properties of multiple AWS CloudFront cache policies.
The AWS::CloudFront::CachePolicy resource describes the CloudFront cache policy.
Syntax
Ensure that the custom resource exists.
describe aws_cloudfront_cache_policies do
it { should exist }
end
Parameters
This resource does not require any parameters.
Properties
types- The type for the cache policy.
Field:
typeids- The unique identifier for the cache policy.
Field:
idlast_modified_times- The date and time when the cache policy was last modified.
Field:
last_modified_timecomments- A comment to describe the cache policy.
Field:
commentnames- A unique name to identify the cache policy.
Field:
namedefault_ttls- The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
Field:
default_ttlmax_ttls- The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
Field:
max_ttlmin_ttls- The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
Field:
min_ttl
Examples
Test that an ID is available:
describe aws_cloudfront_cache_policies do
its('ids') { should include 'ID' }
end
Verify the maximum TTL of the policy:
describe aws_cloudfront_cache_policies do
its('max_ttls') { should include 1 }
end
Matchers
For a full list of available matchers, see our Universal Matchers page.The controls will pass if the list method returns at least one result.
exist
Use should to test that the entity exists.
describe aws_cloudfront_cache_policies do
it { should exist }
end
Use should_not to test the entity does not exist.
describe aws_cloudfront_cache_policies do
it { should_not exist }
end
AWS Permissions
Your AWS principal will need the CloudFront:Client:ListCachePoliciesResult action with Effect set to Allow.