Skip to content

Commit 3b9c983

Browse files
authored
chore(lambda): add toString to lambda architecture (#26145)
Add toString to Lambda Architecture property When throwing errors during synthesis, you can't see the architecture chosen for a lambda. Adding this toString method solves that Closes #26117 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 669dd7f commit 3b9c983

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/aws-cdk-lib/aws-lambda/lib/architecture.ts

+7
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,11 @@ export class Architecture {
3636
this.name = archName;
3737
this.dockerPlatform = dockerPlatform;
3838
}
39+
40+
/**
41+
* Returns a string representation of the architecture using the name
42+
*/
43+
public toString(): string {
44+
return this.name;
45+
}
3946
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
import { App, Stack } from '../../core';
3+
import * as lambda from '../lib';
4+
5+
describe('architecture', () => {
6+
const app = new App();
7+
const stack = new Stack(app, 'stack');
8+
9+
test('toString to return the architecture name', () => {
10+
// GIVEN
11+
const testLambda = new lambda.Function(stack, 'testLambda', {
12+
code: new lambda.InlineCode('foo'),
13+
handler: 'index.handler',
14+
runtime: lambda.Runtime.NODEJS_14_X,
15+
},
16+
);
17+
18+
// THEN
19+
expect(`${testLambda.architecture}`).toEqual(testLambda.architecture.name);
20+
});
21+
});

0 commit comments

Comments
 (0)