Skip to main content

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.

Install

This resource is available in the Chef InSpec AWS resource pack.

For information on configuring your AWS environment for Chef InSpec and creating an InSpec profile that uses the InSpec AWS resource pack, see the Chef InSpec documentation on the AWS cloud platform.

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: type

ids
The unique identifier for the cache policy.

Field: id

last_modified_times
The date and time when the cache policy was last modified.

Field: last_modified_time

comments
A comment to describe the cache policy.

Field: comment

names
A unique name to identify the cache policy.

Field: name

default_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_ttl

max_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_ttl

min_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 Principal will need the CloudFront:Client:ListCachePoliciesResult action with Effect set to Allow.

Edit this page on GitHub

Thank you for your feedback!

×