Skip to content

Commit f109720

Browse files
authored
chore(lambda): explain to not use Version (#19248)
The `Version` object's documentation was pretty unclear, and only needed to discourage users from using it. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent e01654e commit f109720

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/@aws-cdk/aws-lambda/lib/lambda-version.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,17 @@ export interface VersionAttributes {
9393
}
9494

9595
/**
96-
* A single newly-deployed version of a Lambda function.
96+
* Tag the current state of a Function with a Version number
9797
*
98-
* This object exists to--at deploy time--query the "then-current" version of
99-
* the Lambda function that it refers to. This Version object can then be
100-
* used in `Alias` to refer to a particular deployment of a Lambda.
98+
* Avoid using this resource directly. If you need a Version object, use
99+
* `function.currentVersion` instead. That will add a Version object to your
100+
* template, and make sure the Version is invalidated whenever the Function
101+
* object changes. If you use the `Version` resource directly, you are
102+
* responsible for making sure it is invalidated (by changing its
103+
* logical ID) whenever necessary.
101104
*
102-
* This means that for every new update you deploy to your Lambda (using the
103-
* CDK and Aliases), you must always create a new Version object. In
104-
* particular, it must have a different name, so that a new resource is
105-
* created.
105+
* Version resources can then be used in `Alias` resources to refer to a
106+
* particular deployment of a Lambda.
106107
*
107108
* If you want to ensure that you're associating the right version with
108109
* the right deployment, specify the `codeSha256` property while

0 commit comments

Comments
 (0)