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

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:43.683Z") @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 }"))
         .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
    • getFunctionStage

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