Skip to content
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

feat(core): description parameter in the CustomResourceProvider #13275

Merged
merged 2 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@aws-cdk/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ stack-unique identifier and returns the service token:
const serviceToken = CustomResourceProvider.getOrCreate(this, 'Custom::MyCustomResourceType', {
codeDirectory: `${__dirname}/my-handler`,
runtime: CustomResourceProviderRuntime.NODEJS_12, // currently the only supported runtime
description: "Lambda function created by the custom resource provider",
});

new CustomResource(this, 'MyResource', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export interface CustomResourceProviderProps {
* @default - No environment variables.
*/
readonly environment?: { [key: string]: string };

/**
* A description of the function.
*
* @default - No description.
*/
readonly description?: string;
}

/**
Expand Down Expand Up @@ -205,6 +212,7 @@ export class CustomResourceProvider extends CoreConstruct {
Role: role.getAtt('Arn'),
Runtime: 'nodejs12.x',
Environment: this.renderEnvironmentVariables(props.environment),
Description: props.description ?? undefined,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ nodeunitShim({
test.done();
},

'memorySize and timeout'(test: Test) {
'memorySize, timeout and description'(test: Test) {
// GIVEN
const stack = new Stack();

Expand All @@ -197,13 +197,15 @@ nodeunitShim({
runtime: CustomResourceProviderRuntime.NODEJS_12,
memorySize: Size.gibibytes(2),
timeout: Duration.minutes(5),
description: 'veni vidi vici',
});

// THEN
const template = toCloudFormation(stack);
const lambda = template.Resources.CustomMyResourceTypeCustomResourceProviderHandler29FBDD2A;
test.deepEqual(lambda.Properties.MemorySize, 2048);
test.deepEqual(lambda.Properties.Timeout, 300);
test.deepEqual(lambda.Properties.Description, 'veni vidi vici');
test.done();
},

Expand Down