Interface FunctionProps

All Superinterfaces:
software.amazon.jsii.JsiiSerializable
All Known Implementing Classes:
FunctionProps.Jsii$Proxy

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-08T21:35:03.869Z") @Stability(Stable) public interface FunctionProps extends software.amazon.jsii.JsiiSerializable
Properties for creating a CloudFront Function.

Example:

 Bucket s3Bucket;
 // Add a cloudfront Function to a Distribution
 Function cfFunction = Function.Builder.create(this, "Function")
         .code(FunctionCode.fromInline("function handler(event) { return event.request }"))
         .runtime(FunctionRuntime.JS_2_0)
         .build();
 Distribution.Builder.create(this, "distro")
         .defaultBehavior(BehaviorOptions.builder()
                 .origin(new S3Origin(s3Bucket))
                 .functionAssociations(List.of(FunctionAssociation.builder()
                         .function(cfFunction)
                         .eventType(FunctionEventType.VIEWER_REQUEST)
                         .build()))
                 .build())
         .build();
 
  • Method Details

    • getCode

      @Stability(Stable) @NotNull FunctionCode getCode()
      The source code of the function.
    • getAutoPublish

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

      Default: - true

    • getComment

      @Stability(Stable) @Nullable default String getComment()
      A comment to describe the function.

      Default: - same as `functionName`

    • getFunctionName

      @Stability(Stable) @Nullable default String getFunctionName()
      A name to identify the function.

      Default: - generated from the `id`

    • getKeyValueStore

      @Stability(Stable) @Nullable default IKeyValueStore getKeyValueStore()
      The Key Value Store to associate with this function.

      In order to associate a Key Value Store, the runtime must be cloudfront-js-2.0 or newer.

      Default: - no key value store is associated

    • getRuntime

      @Stability(Stable) @Nullable default FunctionRuntime getRuntime()
      The runtime environment for the function.

      Default: FunctionRuntime.JS_1_0 (unless `keyValueStore` is specified, then `FunctionRuntime.JS_2_0`)

    • builder

      @Stability(Stable) static FunctionProps.Builder builder()
      Returns:
      a FunctionProps.Builder of FunctionProps