Class CfnFunction
- All Implemented Interfaces:
IInspectable
,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
Modifier and TypeClassDescriptionstatic final class
A fluent builder forCfnFunction
.static interface
Contains configuration information about a CloudFront function.static interface
Contains metadata about a CloudFront function.static interface
The key value store association.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The CloudFormation resource type name for this resource class. -
Constructor Summary
ModifierConstructorDescriptionprotected
CfnFunction
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CfnFunction
(software.amazon.jsii.JsiiObjectRef objRef) CfnFunction
(software.constructs.Construct scope, String id, CfnFunctionProps props) -
Method Summary
Modifier and TypeMethodDescriptionThe ARN of the function.The Amazon Resource Name (ARN) of the function.A flag that determines whether to automatically publish the function to theLIVE
stage when it’s created.The function code.Contains configuration information about a CloudFront function.Contains metadata about a CloudFront function.getName()
A name to identify the function.void
inspect
(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties
(Map<String, Object> props) void
setAutoPublish
(Boolean value) A flag that determines whether to automatically publish the function to theLIVE
stage when it’s created.void
setAutoPublish
(IResolvable value) A flag that determines whether to automatically publish the function to theLIVE
stage when it’s created.void
setFunctionCode
(String value) The function code.void
setFunctionConfig
(IResolvable value) Contains configuration information about a CloudFront function.void
Contains configuration information about a CloudFront function.void
setFunctionMetadata
(IResolvable value) Contains metadata about a CloudFront function.void
Contains metadata about a CloudFront function.void
A 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, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validateProperties
Methods inherited from class software.amazon.awscdk.CfnRefElement
getRef
Methods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
Methods inherited from class software.constructs.Construct
getNode, isConstruct
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, wait, wait, wait
Methods 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) - 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
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspect
in 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:
renderProperties
in 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:
getCfnProperties
in classCfnResource
-
getFunctionCode
The function code. -
setFunctionCode
The function code. -
getFunctionConfig
Contains configuration information about a CloudFront function. -
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 theLIVE
stage when it’s created. -
setAutoPublish
A flag that determines whether to automatically publish the function to theLIVE
stage when it’s created. -
setAutoPublish
A flag that determines whether to automatically publish the function to theLIVE
stage when it’s created. -
getFunctionMetadata
Contains metadata about a CloudFront function. -
setFunctionMetadata
Contains metadata about a CloudFront function. -
setFunctionMetadata
@Stability(Stable) public void setFunctionMetadata(@Nullable CfnFunction.FunctionMetadataProperty value) Contains metadata about a CloudFront function.
-