Skip to content

Commit

Permalink
feat(core): description parameter in the CustomResourceProvider (#1…
Browse files Browse the repository at this point in the history
…3275)

Required by #13277 and #13276 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
robertd authored Feb 25, 2021
1 parent 17244af commit 78831cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
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

0 comments on commit 78831cf

Please sign in to comment.