From 0436331e3ff9b57261dfadea995bc71e604fc1bd Mon Sep 17 00:00:00 2001 From: Hiroki Yamazaki Date: Thu, 3 Aug 2023 12:02:10 +0000 Subject: [PATCH 1/4] docs(custom-resource): add example for AwsApiCall in v2 and v3 --- .../aws-custom-resource.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts index 31a9045961742..4ca4fc1220278 100644 --- a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts +++ b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts @@ -74,6 +74,41 @@ export class PhysicalResourceId { /** * An AWS SDK call. + * + * @example + * + * // In AWS SDK for JavaScript v2 + * new cr.AwsCustomResource(this, 'GetParameterV2', { + * onUpdate: { // will also be called for a CREATE event + * service: 'SSM', + * action: 'getParameter', + * parameters: { + * Name: 'my-parameter', + * WithDecryption: true, + * }, + * physicalResourceId: cr.PhysicalResourceId.fromResponse('Parameter.ARN'), + * }, + * policy: cr.AwsCustomResourcePolicy.fromSdkCalls({ + * resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE, + * }), + * }); + * + * // In AWS SDK for JavaScript v3 + * new cr.AwsCustomResource(this, 'GetParameterV3', { + * onUpdate: { + * service: '@aws-sdk/client-ssm', // 'SSM' in v2 + * action: 'GetParameterCommand', // 'getParameter' in v2 + * parameters: { + * Name: 'my-parameter', + * WithDecryption: true, + * }, + * physicalResourceId: cr.PhysicalResourceId.fromResponse('Parameter.ARN'), + * }, + * policy: cr.AwsCustomResourcePolicy.fromSdkCalls({ + * resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE, + * }), + * }); + * */ export interface AwsSdkCall { /** From 8b55145c910c852a87745eddf54f7c03960dde78 Mon Sep 17 00:00:00 2001 From: Hiroki Yamazaki Date: Thu, 3 Aug 2023 12:18:50 +0000 Subject: [PATCH 2/4] rm trailing space --- .../lib/aws-custom-resource/aws-custom-resource.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts index 4ca4fc1220278..2401bec804ab3 100644 --- a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts +++ b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts @@ -74,7 +74,7 @@ export class PhysicalResourceId { /** * An AWS SDK call. - * + * * @example * * // In AWS SDK for JavaScript v2 From 01e014d57a2f55e635441895660c6f9f7bb796bb Mon Sep 17 00:00:00 2001 From: Hiroki Yamazaki Date: Tue, 8 Aug 2023 05:54:50 +0000 Subject: [PATCH 3/4] update comment --- .../aws-custom-resource.ts | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts index 2401bec804ab3..52a211acce79e 100644 --- a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts +++ b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts @@ -74,30 +74,15 @@ export class PhysicalResourceId { /** * An AWS SDK call. + * The `AwsCustomResource` uses the AWS SDK for JavaScript v3 by default. + * Services, actions and parameters can be found in the [API documentation](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/). * * @example * - * // In AWS SDK for JavaScript v2 - * new cr.AwsCustomResource(this, 'GetParameterV2', { + * new cr.AwsCustomResource(this, 'GetParameterCustomResource', { * onUpdate: { // will also be called for a CREATE event - * service: 'SSM', - * action: 'getParameter', - * parameters: { - * Name: 'my-parameter', - * WithDecryption: true, - * }, - * physicalResourceId: cr.PhysicalResourceId.fromResponse('Parameter.ARN'), - * }, - * policy: cr.AwsCustomResourcePolicy.fromSdkCalls({ - * resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE, - * }), - * }); - * - * // In AWS SDK for JavaScript v3 - * new cr.AwsCustomResource(this, 'GetParameterV3', { - * onUpdate: { - * service: '@aws-sdk/client-ssm', // 'SSM' in v2 - * action: 'GetParameterCommand', // 'getParameter' in v2 + * service: '@aws-sdk/client-ssm', // 'SSM' in SDKv2 + * action: 'GetParameterCommand', // 'getParameter' in SDKv2 * parameters: { * Name: 'my-parameter', * WithDecryption: true, From aef579ac7ad709e0c09ffa472b387adca31c4e73 Mon Sep 17 00:00:00 2001 From: Hiroki Yamazaki Date: Tue, 8 Aug 2023 08:22:11 +0000 Subject: [PATCH 4/4] update example --- .../lib/aws-custom-resource/aws-custom-resource.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts index 52a211acce79e..aaea15bf280e1 100644 --- a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts +++ b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts @@ -74,15 +74,13 @@ export class PhysicalResourceId { /** * An AWS SDK call. - * The `AwsCustomResource` uses the AWS SDK for JavaScript v3 by default. - * Services, actions and parameters can be found in the [API documentation](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/). * * @example * * new cr.AwsCustomResource(this, 'GetParameterCustomResource', { * onUpdate: { // will also be called for a CREATE event - * service: '@aws-sdk/client-ssm', // 'SSM' in SDKv2 - * action: 'GetParameterCommand', // 'getParameter' in SDKv2 + * service: 'SSM', + * action: 'getParameter', * parameters: { * Name: 'my-parameter', * WithDecryption: true,