@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:40.484Z") @Stability(value=Stable) public class SingletonFunction extends FunctionBase
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:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.codeguruprofiler.*;
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.services.iam.*;
import software.amazon.awscdk.services.kms.*;
import software.amazon.awscdk.services.lambda.*;
import software.amazon.awscdk.services.logs.*;
import software.amazon.awscdk.services.sns.*;
import software.amazon.awscdk.services.sqs.*;
Architecture architecture;
Code code;
CodeSigningConfig codeSigningConfig;
IDestination destination;
IEventSource eventSource;
FileSystem fileSystem;
Key key;
LambdaInsightsVersion lambdaInsightsVersion;
LayerVersion layerVersion;
PolicyStatement policyStatement;
ProfilingGroup profilingGroup;
Queue queue;
Role role;
Runtime runtime;
SecurityGroup securityGroup;
Size size;
Subnet subnet;
SubnetFilter subnetFilter;
Topic topic;
Vpc vpc;
SingletonFunction singletonFunction = SingletonFunction.Builder.create(this, "MySingletonFunction")
.code(code)
.handler("handler")
.runtime(runtime)
.uuid("uuid")
// the properties below are optional
.allowAllOutbound(false)
.allowPublicSubnet(false)
.architecture(architecture)
.codeSigningConfig(codeSigningConfig)
.currentVersionOptions(VersionOptions.builder()
.codeSha256("codeSha256")
.description("description")
.maxEventAge(Duration.minutes(30))
.onFailure(destination)
.onSuccess(destination)
.provisionedConcurrentExecutions(123)
.removalPolicy(RemovalPolicy.DESTROY)
.retryAttempts(123)
.build())
.deadLetterQueue(queue)
.deadLetterQueueEnabled(false)
.deadLetterTopic(topic)
.description("description")
.environment(Map.of(
"environmentKey", "environment"))
.environmentEncryption(key)
.ephemeralStorageSize(size)
.events(List.of(eventSource))
.filesystem(fileSystem)
.functionName("functionName")
.initialPolicy(List.of(policyStatement))
.insightsVersion(lambdaInsightsVersion)
.lambdaPurpose("lambdaPurpose")
.layers(List.of(layerVersion))
.logRetention(RetentionDays.ONE_DAY)
.logRetentionRetryOptions(LogRetentionRetryOptions.builder()
.base(Duration.minutes(30))
.maxRetries(123)
.build())
.logRetentionRole(role)
.maxEventAge(Duration.minutes(30))
.memorySize(123)
.onFailure(destination)
.onSuccess(destination)
.profiling(false)
.profilingGroup(profilingGroup)
.reservedConcurrentExecutions(123)
.retryAttempts(123)
.role(role)
.securityGroups(List.of(securityGroup))
.timeout(Duration.minutes(30))
.tracing(Tracing.ACTIVE)
.vpc(vpc)
.vpcSubnets(SubnetSelection.builder()
.availabilityZones(List.of("availabilityZones"))
.onePerAz(false)
.subnetFilters(List.of(subnetFilter))
.subnetGroupName("subnetGroupName")
.subnets(List.of(subnet))
.subnetType(SubnetType.PRIVATE_ISOLATED)
.build())
.build();
| Modifier and Type | Class and Description |
|---|---|
static class |
SingletonFunction.Builder
A fluent builder for
SingletonFunction. |
software.amazon.jsii.JsiiObject.InitializationModeIFunction.Jsii$DefaultIClientVpnConnectionHandler.Jsii$Default| Modifier | Constructor and Description |
|---|---|
|
SingletonFunction(software.constructs.Construct scope,
String id,
SingletonFunctionProps props) |
protected |
SingletonFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
SingletonFunction(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDependency(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.
|
Function |
addEnvironment(String key,
String value)
Adds an environment variable to this Lambda function.
|
Function |
addEnvironment(String key,
String value,
EnvironmentOptions options)
Adds an environment variable to this Lambda function.
|
void |
addLayers(ILayerVersion... layers)
Adds one or more Lambda Layers to this Lambda function.
|
void |
addPermission(String name,
Permission permission)
Adds a permission to the Lambda resource policy.
|
void |
dependOn(software.constructs.IConstruct down)
The SingletonFunction construct cannot be added as a dependency of another construct using node.addDependency().
|
Architecture |
getArchitecture()
The architecture of this Lambda Function.
|
protected Boolean |
getCanCreatePermissions()
Whether the addPermission() call adds any permissions.
|
Connections |
getConnections()
Access the Connections object.
|
Version |
getCurrentVersion()
Returns a `lambda.Version` which represents the current version of this singleton Lambda function.
|
String |
getFunctionArn()
The ARN fo the function.
|
String |
getFunctionName()
The name of the function.
|
IPrincipal |
getGrantPrincipal()
The principal this Lambda Function is running as.
|
Boolean |
getIsBoundToVpc()
Whether or not this Lambda function was bound to a VPC.
|
ILogGroup |
getLogGroup()
The LogGroup where the Lambda function's logs are made available.
|
software.constructs.Node |
getPermissionsNode()
The construct node where permissions are attached.
|
List<String> |
getResourceArnsForGrantInvoke()
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
|
IRole |
getRole()
The IAM role associated with this function.
|
Runtime |
getRuntime()
The runtime environment for the Lambda function.
|
addEventSource, addEventSourceMapping, addFunctionUrl, addFunctionUrl, addToRolePolicy, configureAsyncInvoke, considerWarningOnInvokeFunctionPermissions, getLatestVersion, grantInvoke, grantInvokeUrl, metric, metric, metricDuration, metricDuration, metricErrors, metricErrors, metricInvocations, metricInvocations, metricThrottles, metricThrottles, warnInvokeFunctionPermissionsapplyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourcejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitapplyRemovalPolicy, getEnv, getStackprotected SingletonFunction(software.amazon.jsii.JsiiObjectRef objRef)
protected SingletonFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public SingletonFunction(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
SingletonFunctionProps props)
scope - This parameter is required.id - This parameter is required.props - This parameter is required.@Stability(value=Stable)
public void addDependency(@NotNull
software.constructs.IDependable... up)
up - This parameter is required.@Stability(value=Stable) @NotNull public Function addEnvironment(@NotNull String key, @NotNull String value, @Nullable EnvironmentOptions options)
If this is a ref to a Lambda function, this operation results in a no-op.
key - The environment variable key. This parameter is required.value - The environment variable's value. This parameter is required.options - Environment variable options.@Stability(value=Stable) @NotNull public Function addEnvironment(@NotNull String key, @NotNull String value)
If this is a ref to a Lambda function, this operation results in a no-op.
key - The environment variable key. This parameter is required.value - The environment variable's value. This parameter is required.@Stability(value=Stable)
public void addLayers(@NotNull
ILayerVersion... layers)
layers - the layers to be added. This parameter is required.@Stability(value=Stable)
public void addPermission(@NotNull
String name,
@NotNull
Permission permission)
addPermission in interface IFunctionaddPermission in class FunctionBasename - This parameter is required.permission - This parameter is required.@Stability(value=Stable)
public void dependOn(@NotNull
software.constructs.IConstruct down)
down - This parameter is required.@Stability(value=Stable) @NotNull public Architecture getArchitecture()
getArchitecture in interface IFunctiongetArchitecture in class FunctionBase@Stability(value=Stable) @NotNull protected Boolean getCanCreatePermissions()
True for new Lambdas, false for version $LATEST and imported Lambdas from different accounts.
getCanCreatePermissions in class FunctionBase@Stability(value=Stable) @NotNull public Connections getConnections()
Will fail if not a VPC-enabled Lambda Function
getConnections in interface IConnectablegetConnections in class FunctionBase@Stability(value=Stable) @NotNull public Version getCurrentVersion()
You can specify options for this version using the currentVersionOptions
prop when initializing the lambda.SingletonFunction.
@Stability(value=Stable) @NotNull public String getFunctionArn()
getFunctionArn in interface IClientVpnConnectionHandlergetFunctionArn in interface IFunctiongetFunctionArn in class FunctionBase@Stability(value=Stable) @NotNull public String getFunctionName()
getFunctionName in interface IClientVpnConnectionHandlergetFunctionName in interface IFunctiongetFunctionName in class FunctionBase@Stability(value=Stable) @NotNull public IPrincipal getGrantPrincipal()
getGrantPrincipal in interface IGrantablegetGrantPrincipal in class FunctionBase@Stability(value=Stable) @NotNull public Boolean getIsBoundToVpc()
If this is is false, trying to access the connections object will fail.
getIsBoundToVpc in interface IFunctiongetIsBoundToVpc in class FunctionBase@Stability(value=Stable) @NotNull public ILogGroup getLogGroup()
If either logRetention is 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 logRetention is not set, the custom resource will reset the log retention
to never expire even if it was configured with a different value.
@Stability(value=Stable) @NotNull public software.constructs.Node getPermissionsNode()
getPermissionsNode in interface IFunctiongetPermissionsNode in class FunctionBase@Stability(value=Stable) @NotNull public List<String> getResourceArnsForGrantInvoke()
getResourceArnsForGrantInvoke in interface IFunctiongetResourceArnsForGrantInvoke in class FunctionBase@Stability(value=Stable) @NotNull public Runtime getRuntime()
@Stability(value=Stable) @Nullable public IRole getRole()
Undefined if the function was imported without a role.
getRole in interface IFunctiongetRole in class FunctionBaseCopyright © 2022. All rights reserved.