Table: aws_cloudfront_cache_policy - Query AWS CloudFront Cache Policies using SQL
The AWS CloudFront Cache Policy is a feature of AWS CloudFront that allows you to specify detailed cache behaviors, including how, when, and where CloudFront caches and delivers content. It provides control over the data that CloudFront uses to serve requests, including headers, cookies, and query strings. This policy aids in optimizing the cache key and improving the cache hit ratio, thereby enhancing the performance of your application.
Table Usage Guide
The aws_cloudfront_cache_policy
table in Steampipe provides you with information about Cache Policies within AWS CloudFront. This table allows you, as a DevOps engineer, to query policy-specific details, including the configuration, status, and associated metadata. You can utilize this table to gather insights on cache policies, such as their identifiers, comment descriptions, the default time to live (TTL), maximum and minimum TTL, and more. The schema outlines the various attributes of the cache policy for you, including the policy ARN, creation time, last modified time, and associated tags.
Examples
Basic info
Explore which AWS CloudFront cache policies are in place to understand their impact on content delivery and caching strategies. This can be beneficial in optimizing resource usage and reducing costs.
select id, name, comment, min_ttl, etag, last_modified_timefrom aws_cloudfront_cache_policy;
select id, name, comment, min_ttl, etag, last_modified_timefrom aws_cloudfront_cache_policy;
List cache policies where Gzip compression format is not enabled
Identify instances where Gzip compression format is not enabled in AWS CloudFront cache policies. This can help to optimize content delivery and improve website loading speeds.
select id, name, parameters_in_cache_key_and_forwarded_to_origin ->> 'EnableAcceptEncodingGzip' as enable_gzipfrom aws_cloudfront_cache_policywhere parameters_in_cache_key_and_forwarded_to_origin ->> 'EnableAcceptEncodingGzip' <> 'true';
select id, name, json_extract( parameters_in_cache_key_and_forwarded_to_origin, '$.EnableAcceptEncodingGzip' ) as enable_gzipfrom aws_cloudfront_cache_policywhere json_extract( parameters_in_cache_key_and_forwarded_to_origin, '$.EnableAcceptEncodingGzip' ) <> 'true';
List cache policies where Brotli compression format is not enabled
Identify instances where Brotli compression format is not enabled in cache policies. This could help improve website performance by enabling more efficient data compression.
select id, name, parameters_in_cache_key_and_forwarded_to_origin ->> 'EnableAcceptEncodingBrotli' as enable_brotlifrom aws_cloudfront_cache_policywhere parameters_in_cache_key_and_forwarded_to_origin ->> 'EnableAcceptEncodingBrotli' <> 'true';
select id, name, json_extract( parameters_in_cache_key_and_forwarded_to_origin, '$.EnableAcceptEncodingBrotli' ) as enable_brotlifrom aws_cloudfront_cache_policywhere json_extract( parameters_in_cache_key_and_forwarded_to_origin, '$.EnableAcceptEncodingBrotli' ) <> 'true';
Schema for aws_cloudfront_cache_policy
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | =, !=, ~~, ~~*, !~~, !~~* | The AWS Account ID in which the resource is located. |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
comment | text | A comment to describe the cache policy. | |
default_ttl | bigint | 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. | |
etag | text | The current version of the cache policy. | |
id | text | = | The unique identifier for the cache policy. |
last_modified_time | timestamp with time zone | The date and time when the cache policy was last modified. | |
max_ttl | bigint | The maximum 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. | |
min_ttl | bigint | 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. | |
name | text | A unique name to identify the cache policy. | |
parameters_in_cache_key_and_forwarded_to_origin | jsonb | The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are automatically included in requests that CloudFront sends to the origin. | |
partition | text | The AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov). | |
region | text | The AWS Region in which the resource is located. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
title | text | Title of the resource. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- aws
You can pass the configuration to the command with the --config
argument:
steampipe_export_aws --config '<your_config>' aws_cloudfront_cache_policy