Skip to content

Commit

Permalink
chore(lambda): add toString to lambda architecture (#26145)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
lukey-aleios authored Jul 17, 2023
1 parent 669dd7f commit 3b9c983
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/aws-cdk-lib/aws-lambda/lib/architecture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ export class Architecture {
this.name = archName;
this.dockerPlatform = dockerPlatform;
}

/**
* Returns a string representation of the architecture using the name
*/
public toString(): string {
return this.name;
}
}
21 changes: 21 additions & 0 deletions packages/aws-cdk-lib/aws-lambda/test/architecture.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import { App, Stack } from '../../core';
import * as lambda from '../lib';

describe('architecture', () => {
const app = new App();
const stack = new Stack(app, 'stack');

test('toString to return the architecture name', () => {
// GIVEN
const testLambda = new lambda.Function(stack, 'testLambda', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
},
);

// THEN
expect(`${testLambda.architecture}`).toEqual(testLambda.architecture.name);
});
});

0 comments on commit 3b9c983

Please sign in to comment.