Class CfnFunction
- All Implemented Interfaces:
IInspectable,IFunctionRef,IEnvironmentAware,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
To create a function, you provide the function code and some configuration information about the function. The response contains an Amazon Resource Name (ARN) that uniquely identifies the function, and the function’s stage.
By default, when you create a function, it’s in the DEVELOPMENT stage. In this stage, you can test the function in the CloudFront console (or with TestFunction in the CloudFront API).
When you’re ready to use your function with a CloudFront distribution, publish the function to the LIVE stage. You can do this in the CloudFront console, with PublishFunction in the CloudFront API, or by updating the AWS::CloudFront::Function resource with the AutoPublish property set to true . When the function is published to the LIVE stage, you can attach it to a distribution’s cache behavior, using the function’s ARN.
To automatically publish the function to the LIVE stage when it’s created, set the AutoPublish property to true .
Example:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.cloudfront.*;
CfnFunction cfnFunction = CfnFunction.Builder.create(this, "MyCfnFunction")
.functionCode("functionCode")
.functionConfig(FunctionConfigProperty.builder()
.comment("comment")
.runtime("runtime")
// the properties below are optional
.keyValueStoreAssociations(List.of(KeyValueStoreAssociationProperty.builder()
.keyValueStoreArn("keyValueStoreArn")
.build()))
.build())
.name("name")
// the properties below are optional
.autoPublish(false)
.functionMetadata(FunctionMetadataProperty.builder()
.functionArn("functionArn")
.build())
.build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder forCfnFunction.static interfaceContains configuration information about a CloudFront function.static interfaceContains metadata about a CloudFront function.static interfaceThe key value store association.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.interfaces.cloudfront.IFunctionRef
IFunctionRef.Jsii$Default, IFunctionRef.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnFunction(software.amazon.jsii.JsiiObjectRef objRef) CfnFunction(software.constructs.Construct scope, String id, CfnFunctionProps props) Create a newAWS::CloudFront::Function. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringarnForFunction(IFunctionRef resource) The ARN of the function.The Amazon Resource Name (ARN) of the function.A flag that determines whether to automatically publish the function to theLIVEstage when it’s created.The function code.Contains configuration information about a CloudFront function.Contains metadata about a CloudFront function.A reference to a Function resource.getName()A name to identify the function.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.static BooleanChecks whether the given object is a CfnFunction.renderProperties(Map<String, Object> props) voidsetAutoPublish(Boolean value) A flag that determines whether to automatically publish the function to theLIVEstage when it’s created.voidsetAutoPublish(IResolvable value) A flag that determines whether to automatically publish the function to theLIVEstage when it’s created.voidsetFunctionCode(String value) The function code.voidsetFunctionConfig(IResolvable value) Contains configuration information about a CloudFront function.voidContains configuration information about a CloudFront function.voidsetFunctionMetadata(IResolvable value) Contains metadata about a CloudFront function.voidContains metadata about a CloudFront function.voidA name to identify the function.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getEnv, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.interfaces.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnFunction
protected CfnFunction(software.amazon.jsii.JsiiObjectRef objRef) -
CfnFunction
protected CfnFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnFunction
@Stability(Stable) public CfnFunction(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnFunctionProps props) Create a newAWS::CloudFront::Function.- Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.props- Resource properties. This parameter is required.
-
-
Method Details
-
arnForFunction
- Parameters:
resource- This parameter is required.
-
isCfnFunction
Checks whether the given object is a CfnFunction.- Parameters:
x- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrFunctionArn
The ARN of the function. For example:.arn:aws:cloudfront::123456789012:function/ExampleFunction.To get the function ARN, use the following syntax:
!GetAtt *Function_Logical_ID* .FunctionMetadata.FunctionARN -
getAttrFunctionMetadataFunctionArn
The Amazon Resource Name (ARN) of the function.The ARN uniquely identifies the function.
-
getAttrStage
-
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getFunctionRef
A reference to a Function resource.- Specified by:
getFunctionRefin interfaceIFunctionRef
-
getFunctionCode
The function code. -
setFunctionCode
The function code. -
getFunctionConfig
Contains configuration information about a CloudFront function.Returns union: either
IResolvableorCfnFunction.FunctionConfigProperty -
setFunctionConfig
Contains configuration information about a CloudFront function. -
setFunctionConfig
Contains configuration information about a CloudFront function. -
getName
A name to identify the function. -
setName
A name to identify the function. -
getAutoPublish
A flag that determines whether to automatically publish the function to theLIVEstage when it’s created.Returns union: either
BooleanorIResolvable -
setAutoPublish
A flag that determines whether to automatically publish the function to theLIVEstage when it’s created. -
setAutoPublish
A flag that determines whether to automatically publish the function to theLIVEstage when it’s created. -
getFunctionMetadata
Contains metadata about a CloudFront function.Returns union: either
IResolvableorCfnFunction.FunctionMetadataProperty -
setFunctionMetadata
Contains metadata about a CloudFront function. -
setFunctionMetadata
@Stability(Stable) public void setFunctionMetadata(@Nullable CfnFunction.FunctionMetadataProperty value) Contains metadata about a CloudFront function.
-