1. Packages
  2. AWS
  3. API Docs
  4. cloudfront
  5. CachePolicy
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

aws.cloudfront.CachePolicy

Explore with Pulumi AI

aws logo
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Example Usage

    Use the aws.cloudfront.CachePolicy resource to create a cache policy for CloudFront.

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = new aws.cloudfront.CachePolicy("example", {
        name: "example-policy",
        comment: "test comment",
        defaultTtl: 50,
        maxTtl: 100,
        minTtl: 1,
        parametersInCacheKeyAndForwardedToOrigin: {
            cookiesConfig: {
                cookieBehavior: "whitelist",
                cookies: {
                    items: ["example"],
                },
            },
            headersConfig: {
                headerBehavior: "whitelist",
                headers: {
                    items: ["example"],
                },
            },
            queryStringsConfig: {
                queryStringBehavior: "whitelist",
                queryStrings: {
                    items: ["example"],
                },
            },
        },
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.cloudfront.CachePolicy("example",
        name="example-policy",
        comment="test comment",
        default_ttl=50,
        max_ttl=100,
        min_ttl=1,
        parameters_in_cache_key_and_forwarded_to_origin={
            "cookies_config": {
                "cookie_behavior": "whitelist",
                "cookies": {
                    "items": ["example"],
                },
            },
            "headers_config": {
                "header_behavior": "whitelist",
                "headers": {
                    "items": ["example"],
                },
            },
            "query_strings_config": {
                "query_string_behavior": "whitelist",
                "query_strings": {
                    "items": ["example"],
                },
            },
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudfront"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := cloudfront.NewCachePolicy(ctx, "example", &cloudfront.CachePolicyArgs{
    			Name:       pulumi.String("example-policy"),
    			Comment:    pulumi.String("test comment"),
    			DefaultTtl: pulumi.Int(50),
    			MaxTtl:     pulumi.Int(100),
    			MinTtl:     pulumi.Int(1),
    			ParametersInCacheKeyAndForwardedToOrigin: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginArgs{
    				CookiesConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigArgs{
    					CookieBehavior: pulumi.String("whitelist"),
    					Cookies: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookiesArgs{
    						Items: pulumi.StringArray{
    							pulumi.String("example"),
    						},
    					},
    				},
    				HeadersConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigArgs{
    					HeaderBehavior: pulumi.String("whitelist"),
    					Headers: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeadersArgs{
    						Items: pulumi.StringArray{
    							pulumi.String("example"),
    						},
    					},
    				},
    				QueryStringsConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigArgs{
    					QueryStringBehavior: pulumi.String("whitelist"),
    					QueryStrings: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStringsArgs{
    						Items: pulumi.StringArray{
    							pulumi.String("example"),
    						},
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Aws.CloudFront.CachePolicy("example", new()
        {
            Name = "example-policy",
            Comment = "test comment",
            DefaultTtl = 50,
            MaxTtl = 100,
            MinTtl = 1,
            ParametersInCacheKeyAndForwardedToOrigin = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginArgs
            {
                CookiesConfig = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigArgs
                {
                    CookieBehavior = "whitelist",
                    Cookies = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookiesArgs
                    {
                        Items = new[]
                        {
                            "example",
                        },
                    },
                },
                HeadersConfig = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigArgs
                {
                    HeaderBehavior = "whitelist",
                    Headers = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeadersArgs
                    {
                        Items = new[]
                        {
                            "example",
                        },
                    },
                },
                QueryStringsConfig = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigArgs
                {
                    QueryStringBehavior = "whitelist",
                    QueryStrings = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStringsArgs
                    {
                        Items = new[]
                        {
                            "example",
                        },
                    },
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.cloudfront.CachePolicy;
    import com.pulumi.aws.cloudfront.CachePolicyArgs;
    import com.pulumi.aws.cloudfront.inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginArgs;
    import com.pulumi.aws.cloudfront.inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigArgs;
    import com.pulumi.aws.cloudfront.inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookiesArgs;
    import com.pulumi.aws.cloudfront.inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigArgs;
    import com.pulumi.aws.cloudfront.inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeadersArgs;
    import com.pulumi.aws.cloudfront.inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigArgs;
    import com.pulumi.aws.cloudfront.inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStringsArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var example = new CachePolicy("example", CachePolicyArgs.builder()
                .name("example-policy")
                .comment("test comment")
                .defaultTtl(50)
                .maxTtl(100)
                .minTtl(1)
                .parametersInCacheKeyAndForwardedToOrigin(CachePolicyParametersInCacheKeyAndForwardedToOriginArgs.builder()
                    .cookiesConfig(CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigArgs.builder()
                        .cookieBehavior("whitelist")
                        .cookies(CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookiesArgs.builder()
                            .items("example")
                            .build())
                        .build())
                    .headersConfig(CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigArgs.builder()
                        .headerBehavior("whitelist")
                        .headers(CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeadersArgs.builder()
                            .items("example")
                            .build())
                        .build())
                    .queryStringsConfig(CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigArgs.builder()
                        .queryStringBehavior("whitelist")
                        .queryStrings(CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStringsArgs.builder()
                            .items("example")
                            .build())
                        .build())
                    .build())
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:cloudfront:CachePolicy
        properties:
          name: example-policy
          comment: test comment
          defaultTtl: 50
          maxTtl: 100
          minTtl: 1
          parametersInCacheKeyAndForwardedToOrigin:
            cookiesConfig:
              cookieBehavior: whitelist
              cookies:
                items:
                  - example
            headersConfig:
              headerBehavior: whitelist
              headers:
                items:
                  - example
            queryStringsConfig:
              queryStringBehavior: whitelist
              queryStrings:
                items:
                  - example
    

    Create CachePolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new CachePolicy(name: string, args: CachePolicyArgs, opts?: CustomResourceOptions);
    @overload
    def CachePolicy(resource_name: str,
                    args: CachePolicyArgs,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def CachePolicy(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    parameters_in_cache_key_and_forwarded_to_origin: Optional[CachePolicyParametersInCacheKeyAndForwardedToOriginArgs] = None,
                    comment: Optional[str] = None,
                    default_ttl: Optional[int] = None,
                    max_ttl: Optional[int] = None,
                    min_ttl: Optional[int] = None,
                    name: Optional[str] = None)
    func NewCachePolicy(ctx *Context, name string, args CachePolicyArgs, opts ...ResourceOption) (*CachePolicy, error)
    public CachePolicy(string name, CachePolicyArgs args, CustomResourceOptions? opts = null)
    public CachePolicy(String name, CachePolicyArgs args)
    public CachePolicy(String name, CachePolicyArgs args, CustomResourceOptions options)
    
    type: aws:cloudfront:CachePolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args CachePolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args CachePolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args CachePolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args CachePolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args CachePolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var cachePolicyResource = new Aws.CloudFront.CachePolicy("cachePolicyResource", new()
    {
        ParametersInCacheKeyAndForwardedToOrigin = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginArgs
        {
            CookiesConfig = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigArgs
            {
                CookieBehavior = "string",
                Cookies = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookiesArgs
                {
                    Items = new[]
                    {
                        "string",
                    },
                },
            },
            HeadersConfig = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigArgs
            {
                HeaderBehavior = "string",
                Headers = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeadersArgs
                {
                    Items = new[]
                    {
                        "string",
                    },
                },
            },
            QueryStringsConfig = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigArgs
            {
                QueryStringBehavior = "string",
                QueryStrings = new Aws.CloudFront.Inputs.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStringsArgs
                {
                    Items = new[]
                    {
                        "string",
                    },
                },
            },
            EnableAcceptEncodingBrotli = false,
            EnableAcceptEncodingGzip = false,
        },
        Comment = "string",
        DefaultTtl = 0,
        MaxTtl = 0,
        MinTtl = 0,
        Name = "string",
    });
    
    example, err := cloudfront.NewCachePolicy(ctx, "cachePolicyResource", &cloudfront.CachePolicyArgs{
    	ParametersInCacheKeyAndForwardedToOrigin: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginArgs{
    		CookiesConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigArgs{
    			CookieBehavior: pulumi.String("string"),
    			Cookies: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookiesArgs{
    				Items: pulumi.StringArray{
    					pulumi.String("string"),
    				},
    			},
    		},
    		HeadersConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigArgs{
    			HeaderBehavior: pulumi.String("string"),
    			Headers: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeadersArgs{
    				Items: pulumi.StringArray{
    					pulumi.String("string"),
    				},
    			},
    		},
    		QueryStringsConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigArgs{
    			QueryStringBehavior: pulumi.String("string"),
    			QueryStrings: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStringsArgs{
    				Items: pulumi.StringArray{
    					pulumi.String("string"),
    				},
    			},
    		},
    		EnableAcceptEncodingBrotli: pulumi.Bool(false),
    		EnableAcceptEncodingGzip:   pulumi.Bool(false),
    	},
    	Comment:    pulumi.String("string"),
    	DefaultTtl: pulumi.Int(0),
    	MaxTtl:     pulumi.Int(0),
    	MinTtl:     pulumi.Int(0),
    	Name:       pulumi.String("string"),
    })
    
    var cachePolicyResource = new CachePolicy("cachePolicyResource", CachePolicyArgs.builder()
        .parametersInCacheKeyAndForwardedToOrigin(CachePolicyParametersInCacheKeyAndForwardedToOriginArgs.builder()
            .cookiesConfig(CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigArgs.builder()
                .cookieBehavior("string")
                .cookies(CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookiesArgs.builder()
                    .items("string")
                    .build())
                .build())
            .headersConfig(CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigArgs.builder()
                .headerBehavior("string")
                .headers(CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeadersArgs.builder()
                    .items("string")
                    .build())
                .build())
            .queryStringsConfig(CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigArgs.builder()
                .queryStringBehavior("string")
                .queryStrings(CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStringsArgs.builder()
                    .items("string")
                    .build())
                .build())
            .enableAcceptEncodingBrotli(false)
            .enableAcceptEncodingGzip(false)
            .build())
        .comment("string")
        .defaultTtl(0)
        .maxTtl(0)
        .minTtl(0)
        .name("string")
        .build());
    
    cache_policy_resource = aws.cloudfront.CachePolicy("cachePolicyResource",
        parameters_in_cache_key_and_forwarded_to_origin={
            "cookies_config": {
                "cookie_behavior": "string",
                "cookies": {
                    "items": ["string"],
                },
            },
            "headers_config": {
                "header_behavior": "string",
                "headers": {
                    "items": ["string"],
                },
            },
            "query_strings_config": {
                "query_string_behavior": "string",
                "query_strings": {
                    "items": ["string"],
                },
            },
            "enable_accept_encoding_brotli": False,
            "enable_accept_encoding_gzip": False,
        },
        comment="string",
        default_ttl=0,
        max_ttl=0,
        min_ttl=0,
        name="string")
    
    const cachePolicyResource = new aws.cloudfront.CachePolicy("cachePolicyResource", {
        parametersInCacheKeyAndForwardedToOrigin: {
            cookiesConfig: {
                cookieBehavior: "string",
                cookies: {
                    items: ["string"],
                },
            },
            headersConfig: {
                headerBehavior: "string",
                headers: {
                    items: ["string"],
                },
            },
            queryStringsConfig: {
                queryStringBehavior: "string",
                queryStrings: {
                    items: ["string"],
                },
            },
            enableAcceptEncodingBrotli: false,
            enableAcceptEncodingGzip: false,
        },
        comment: "string",
        defaultTtl: 0,
        maxTtl: 0,
        minTtl: 0,
        name: "string",
    });
    
    type: aws:cloudfront:CachePolicy
    properties:
        comment: string
        defaultTtl: 0
        maxTtl: 0
        minTtl: 0
        name: string
        parametersInCacheKeyAndForwardedToOrigin:
            cookiesConfig:
                cookieBehavior: string
                cookies:
                    items:
                        - string
            enableAcceptEncodingBrotli: false
            enableAcceptEncodingGzip: false
            headersConfig:
                headerBehavior: string
                headers:
                    items:
                        - string
            queryStringsConfig:
                queryStringBehavior: string
                queryStrings:
                    items:
                        - string
    

    CachePolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The CachePolicy resource accepts the following input properties:

    ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOrigin
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    Comment string
    Description for the cache policy.
    DefaultTtl int
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    MaxTtl int
    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.
    MinTtl int
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    Name string
    Unique name used to identify the cache policy.
    ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginArgs
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    Comment string
    Description for the cache policy.
    DefaultTtl int
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    MaxTtl int
    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.
    MinTtl int
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    Name string
    Unique name used to identify the cache policy.
    parametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOrigin
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    comment String
    Description for the cache policy.
    defaultTtl Integer
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    maxTtl Integer
    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.
    minTtl Integer
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    name String
    Unique name used to identify the cache policy.
    parametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOrigin
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    comment string
    Description for the cache policy.
    defaultTtl number
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    maxTtl number
    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.
    minTtl number
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    name string
    Unique name used to identify the cache policy.
    parameters_in_cache_key_and_forwarded_to_origin CachePolicyParametersInCacheKeyAndForwardedToOriginArgs
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    comment str
    Description for the cache policy.
    default_ttl int
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    max_ttl int
    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.
    min_ttl int
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    name str
    Unique name used to identify the cache policy.
    parametersInCacheKeyAndForwardedToOrigin Property Map
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    comment String
    Description for the cache policy.
    defaultTtl Number
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    maxTtl Number
    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.
    minTtl Number
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    name String
    Unique name used to identify the cache policy.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the CachePolicy resource produces the following output properties:

    Etag string
    Current version of the cache policy.
    Id string
    The provider-assigned unique ID for this managed resource.
    Etag string
    Current version of the cache policy.
    Id string
    The provider-assigned unique ID for this managed resource.
    etag String
    Current version of the cache policy.
    id String
    The provider-assigned unique ID for this managed resource.
    etag string
    Current version of the cache policy.
    id string
    The provider-assigned unique ID for this managed resource.
    etag str
    Current version of the cache policy.
    id str
    The provider-assigned unique ID for this managed resource.
    etag String
    Current version of the cache policy.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing CachePolicy Resource

    Get an existing CachePolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: CachePolicyState, opts?: CustomResourceOptions): CachePolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            comment: Optional[str] = None,
            default_ttl: Optional[int] = None,
            etag: Optional[str] = None,
            max_ttl: Optional[int] = None,
            min_ttl: Optional[int] = None,
            name: Optional[str] = None,
            parameters_in_cache_key_and_forwarded_to_origin: Optional[CachePolicyParametersInCacheKeyAndForwardedToOriginArgs] = None) -> CachePolicy
    func GetCachePolicy(ctx *Context, name string, id IDInput, state *CachePolicyState, opts ...ResourceOption) (*CachePolicy, error)
    public static CachePolicy Get(string name, Input<string> id, CachePolicyState? state, CustomResourceOptions? opts = null)
    public static CachePolicy get(String name, Output<String> id, CachePolicyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Comment string
    Description for the cache policy.
    DefaultTtl int
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    Etag string
    Current version of the cache policy.
    MaxTtl int
    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.
    MinTtl int
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    Name string
    Unique name used to identify the cache policy.
    ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOrigin
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    Comment string
    Description for the cache policy.
    DefaultTtl int
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    Etag string
    Current version of the cache policy.
    MaxTtl int
    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.
    MinTtl int
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    Name string
    Unique name used to identify the cache policy.
    ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginArgs
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    comment String
    Description for the cache policy.
    defaultTtl Integer
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    etag String
    Current version of the cache policy.
    maxTtl Integer
    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.
    minTtl Integer
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    name String
    Unique name used to identify the cache policy.
    parametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOrigin
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    comment string
    Description for the cache policy.
    defaultTtl number
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    etag string
    Current version of the cache policy.
    maxTtl number
    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.
    minTtl number
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    name string
    Unique name used to identify the cache policy.
    parametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOrigin
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    comment str
    Description for the cache policy.
    default_ttl int
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    etag str
    Current version of the cache policy.
    max_ttl int
    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.
    min_ttl int
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    name str
    Unique name used to identify the cache policy.
    parameters_in_cache_key_and_forwarded_to_origin CachePolicyParametersInCacheKeyAndForwardedToOriginArgs
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
    comment String
    Description for the cache policy.
    defaultTtl Number
    Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
    etag String
    Current version of the cache policy.
    maxTtl Number
    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.
    minTtl Number
    Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
    name String
    Unique name used to identify the cache policy.
    parametersInCacheKeyAndForwardedToOrigin Property Map
    Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.

    Supporting Types

    CachePolicyParametersInCacheKeyAndForwardedToOrigin, CachePolicyParametersInCacheKeyAndForwardedToOriginArgs

    CookiesConfig CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfig
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Cookies Config for more information.
    HeadersConfig CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfig
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Headers Config for more information.
    QueryStringsConfig CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfig
    Whether any URL query strings in viewer requests are included in the cache key. It also automatically includes these query strings in requests that CloudFront sends to the origin. Please refer to the Query String Config for more information.
    EnableAcceptEncodingBrotli bool
    Flag determines whether the Accept-Encoding HTTP header is included in the cache key and in requests that CloudFront sends to the origin.
    EnableAcceptEncodingGzip bool
    Whether the Accept-Encoding HTTP header is included in the cache key and in requests sent to the origin by CloudFront.
    CookiesConfig CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfig
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Cookies Config for more information.
    HeadersConfig CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfig
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Headers Config for more information.
    QueryStringsConfig CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfig
    Whether any URL query strings in viewer requests are included in the cache key. It also automatically includes these query strings in requests that CloudFront sends to the origin. Please refer to the Query String Config for more information.
    EnableAcceptEncodingBrotli bool
    Flag determines whether the Accept-Encoding HTTP header is included in the cache key and in requests that CloudFront sends to the origin.
    EnableAcceptEncodingGzip bool
    Whether the Accept-Encoding HTTP header is included in the cache key and in requests sent to the origin by CloudFront.
    cookiesConfig CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfig
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Cookies Config for more information.
    headersConfig CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfig
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Headers Config for more information.
    queryStringsConfig CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfig
    Whether any URL query strings in viewer requests are included in the cache key. It also automatically includes these query strings in requests that CloudFront sends to the origin. Please refer to the Query String Config for more information.
    enableAcceptEncodingBrotli Boolean
    Flag determines whether the Accept-Encoding HTTP header is included in the cache key and in requests that CloudFront sends to the origin.
    enableAcceptEncodingGzip Boolean
    Whether the Accept-Encoding HTTP header is included in the cache key and in requests sent to the origin by CloudFront.
    cookiesConfig CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfig
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Cookies Config for more information.
    headersConfig CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfig
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Headers Config for more information.
    queryStringsConfig CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfig
    Whether any URL query strings in viewer requests are included in the cache key. It also automatically includes these query strings in requests that CloudFront sends to the origin. Please refer to the Query String Config for more information.
    enableAcceptEncodingBrotli boolean
    Flag determines whether the Accept-Encoding HTTP header is included in the cache key and in requests that CloudFront sends to the origin.
    enableAcceptEncodingGzip boolean
    Whether the Accept-Encoding HTTP header is included in the cache key and in requests sent to the origin by CloudFront.
    cookies_config CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfig
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Cookies Config for more information.
    headers_config CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfig
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Headers Config for more information.
    query_strings_config CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfig
    Whether any URL query strings in viewer requests are included in the cache key. It also automatically includes these query strings in requests that CloudFront sends to the origin. Please refer to the Query String Config for more information.
    enable_accept_encoding_brotli bool
    Flag determines whether the Accept-Encoding HTTP header is included in the cache key and in requests that CloudFront sends to the origin.
    enable_accept_encoding_gzip bool
    Whether the Accept-Encoding HTTP header is included in the cache key and in requests sent to the origin by CloudFront.
    cookiesConfig Property Map
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Cookies Config for more information.
    headersConfig Property Map
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Headers Config for more information.
    queryStringsConfig Property Map
    Whether any URL query strings in viewer requests are included in the cache key. It also automatically includes these query strings in requests that CloudFront sends to the origin. Please refer to the Query String Config for more information.
    enableAcceptEncodingBrotli Boolean
    Flag determines whether the Accept-Encoding HTTP header is included in the cache key and in requests that CloudFront sends to the origin.
    enableAcceptEncodingGzip Boolean
    Whether the Accept-Encoding HTTP header is included in the cache key and in requests sent to the origin by CloudFront.

    CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfig, CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigArgs

    CookieBehavior string
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for cookie_behavior are none, whitelist, allExcept, and all.
    Cookies CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookies
    Object that contains a list of cookie names. See Items for more information.
    CookieBehavior string
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for cookie_behavior are none, whitelist, allExcept, and all.
    Cookies CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookies
    Object that contains a list of cookie names. See Items for more information.
    cookieBehavior String
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for cookie_behavior are none, whitelist, allExcept, and all.
    cookies CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookies
    Object that contains a list of cookie names. See Items for more information.
    cookieBehavior string
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for cookie_behavior are none, whitelist, allExcept, and all.
    cookies CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookies
    Object that contains a list of cookie names. See Items for more information.
    cookie_behavior str
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for cookie_behavior are none, whitelist, allExcept, and all.
    cookies CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookies
    Object that contains a list of cookie names. See Items for more information.
    cookieBehavior String
    Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for cookie_behavior are none, whitelist, allExcept, and all.
    cookies Property Map
    Object that contains a list of cookie names. See Items for more information.

    CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookies, CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookiesArgs

    Items List<string>
    List of item names, such as cookies, headers, or query strings.
    Items []string
    List of item names, such as cookies, headers, or query strings.
    items List<String>
    List of item names, such as cookies, headers, or query strings.
    items string[]
    List of item names, such as cookies, headers, or query strings.
    items Sequence[str]
    List of item names, such as cookies, headers, or query strings.
    items List<String>
    List of item names, such as cookies, headers, or query strings.

    CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfig, CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigArgs

    HeaderBehavior string
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for header_behavior are none and whitelist.
    Headers CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeaders
    Object contains a list of header names. See Items for more information.
    HeaderBehavior string
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for header_behavior are none and whitelist.
    Headers CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeaders
    Object contains a list of header names. See Items for more information.
    headerBehavior String
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for header_behavior are none and whitelist.
    headers CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeaders
    Object contains a list of header names. See Items for more information.
    headerBehavior string
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for header_behavior are none and whitelist.
    headers CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeaders
    Object contains a list of header names. See Items for more information.
    header_behavior str
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for header_behavior are none and whitelist.
    headers CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeaders
    Object contains a list of header names. See Items for more information.
    headerBehavior String
    Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for header_behavior are none and whitelist.
    headers Property Map
    Object contains a list of header names. See Items for more information.

    CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeaders, CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeadersArgs

    Items List<string>
    List of item names, such as cookies, headers, or query strings.
    Items []string
    List of item names, such as cookies, headers, or query strings.
    items List<String>
    List of item names, such as cookies, headers, or query strings.
    items string[]
    List of item names, such as cookies, headers, or query strings.
    items Sequence[str]
    List of item names, such as cookies, headers, or query strings.
    items List<String>
    List of item names, such as cookies, headers, or query strings.

    CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfig, CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigArgs

    QueryStringBehavior string
    Whether URL query strings in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for query_string_behavior are none, whitelist, allExcept, and all.
    QueryStrings CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStrings
    Configuration parameter that contains a list of query string names. See Items for more information.
    QueryStringBehavior string
    Whether URL query strings in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for query_string_behavior are none, whitelist, allExcept, and all.
    QueryStrings CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStrings
    Configuration parameter that contains a list of query string names. See Items for more information.
    queryStringBehavior String
    Whether URL query strings in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for query_string_behavior are none, whitelist, allExcept, and all.
    queryStrings CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStrings
    Configuration parameter that contains a list of query string names. See Items for more information.
    queryStringBehavior string
    Whether URL query strings in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for query_string_behavior are none, whitelist, allExcept, and all.
    queryStrings CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStrings
    Configuration parameter that contains a list of query string names. See Items for more information.
    query_string_behavior str
    Whether URL query strings in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for query_string_behavior are none, whitelist, allExcept, and all.
    query_strings CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStrings
    Configuration parameter that contains a list of query string names. See Items for more information.
    queryStringBehavior String
    Whether URL query strings in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values for query_string_behavior are none, whitelist, allExcept, and all.
    queryStrings Property Map
    Configuration parameter that contains a list of query string names. See Items for more information.

    CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStrings, CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStringsArgs

    Items List<string>
    List of item names, such as cookies, headers, or query strings.
    Items []string
    List of item names, such as cookies, headers, or query strings.
    items List<String>
    List of item names, such as cookies, headers, or query strings.
    items string[]
    List of item names, such as cookies, headers, or query strings.
    items Sequence[str]
    List of item names, such as cookies, headers, or query strings.
    items List<String>
    List of item names, such as cookies, headers, or query strings.

    Import

    Using pulumi import, import CloudFront cache policies using the id of the cache policy. For example:

    $ pulumi import aws:cloudfront/cachePolicy:CachePolicy policy 658327ea-f89d-4fab-a63d-7e88639e58f6
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi