java.lang.Object
software.amazon.jsii.JsiiObject
All Implemented Interfaces:
IResource, IClientVpnConnectionHandler, IConnectable, IGrantable, IFunction, IVersion, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.94.0 (build b380f01)", date="2024-02-23T02:06:34.595Z") @Stability(Stable) public class Version extends QualifiedFunctionBase implements IVersion
Tag the current state of a Function with a Version number.

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_LATEST)
         .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();
 
  • 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.
      Calling addAlias on a Version object will cause the Alias to be replaced on every function update. Call function.addAlias() or new Alias() instead.
      (deprecated) Defines an alias for this version.

      Specified by:
      addAlias in interface IVersion
      Parameters:
      aliasName - The name of the alias (e.g. "live"). This parameter is required.
      options - Alias options.
    • addAlias

      @Stability(Deprecated) @Deprecated @NotNull public Alias addAlias(@NotNull String aliasName)
      Deprecated.
      Calling addAlias on a Version object will cause the Alias to be replaced on every function update. Call function.addAlias() or new Alias() instead.
      (deprecated) Defines an alias for this version.

      Specified by:
      addAlias in interface IVersion
      Parameters:
      aliasName - The name of the alias (e.g. "live"). This parameter is required.
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props)
      Return the given named metric for this Function.

      Specified by:
      metric in interface IFunction
      Overrides:
      metric in class FunctionBase
      Parameters:
      metricName - This parameter is required.
      props -
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName)
      Return the given named metric for this Function.

      Specified by:
      metric in interface IFunction
      Overrides:
      metric in class FunctionBase
      Parameters:
      metricName - This parameter is required.
    • getArchitecture

      @Stability(Stable) @NotNull public Architecture getArchitecture()
      The architecture of this Lambda Function.
      Specified by:
      getArchitecture in interface IFunction
      Specified by:
      getArchitecture in class FunctionBase
    • getCanCreatePermissions

      @Stability(Stable) @NotNull protected Boolean getCanCreatePermissions()
      Whether the addPermission() call adds any permissions.

      True for new Lambdas, false for version $LATEST and imported Lambdas from different accounts.

      Specified by:
      getCanCreatePermissions in class FunctionBase
    • getEdgeArn

      @Stability(Stable) @NotNull public String getEdgeArn()
      The ARN of the version for Lambda@Edge.
      Specified by:
      getEdgeArn in interface IVersion
    • getFunctionArn

      @Stability(Stable) @NotNull public String getFunctionArn()
      The ARN fo the function.
      Specified by:
      getFunctionArn in interface IClientVpnConnectionHandler
      Specified by:
      getFunctionArn in interface IFunction
      Specified by:
      getFunctionArn in class FunctionBase
    • getFunctionName

      @Stability(Stable) @NotNull public String getFunctionName()
      The name of the function.
      Specified by:
      getFunctionName in interface IClientVpnConnectionHandler
      Specified by:
      getFunctionName in interface IFunction
      Specified by:
      getFunctionName in class FunctionBase
    • getGrantPrincipal

      @Stability(Stable) @NotNull public IPrincipal getGrantPrincipal()
      The principal this Lambda Function is running as.
      Specified by:
      getGrantPrincipal in interface IGrantable
      Specified by:
      getGrantPrincipal in class FunctionBase
    • getLambda

      @Stability(Stable) @NotNull public IFunction getLambda()
      The underlying IFunction.
      Specified by:
      getLambda in interface IVersion
      Specified by:
      getLambda in class QualifiedFunctionBase
    • getQualifier

      @Stability(Stable) @NotNull protected String 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.

      Specified by:
      getQualifier in class QualifiedFunctionBase
      See Also:
    • getVersion

      @Stability(Stable) @NotNull public String getVersion()
      The most recently deployed version of this function.
      Specified by:
      getVersion in interface IVersion
    • getRole

      @Stability(Stable) @Nullable public IRole getRole()
      The IAM role associated with this function.

      Undefined if the function was imported without a role.

      Specified by:
      getRole in interface IFunction
      Specified by:
      getRole in class FunctionBase