java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.cloudfront.Function
All Implemented Interfaces:
IResource, IFunction, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-08T21:35:03.866Z") @Stability(Stable) public class Function extends Resource implements IFunction
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();
 
  • Constructor Details

    • Function

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

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

      @Stability(Stable) public Function(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull FunctionProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromFunctionAttributes

      @Stability(Stable) @NotNull public static IFunction fromFunctionAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull FunctionAttributes attrs)
      Imports a function by its name and ARN.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      attrs - This parameter is required.
    • getFunctionArn

      @Stability(Stable) @NotNull public String getFunctionArn()
      the ARN of the CloudFront function.
      Specified by:
      getFunctionArn in interface IFunction
    • getFunctionName

      @Stability(Stable) @NotNull public String getFunctionName()
      the name of the CloudFront function.
      Specified by:
      getFunctionName in interface IFunction
    • getFunctionRuntime

      @Stability(Stable) @NotNull public String getFunctionRuntime()
      the runtime of the CloudFront function.
    • getFunctionStage

      @Stability(Stable) @NotNull public String getFunctionStage()
      the deployment stage of the CloudFront function.