Class CfnFunction

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-13T21:17:30.081Z") @Stability(Stable) public class CfnFunction extends CfnResource implements IInspectable
Creates a CloudFront function.

To create a function, you provide the function code and some configuration information about the function. The response contains an Amazon Resource Name (ARN) that uniquely identifies the function, and the function’s stage.

By default, when you create a function, it’s in the DEVELOPMENT stage. In this stage, you can test the function in the CloudFront console (or with TestFunction in the CloudFront API).

When you’re ready to use your function with a CloudFront distribution, publish the function to the LIVE stage. You can do this in the CloudFront console, with PublishFunction in the CloudFront API, or by updating the AWS::CloudFront::Function resource with the AutoPublish property set to true . When the function is published to the LIVE stage, you can attach it to a distribution’s cache behavior, using the function’s ARN.

To automatically publish the function to the LIVE stage when it’s created, set the AutoPublish property to true .

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.services.cloudfront.*;
 CfnFunction cfnFunction = CfnFunction.Builder.create(this, "MyCfnFunction")
         .functionCode("functionCode")
         .functionConfig(FunctionConfigProperty.builder()
                 .comment("comment")
                 .runtime("runtime")
                 // the properties below are optional
                 .keyValueStoreAssociations(List.of(KeyValueStoreAssociationProperty.builder()
                         .keyValueStoreArn("keyValueStoreArn")
                         .build()))
                 .build())
         .name("name")
         // the properties below are optional
         .autoPublish(false)
         .functionMetadata(FunctionMetadataProperty.builder()
                 .functionArn("functionArn")
                 .build())
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnFunction

      protected CfnFunction(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnFunction

      protected CfnFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnFunction

      @Stability(Stable) public CfnFunction(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnFunctionProps props)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties. This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrFunctionArn

      @Stability(Stable) @NotNull public String getAttrFunctionArn()
      The ARN of the function. For example:.

      arn:aws:cloudfront::123456789012:function/ExampleFunction .

      To get the function ARN, use the following syntax:

      !GetAtt *Function_Logical_ID* .FunctionMetadata.FunctionARN

    • getAttrFunctionMetadataFunctionArn

      @Stability(Stable) @NotNull public String getAttrFunctionMetadataFunctionArn()
      The Amazon Resource Name (ARN) of the function.

      The ARN uniquely identifies the function.

    • getAttrStage

      @Stability(Stable) @NotNull public String getAttrStage()
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getFunctionCode

      @Stability(Stable) @NotNull public String getFunctionCode()
      The function code.
    • setFunctionCode

      @Stability(Stable) public void setFunctionCode(@NotNull String value)
      The function code.
    • getFunctionConfig

      @Stability(Stable) @NotNull public Object getFunctionConfig()
      Contains configuration information about a CloudFront function.
    • setFunctionConfig

      @Stability(Stable) public void setFunctionConfig(@NotNull IResolvable value)
      Contains configuration information about a CloudFront function.
    • setFunctionConfig

      @Stability(Stable) public void setFunctionConfig(@NotNull CfnFunction.FunctionConfigProperty value)
      Contains configuration information about a CloudFront function.
    • getName

      @Stability(Stable) @NotNull public String getName()
      A name to identify the function.
    • setName

      @Stability(Stable) public void setName(@NotNull String value)
      A name to identify the function.
    • getAutoPublish

      @Stability(Stable) @Nullable public Object getAutoPublish()
      A flag that determines whether to automatically publish the function to the LIVE stage when it’s created.
    • setAutoPublish

      @Stability(Stable) public void setAutoPublish(@Nullable Boolean value)
      A flag that determines whether to automatically publish the function to the LIVE stage when it’s created.
    • setAutoPublish

      @Stability(Stable) public void setAutoPublish(@Nullable IResolvable value)
      A flag that determines whether to automatically publish the function to the LIVE stage when it’s created.
    • getFunctionMetadata

      @Stability(Stable) @Nullable public Object getFunctionMetadata()
      Contains metadata about a CloudFront function.
    • setFunctionMetadata

      @Stability(Stable) public void setFunctionMetadata(@Nullable IResolvable value)
      Contains metadata about a CloudFront function.
    • setFunctionMetadata

      @Stability(Stable) public void setFunctionMetadata(@Nullable CfnFunction.FunctionMetadataProperty value)
      Contains metadata about a CloudFront function.