-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix(lambda): function version ignores layer version changes #20150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
6061750
ca89e1a
6562425
5bb2c19
c5af8f5
97f7f8c
144b38d
2bac2c9
5d45ae6
78fd23b
56db632
a050989
68d06b3
3f62785
4e6b561
0068a22
8df2619
d850443
404fcd3
594a590
dc4a0d2
757ef2d
a0a617b
5967433
3404aa3
47f7115
3be936f
72a3197
de03832
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,8 @@ import * as kms from '@aws-cdk/aws-kms'; | |
| import * as logs from '@aws-cdk/aws-logs'; | ||
| import * as sns from '@aws-cdk/aws-sns'; | ||
| import * as sqs from '@aws-cdk/aws-sqs'; | ||
| import { Annotations, ArnFormat, CfnResource, Duration, Fn, Lazy, Names, Size, Stack, Token } from '@aws-cdk/core'; | ||
| import { Annotations, ArnFormat, CfnResource, Duration, FeatureFlags, Fn, Lazy, Names, Size, Stack, Token } from '@aws-cdk/core'; | ||
| import { LAMBDA_RECOGNIZE_LAYER_VERSION } from '@aws-cdk/cx-api'; | ||
| import { Construct } from 'constructs'; | ||
| import { Architecture } from './architecture'; | ||
| import { Code, CodeConfig } from './code'; | ||
|
|
@@ -640,7 +641,10 @@ export class Function extends FunctionBase { | |
|
|
||
| protected readonly canCreatePermissions = true; | ||
|
|
||
| private readonly layers: ILayerVersion[] = []; | ||
| /** | ||
| * The lambda layers that this function depends on. | ||
| */ | ||
| public readonly layers: ILayerVersion[] = []; | ||
|
||
|
|
||
| private _logGroup?: logs.ILogGroup; | ||
|
|
||
|
|
@@ -771,7 +775,7 @@ export class Function extends FunctionBase { | |
| zipFile: code.inlineCode, | ||
| imageUri: code.image?.imageUri, | ||
| }, | ||
| layers: Lazy.list({ produce: () => this.layers.map(layer => layer.layerVersionArn) }, { omitEmpty: true }), // Evaluated on synthesis | ||
| layers: Lazy.list({ produce: () => this.renderLayers() }), // Evaluated on synthesis | ||
| handler: props.handler === Handler.FROM_IMAGE ? undefined : props.handler, | ||
| timeout: props.timeout && props.timeout.toSeconds(), | ||
| packageType: props.runtime === Runtime.FROM_IMAGE ? 'Image' : undefined, | ||
|
|
@@ -914,7 +918,6 @@ export class Function extends FunctionBase { | |
| // Currently no validations for compatible architectures since Lambda service | ||
| // allows layers configured with one architecture to be used with a Lambda function | ||
| // from another architecture. | ||
|
|
||
| this.layers.push(layer); | ||
| } | ||
| } | ||
|
|
@@ -1044,6 +1047,18 @@ Environment variables can be marked for removal when used in Lambda@Edge by sett | |
| this.role?.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('CloudWatchLambdaInsightsExecutionRolePolicy')); | ||
| } | ||
|
|
||
| private renderLayers() { | ||
| if (!this.layers || this.layers.length === 0) { | ||
| return undefined; | ||
| } | ||
|
|
||
| if (FeatureFlags.of(this).isEnabled(LAMBDA_RECOGNIZE_LAYER_VERSION)) { | ||
| this.layers.sort(); | ||
| } | ||
|
|
||
| return this.layers.map(layer => layer.layerVersionArn); | ||
| } | ||
|
|
||
| private renderEnvironment() { | ||
| if (!this.environment || Object.keys(this.environment).length === 0) { | ||
| return undefined; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.