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

aws.cloudfront.Function

Explore with Pulumi AI

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

    Provides a CloudFront Function resource. With CloudFront Functions in Amazon CloudFront, you can write lightweight functions in JavaScript for high-scale, latency-sensitive CDN customizations.

    See CloudFront Functions

    NOTE: You cannot delete a function if it’s associated with a cache behavior. First, update your distributions to remove the function association from all cache behaviors, then delete the function.

    Example Usage

    Create Function Resource

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

    Constructor syntax

    new Function(name: string, args: FunctionArgs, opts?: CustomResourceOptions);
    @overload
    def Function(resource_name: str,
                 args: FunctionArgs,
                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def Function(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 code: Optional[str] = None,
                 runtime: Optional[str] = None,
                 comment: Optional[str] = None,
                 key_value_store_associations: Optional[Sequence[str]] = None,
                 name: Optional[str] = None,
                 publish: Optional[bool] = None)
    func NewFunction(ctx *Context, name string, args FunctionArgs, opts ...ResourceOption) (*Function, error)
    public Function(string name, FunctionArgs args, CustomResourceOptions? opts = null)
    public Function(String name, FunctionArgs args)
    public Function(String name, FunctionArgs args, CustomResourceOptions options)
    
    type: aws:cloudfront:Function
    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 FunctionArgs
    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 FunctionArgs
    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 FunctionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args FunctionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args FunctionArgs
    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 awsFunctionResource = new Aws.CloudFront.Function("awsFunctionResource", new()
    {
        Code = "string",
        Runtime = "string",
        Comment = "string",
        KeyValueStoreAssociations = new[]
        {
            "string",
        },
        Name = "string",
        Publish = false,
    });
    
    example, err := cloudfront.NewFunction(ctx, "awsFunctionResource", &cloudfront.FunctionArgs{
    	Code:    pulumi.String("string"),
    	Runtime: pulumi.String("string"),
    	Comment: pulumi.String("string"),
    	KeyValueStoreAssociations: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Name:    pulumi.String("string"),
    	Publish: pulumi.Bool(false),
    })
    
    var awsFunctionResource = new Function("awsFunctionResource", FunctionArgs.builder()
        .code("string")
        .runtime("string")
        .comment("string")
        .keyValueStoreAssociations("string")
        .name("string")
        .publish(false)
        .build());
    
    aws_function_resource = aws.cloudfront.Function("awsFunctionResource",
        code="string",
        runtime="string",
        comment="string",
        key_value_store_associations=["string"],
        name="string",
        publish=False)
    
    const awsFunctionResource = new aws.cloudfront.Function("awsFunctionResource", {
        code: "string",
        runtime: "string",
        comment: "string",
        keyValueStoreAssociations: ["string"],
        name: "string",
        publish: false,
    });
    
    type: aws:cloudfront:Function
    properties:
        code: string
        comment: string
        keyValueStoreAssociations:
            - string
        name: string
        publish: false
        runtime: string
    

    Function 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 Function resource accepts the following input properties:

    Code string
    Source code of the function
    Runtime string

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    Comment string
    Comment.
    KeyValueStoreAssociations List<string>
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    Name string
    Unique name for your CloudFront Function.
    Publish bool
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    Code string
    Source code of the function
    Runtime string

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    Comment string
    Comment.
    KeyValueStoreAssociations []string
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    Name string
    Unique name for your CloudFront Function.
    Publish bool
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    code String
    Source code of the function
    runtime String

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    comment String
    Comment.
    keyValueStoreAssociations List<String>
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    name String
    Unique name for your CloudFront Function.
    publish Boolean
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    code string
    Source code of the function
    runtime string

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    comment string
    Comment.
    keyValueStoreAssociations string[]
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    name string
    Unique name for your CloudFront Function.
    publish boolean
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    code str
    Source code of the function
    runtime str

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    comment str
    Comment.
    key_value_store_associations Sequence[str]
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    name str
    Unique name for your CloudFront Function.
    publish bool
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    code String
    Source code of the function
    runtime String

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    comment String
    Comment.
    keyValueStoreAssociations List<String>
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    name String
    Unique name for your CloudFront Function.
    publish Boolean
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.

    Outputs

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

    Arn string
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    Etag string
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    Id string
    The provider-assigned unique ID for this managed resource.
    LiveStageEtag string
    ETag hash of any LIVE stage of the function.
    Status string
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.
    Arn string
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    Etag string
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    Id string
    The provider-assigned unique ID for this managed resource.
    LiveStageEtag string
    ETag hash of any LIVE stage of the function.
    Status string
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.
    arn String
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    etag String
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    id String
    The provider-assigned unique ID for this managed resource.
    liveStageEtag String
    ETag hash of any LIVE stage of the function.
    status String
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.
    arn string
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    etag string
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    id string
    The provider-assigned unique ID for this managed resource.
    liveStageEtag string
    ETag hash of any LIVE stage of the function.
    status string
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.
    arn str
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    etag str
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    id str
    The provider-assigned unique ID for this managed resource.
    live_stage_etag str
    ETag hash of any LIVE stage of the function.
    status str
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.
    arn String
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    etag String
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    id String
    The provider-assigned unique ID for this managed resource.
    liveStageEtag String
    ETag hash of any LIVE stage of the function.
    status String
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.

    Look up Existing Function Resource

    Get an existing Function 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?: FunctionState, opts?: CustomResourceOptions): Function
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            arn: Optional[str] = None,
            code: Optional[str] = None,
            comment: Optional[str] = None,
            etag: Optional[str] = None,
            key_value_store_associations: Optional[Sequence[str]] = None,
            live_stage_etag: Optional[str] = None,
            name: Optional[str] = None,
            publish: Optional[bool] = None,
            runtime: Optional[str] = None,
            status: Optional[str] = None) -> Function
    func GetFunction(ctx *Context, name string, id IDInput, state *FunctionState, opts ...ResourceOption) (*Function, error)
    public static Function Get(string name, Input<string> id, FunctionState? state, CustomResourceOptions? opts = null)
    public static Function get(String name, Output<String> id, FunctionState 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:
    Arn string
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    Code string
    Source code of the function
    Comment string
    Comment.
    Etag string
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    KeyValueStoreAssociations List<string>
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    LiveStageEtag string
    ETag hash of any LIVE stage of the function.
    Name string
    Unique name for your CloudFront Function.
    Publish bool
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    Runtime string

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    Status string
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.
    Arn string
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    Code string
    Source code of the function
    Comment string
    Comment.
    Etag string
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    KeyValueStoreAssociations []string
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    LiveStageEtag string
    ETag hash of any LIVE stage of the function.
    Name string
    Unique name for your CloudFront Function.
    Publish bool
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    Runtime string

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    Status string
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.
    arn String
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    code String
    Source code of the function
    comment String
    Comment.
    etag String
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    keyValueStoreAssociations List<String>
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    liveStageEtag String
    ETag hash of any LIVE stage of the function.
    name String
    Unique name for your CloudFront Function.
    publish Boolean
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    runtime String

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    status String
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.
    arn string
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    code string
    Source code of the function
    comment string
    Comment.
    etag string
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    keyValueStoreAssociations string[]
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    liveStageEtag string
    ETag hash of any LIVE stage of the function.
    name string
    Unique name for your CloudFront Function.
    publish boolean
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    runtime string

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    status string
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.
    arn str
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    code str
    Source code of the function
    comment str
    Comment.
    etag str
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    key_value_store_associations Sequence[str]
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    live_stage_etag str
    ETag hash of any LIVE stage of the function.
    name str
    Unique name for your CloudFront Function.
    publish bool
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    runtime str

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    status str
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.
    arn String
    Amazon Resource Name (ARN) identifying your CloudFront Function.
    code String
    Source code of the function
    comment String
    Comment.
    etag String
    ETag hash of the function. This is the value for the DEVELOPMENT stage of the function.
    keyValueStoreAssociations List<String>
    List of aws.cloudfront.KeyValueStore ARNs to be associated to the function. AWS limits associations to on key value store per function.
    liveStageEtag String
    ETag hash of any LIVE stage of the function.
    name String
    Unique name for your CloudFront Function.
    publish Boolean
    Whether to publish creation/change as Live CloudFront Function Version. Defaults to true.
    runtime String

    Identifier of the function's runtime. Valid values are cloudfront-js-1.0 and cloudfront-js-2.0.

    The following arguments are optional:

    status String
    Status of the function. Can be UNPUBLISHED, UNASSOCIATED or ASSOCIATED.

    Import

    Using pulumi import, import CloudFront Functions using the name. For example:

    $ pulumi import aws:cloudfront/function:Function test my_test_function
    

    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