Class Function


  • public class Function
    extends com.pulumi.resources.CustomResource
    Provides a CloudFront Function resource. With CloudFront Functions in Amazon CloudFront, you can write lightweight functions in JavaScript for high-scale, latency-sensitive CDN customizations. See [CloudFront Functions](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-functions.html) > **NOTE:** You cannot delete a function if it’s associated with a cache behavior. First, update your distributions to remove the function association from all cache behaviors, then delete the function. ## Example Usage ### Basic Example ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.cloudfront.Function; import com.pulumi.aws.cloudfront.FunctionArgs; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var test = new Function("test", FunctionArgs.builder() .runtime("cloudfront-js-1.0") .comment("my function") .publish(true) .code(Files.readString(Paths.get(String.format("%s/function.js", path.module())))) .build()); } } ``` ## Import Using `pulumi import`, import CloudFront Functions using the `name`. For example: ```sh $ pulumi import aws:cloudfront/function:Function test my_test_function ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      Function​(java.lang.String name)  
      Function​(java.lang.String name, FunctionArgs args)  
      Function​(java.lang.String name, FunctionArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> arn()  
      com.pulumi.core.Output<java.lang.String> code()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> comment()  
      com.pulumi.core.Output<java.lang.String> etag()  
      static Function get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, FunctionState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> liveStageEtag()  
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> publish()  
      com.pulumi.core.Output<java.lang.String> runtime()  
      com.pulumi.core.Output<java.lang.String> status()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Function

        public Function​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • Function

        public Function​(java.lang.String name,
                        FunctionArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • Function

        public Function​(java.lang.String name,
                        FunctionArgs args,
                        @Nullable
                        com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • arn

        public com.pulumi.core.Output<java.lang.String> arn()
        Returns:
        Amazon Resource Name (ARN) identifying your CloudFront Function.
      • code

        public com.pulumi.core.Output<java.lang.String> code()
        Returns:
        Source code of the function
      • comment

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> comment()
        Returns:
        Comment.
      • etag

        public com.pulumi.core.Output<java.lang.String> etag()
        Returns:
        ETag hash of the function. This is the value for the `DEVELOPMENT` stage of the function.
      • liveStageEtag

        public com.pulumi.core.Output<java.lang.String> liveStageEtag()
        Returns:
        ETag hash of any `LIVE` stage of the function.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        Unique name for your CloudFront Function.
      • publish

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> publish()
        Returns:
        Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`.
      • runtime

        public com.pulumi.core.Output<java.lang.String> runtime()
        Returns:
        Identifier of the function's runtime. Currently only `cloudfront-js-1.0` is valid. The following arguments are optional:
      • status

        public com.pulumi.core.Output<java.lang.String> status()
        Returns:
        Status of the function. Can be `UNPUBLISHED`, `UNASSOCIATED` or `ASSOCIATED`.
      • get

        public static Function get​(java.lang.String name,
                                   com.pulumi.core.Output<java.lang.String> id,
                                   @Nullable
                                   FunctionState state,
                                   @Nullable
                                   com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.