Class Version
- All Implemented Interfaces:
IConstruct,IDependable,IResource,IClientVpnConnectionHandler,IConnectable,IGrantable,IFunction,IVersion,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
Avoid using this resource directly. If you need a Version object, use
function.currentVersion instead. That will add a Version object to your
template, and make sure the Version is invalidated whenever the Function
object changes. If you use the Version resource directly, you are
responsible for making sure it is invalidated (by changing its
logical ID) whenever necessary.
Version resources can then be used in Alias resources to refer to a
particular deployment of a Lambda.
If you want to ensure that you're associating the right version with
the right deployment, specify the codeSha256 property while
creating the `Version.
Example:
CfnParametersCode lambdaCode = Code.fromCfnParameters();
Function func = Function.Builder.create(this, "Lambda")
.code(lambdaCode)
.handler("index.handler")
.runtime(Runtime.NODEJS_14_X)
.build();
// used to make sure each CDK synthesis produces a different Version
Version version = func.getCurrentVersion();
Alias alias = Alias.Builder.create(this, "LambdaAlias")
.aliasName("Prod")
.version(version)
.build();
LambdaDeploymentGroup.Builder.create(this, "DeploymentGroup")
.alias(alias)
.deploymentConfig(LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE)
.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.amazon.awscdk.core.IConstruct
IConstruct.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.core.IResource
IResource.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.lambda.IVersion
IVersion.Jsii$Default, IVersion.Jsii$Proxy -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedVersion(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedVersion(software.amazon.jsii.JsiiObjectRef objRef) Version(software.constructs.Construct scope, String id, VersionProps props) -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.addAlias(String aliasName, AliasOptions options) Deprecated.CallingaddAliason aVersionobject will cause the Alias to be replaced on every function update.static IVersionfromVersionArn(software.constructs.Construct scope, String id, String versionArn) Construct a Version object from a Version ARN.static IVersionfromVersionAttributes(software.constructs.Construct scope, String id, VersionAttributes attrs) The architecture of this Lambda Function.protected BooleanWhether the addPermission() call adds any permissions.The ARN of the version for Lambda@Edge.The ARN fo the function.The name of the function.The principal this Lambda Function is running as.The underlying AWS Lambda function.protected StringThe qualifier of the version or alias of this function.getRole()The IAM role associated with this function.The most recently deployed version of this function.Return the given named metric for this Function.metric(String metricName, MetricOptions props) Return the given named metric for this Function.Methods inherited from class software.amazon.awscdk.services.lambda.QualifiedFunctionBase
configureAsyncInvoke, considerWarningOnInvokeFunctionPermissions, getLatestVersion, getPermissionsNode, getResourceArnsForGrantInvokeMethods inherited from class software.amazon.awscdk.services.lambda.FunctionBase
addEventSource, addEventSourceMapping, addFunctionUrl, addFunctionUrl, addPermission, addToRolePolicy, getConnections, getIsBoundToVpc, grantInvoke, grantInvokeUrl, metricDuration, metricDuration, metricErrors, metricErrors, metricInvocations, metricInvocations, metricThrottles, metricThrottles, warnInvokeFunctionPermissionsMethods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourceMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.constructs.Construct
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.services.ec2.IConnectable
getConnectionsMethods inherited from interface software.amazon.awscdk.core.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.services.lambda.IFunction
addEventSource, addEventSourceMapping, addFunctionUrl, addFunctionUrl, addPermission, addToRolePolicy, configureAsyncInvoke, getIsBoundToVpc, getLatestVersion, getPermissionsNode, getResourceArnsForGrantInvoke, grantInvoke, grantInvokeUrl, metricDuration, metricDuration, metricErrors, metricErrors, metricInvocations, metricInvocations, metricThrottles, metricThrottlesMethods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Version
protected Version(software.amazon.jsii.JsiiObjectRef objRef) -
Version
protected Version(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Version
@Stability(Stable) public Version(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull VersionProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props- This parameter is required.
-
-
Method Details
-
fromVersionArn
@Stability(Stable) @NotNull public static IVersion fromVersionArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String versionArn) Construct a Version object from a Version ARN.- Parameters:
scope- The cdk scope creating this resource. This parameter is required.id- The cdk id of this resource. This parameter is required.versionArn- The version ARN to create this version from. This parameter is required.
-
fromVersionAttributes
@Stability(Stable) @NotNull public static IVersion fromVersionAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull VersionAttributes attrs) - Parameters:
scope- This parameter is required.id- This parameter is required.attrs- This parameter is required.
-
addAlias
@Stability(Deprecated) @Deprecated @NotNull public Alias addAlias(@NotNull String aliasName, @Nullable AliasOptions options) Deprecated.CallingaddAliason aVersionobject will cause the Alias to be replaced on every function update. Callfunction.addAlias()ornew Alias()instead.(deprecated) Defines an alias for this version. -
addAlias
Deprecated.CallingaddAliason aVersionobject will cause the Alias to be replaced on every function update. Callfunction.addAlias()ornew Alias()instead.(deprecated) Defines an alias for this version. -
metric
@Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props) Return the given named metric for this Function.- Specified by:
metricin interfaceIFunction- Overrides:
metricin classFunctionBase- Parameters:
metricName- This parameter is required.props-
-
metric
Return the given named metric for this Function.- Specified by:
metricin interfaceIFunction- Overrides:
metricin classFunctionBase- Parameters:
metricName- 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
-
getEdgeArn
The ARN of the version for Lambda@Edge.- Specified by:
getEdgeArnin interfaceIVersion
-
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
-
getLambda
The underlying AWS Lambda function.- Specified by:
getLambdain interfaceIVersion- Specified by:
getLambdain classQualifiedFunctionBase
-
getQualifier
The qualifier of the version or alias of this function.A qualifier is the identifier that's appended to a version or alias ARN.
-
getVersion
The most recently deployed version of this function.- Specified by:
getVersionin interfaceIVersion
-
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
-
addAliason aVersionobject will cause the Alias to be replaced on every function update.