Class SingletonFunction
- All Implemented Interfaces:
IEnvironmentAware,IFunctionRef,IResource,IClientVpnConnectionHandler,IConnectable,IGrantable,IFunction,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
This construct is a way to guarantee that the lambda function will be guaranteed to be part of the stack,
once and only once, irrespective of how many times the construct is declared to be part of the stack.
This is guaranteed as long as the uuid property and the optional lambdaPurpose property stay the same
whenever they're declared into the stack.
Example:
SingletonFunction fn = new SingletonFunction(this, "MyProvider", functionProps);
CustomResource.Builder.create(this, "MyResource")
.serviceToken(fn.getFunctionArn())
.build();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.IClientVpnConnectionHandler
IClientVpnConnectionHandler.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.lambda.IFunction
IFunction.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSingletonFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedSingletonFunction(software.amazon.jsii.JsiiObjectRef objRef) SingletonFunction(software.constructs.Construct scope, String id, SingletonFunctionProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDependency(software.constructs.IDependable... up) Using node.addDependency() does not work on this method as the underlying lambda function is modeled as a singleton across the stack.addEnvironment(String key, String value) Adds an environment variable to this Lambda function.addEnvironment(String key, String value, EnvironmentOptions options) Adds an environment variable to this Lambda function.voidaddLayers(ILayerVersion... layers) Adds one or more Lambda Layers to this Lambda function.voidaddMetadata(String type, Object data) Use this method to write to the construct tree.voidaddMetadata(String type, Object data, software.constructs.MetadataOptions options) Use this method to write to the construct tree.voidaddPermission(String name, Permission permission) Adds a permission to the Lambda resource policy.voiddependOn(software.constructs.IConstruct down) The SingletonFunction construct cannot be added as a dependency of another construct using node.addDependency().The architecture of this Lambda Function.protected BooleanWhether the addPermission() call adds any permissions.Access the Connections object.The name of the singleton function.Returns alambda.Versionwhich represents the current version of this singleton Lambda function.The ARN fo the function.The name of the function.The principal this Lambda Function is running as.Whether or not this Lambda function was bound to a VPC.The LogGroup where the Lambda function's logs are made available.software.constructs.NodeThe construct node where permissions are attached.The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().getRole()The IAM role associated with this function.The runtime environment for the Lambda function.The tenancy configuration for this function.Methods inherited from class software.amazon.awscdk.services.lambda.FunctionBase
addEventSource, addEventSourceMapping, addFunctionUrl, addFunctionUrl, addToRolePolicy, configureAsyncInvoke, considerWarningOnInvokeFunctionPermissions, getFunctionRef, getLatestVersion, grantInvoke, grantInvokeCompositePrincipal, grantInvokeLatestVersion, grantInvokeUrl, grantInvokeVersion, metric, metric, metricDuration, metricDuration, metricErrors, metricErrors, metricInvocations, metricInvocations, metricThrottles, metricThrottles, warnInvokeFunctionPermissionsMethods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourceMethods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods 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.amazon.awscdk.IResource
applyRemovalPolicy, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
PROPERTY_INJECTION_ID
Uniquely identifies this class.
-
-
Constructor Details
-
SingletonFunction
protected SingletonFunction(software.amazon.jsii.JsiiObjectRef objRef) -
SingletonFunction
protected SingletonFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
SingletonFunction
@Stability(Stable) public SingletonFunction(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull SingletonFunctionProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props- This parameter is required.
-
-
Method Details
-
addDependency
@Stability(Stable) public void addDependency(@NotNull software.constructs.IDependable... up) Using node.addDependency() does not work on this method as the underlying lambda function is modeled as a singleton across the stack. Use this method instead to declare dependencies.- Parameters:
up- This parameter is required.
-
addEnvironment
@Stability(Stable) @NotNull public Function addEnvironment(@NotNull String key, @NotNull String value, @Nullable EnvironmentOptions options) Adds an environment variable to this Lambda function.If this is a ref to a Lambda function, this operation results in a no-op.
- Parameters:
key- The environment variable key. This parameter is required.value- The environment variable's value. This parameter is required.options- Environment variable options.
-
addEnvironment
@Stability(Stable) @NotNull public Function addEnvironment(@NotNull String key, @NotNull String value) Adds an environment variable to this Lambda function.If this is a ref to a Lambda function, this operation results in a no-op.
- Parameters:
key- The environment variable key. This parameter is required.value- The environment variable's value. This parameter is required.
-
addLayers
Adds one or more Lambda Layers to this Lambda function.- Parameters:
layers- the layers to be added. This parameter is required.
-
addMetadata
@Stability(Stable) public void addMetadata(@NotNull String type, @NotNull Object data, @Nullable software.constructs.MetadataOptions options) Use this method to write to the construct tree.The metadata entries are written to the Cloud Assembly Manifest if the
treeMetadataproperty is specified in the props of the App that contains this Construct.- Parameters:
type- This parameter is required.data- This parameter is required.options-
-
addMetadata
Use this method to write to the construct tree.The metadata entries are written to the Cloud Assembly Manifest if the
treeMetadataproperty is specified in the props of the App that contains this Construct.- Parameters:
type- This parameter is required.data- This parameter is required.
-
addPermission
Adds a permission to the Lambda resource policy.- Specified by:
addPermissionin interfaceIFunction- Overrides:
addPermissionin classFunctionBase- Parameters:
name- This parameter is required.permission- This parameter is required.- See Also:
-
dependOn
@Stability(Stable) public void dependOn(@NotNull software.constructs.IConstruct down) The SingletonFunction construct cannot be added as a dependency of another construct using node.addDependency(). Use this method instead to declare this as a dependency of another construct.- Parameters:
down- This parameter is required.
-
getArchitecture
The architecture of this Lambda Function.- Specified by:
getArchitecturein interfaceIFunction- Specified by:
getArchitecturein classFunctionBase
-
getCanCreatePermissions
Whether the addPermission() call adds any permissions.True for new Lambdas, false for version $LATEST and imported Lambdas from different accounts.
- Specified by:
getCanCreatePermissionsin classFunctionBase
-
getConnections
Access the Connections object.Will fail if not a VPC-enabled Lambda Function
- Specified by:
getConnectionsin interfaceIConnectable- Overrides:
getConnectionsin classFunctionBase
-
getConstructName
The name of the singleton function.It acts as a unique ID within its CDK stack.
-
getCurrentVersion
Returns alambda.Versionwhich represents the current version of this singleton Lambda function. A new version will be created every time the function's configuration changes.You can specify options for this version using the
currentVersionOptionsprop when initializing thelambda.SingletonFunction. -
getFunctionArn
The ARN fo the function.- Specified by:
getFunctionArnin interfaceIClientVpnConnectionHandler- Specified by:
getFunctionArnin interfaceIFunction- Specified by:
getFunctionArnin classFunctionBase
-
getFunctionName
The name of the function.- Specified by:
getFunctionNamein interfaceIClientVpnConnectionHandler- Specified by:
getFunctionNamein interfaceIFunction- Specified by:
getFunctionNamein classFunctionBase
-
getGrantPrincipal
The principal this Lambda Function is running as.- Specified by:
getGrantPrincipalin interfaceIGrantable- Specified by:
getGrantPrincipalin classFunctionBase
-
getIsBoundToVpc
Whether or not this Lambda function was bound to a VPC.If this is is
false, trying to access theconnectionsobject will fail.- Specified by:
getIsBoundToVpcin interfaceIFunction- Overrides:
getIsBoundToVpcin classFunctionBase
-
getLogGroup
The LogGroup where the Lambda function's logs are made available.If either
logRetentionis set or this property is called, a CloudFormation custom resource is added to the stack that pre-creates the log group as part of the stack deployment, if it already doesn't exist, and sets the correct log retention period (never expire, by default).Further, if the log group already exists and the
logRetentionis not set, the custom resource will reset the log retention to never expire even if it was configured with a different value. -
getPermissionsNode
@Stability(Stable) @NotNull public software.constructs.Node getPermissionsNode()The construct node where permissions are attached.- Specified by:
getPermissionsNodein interfaceIFunction- Specified by:
getPermissionsNodein classFunctionBase
-
getResourceArnsForGrantInvoke
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().- Specified by:
getResourceArnsForGrantInvokein interfaceIFunction- Specified by:
getResourceArnsForGrantInvokein classFunctionBase
-
getRuntime
The runtime environment for the Lambda function. -
getRole
The IAM role associated with this function.Undefined if the function was imported without a role.
- Specified by:
getRolein interfaceIFunction- Specified by:
getRolein classFunctionBase
-
getTenancyConfig
The tenancy configuration for this function.- Specified by:
getTenancyConfigin interfaceIFunction- Specified by:
getTenancyConfigin classFunctionBase
-