Skip to content

Commit 2c8a409

Browse files
docs(lambda): Example to guarantee new version creation (#12598)
This is created to provide an example of a workaround for #10136 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 889d673 commit 2c8a409

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/@aws-cdk/aws-lambda/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ of a new version resource. You can specify options for this version through the
143143
> of code providers (such as `lambda.Code.fromBucket`) require that you define a
144144
> `lambda.Version` resource directly since the CDK is unable to determine if
145145
> their contents had changed.
146+
>
147+
> An alternative to defining a `lambda.Version` is to set an environment variable
148+
> which changes at least as often as your code does. This makes sure the function
149+
> always has the latest code.
150+
>
151+
> ```ts
152+
> const codeVersion = "stringOrMethodToGetCodeVersion";
153+
> const fn = new lambda.Function(this, 'MyFunction', {
154+
> environment: {
155+
> 'CodeVersionString': codeVersion
156+
> }
157+
> });
158+
> ```
146159
147160
The `version.addAlias()` method can be used to define an AWS Lambda alias that
148161
points to a specific version.

0 commit comments

Comments
 (0)