Class FunctionCode

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.cloudfront.FunctionCode
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:43.686Z") @Stability(Stable) public abstract class FunctionCode extends software.amazon.jsii.JsiiObject
Represents the function's source code.

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();
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
    FunctionCode(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    FunctionCode(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Code from external file for function.
    Inline code for function.
    abstract String
    renders the function code.

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • FunctionCode

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

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

      @Stability(Stable) protected FunctionCode()
  • Method Details

    • fromFile

      @Stability(Stable) @NotNull public static FunctionCode fromFile(@NotNull FileCodeOptions options)
      Code from external file for function.

      Parameters:
      options - the options for the external file. This parameter is required.
      Returns:
      code object with contents from file.
    • fromInline

      @Stability(Stable) @NotNull public static FunctionCode fromInline(@NotNull String code)
      Inline code for function.

      Parameters:
      code - The actual function code. This parameter is required.
      Returns:
      code object with inline code.
    • render

      @Stability(Stable) @NotNull public abstract String render()
      renders the function code.