diff --git a/packages/@aws-cdk/custom-resource-handlers/package.json b/packages/@aws-cdk/custom-resource-handlers/package.json index 81d3733c7163d..256294cfe9a23 100644 --- a/packages/@aws-cdk/custom-resource-handlers/package.json +++ b/packages/@aws-cdk/custom-resource-handlers/package.json @@ -55,7 +55,8 @@ "sinon": "^9.2.4", "nock": "^13.5.4", "fs-extra": "^11.2.0", - "esbuild": "^0.20.2" + "esbuild": "^0.20.2", + "aws-sdk": "^2.1596.0" }, "dependencies": { "@aws-cdk/asset-node-proxy-agent-v6": "^2.0.3", diff --git a/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-custom-resource-provider-sdk-v2.test.ts b/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-custom-resource-provider-sdk-v2.test.ts index 6e7d2c106f5c7..4c07f2948c8ab 100644 --- a/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-custom-resource-provider-sdk-v2.test.ts +++ b/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-custom-resource-provider-sdk-v2.test.ts @@ -68,6 +68,7 @@ test('create event with physical resource id path', async () => { Bucket: 'my-bucket', }, physicalResourceId: { responsePath: 'Contents.1.ETag' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -107,6 +108,7 @@ test('update event with physical resource id', async () => { TopicArn: 'topicarn', }, physicalResourceId: { id: 'topicarn' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -139,6 +141,7 @@ test('delete event', async () => { Bucket: 'my-bucket', }, physicalResourceId: { responsePath: 'Contents.1.ETag' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -173,6 +176,7 @@ test('delete event with Delete call and no physical resource id in call', async parameters: { Name: 'my-param', }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -207,6 +211,7 @@ test('create event with Delete call only', async () => { parameters: { Name: 'my-param', }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -243,6 +248,7 @@ test('catch errors', async () => { }, physicalResourceId: { id: 'physicalResourceId' }, ignoreErrorCodesMatching: 'NoSuchBucket', + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -287,6 +293,7 @@ test('restrict output path', async () => { }, physicalResourceId: { id: 'id' }, outputPath: 'Contents.0', + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -332,6 +339,7 @@ test('restrict output paths', async () => { }, physicalResourceId: { id: 'id' }, outputPaths: ['Contents.0.Key', 'Contents.1.Key'], + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -370,6 +378,7 @@ test('can specify apiVersion and region', async () => { apiVersion: '2010-03-31', region: 'eu-west-1', physicalResourceId: { id: 'id' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -413,6 +422,7 @@ test('installs the latest SDK', async () => { TopicArn: 'topic', }, physicalResourceId: { id: 'id' }, + logApiResponseData: true, } satisfies AwsSdkCall), InstallLatestAwsSdk: 'true', }, @@ -452,6 +462,7 @@ test('invalid service name throws explicit error', async () => { TopicArn: 'topic', }, physicalResourceId: { id: 'id' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; diff --git a/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-sdk-v2-handler.test.ts b/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-sdk-v2-handler.test.ts index b1b85f8326f7b..1775fda5d85af 100644 --- a/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-sdk-v2-handler.test.ts +++ b/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-sdk-v2-handler.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ import * as AWS from 'aws-sdk'; import { v2handler as handler } from '../../../lib/custom-resources/aws-custom-resource-handler'; import { AwsSdkCall } from '../../../lib/custom-resources/aws-custom-resource-handler/construct-types'; @@ -57,6 +58,7 @@ test('SDK global credentials are never set', async () => { }, physicalResourceId: { id: 'id' }, service: 'SSM', + logApiResponseData: true, } satisfies AwsSdkCall), ServiceToken: 'serviceToken', }, @@ -89,6 +91,7 @@ test('SDK credentials are not persisted across subsequent invocations', async () }, physicalResourceId: { id: 'id' }, service: 'SSM', + logApiResponseData: true, } satisfies AwsSdkCall), ServiceToken: 'serviceToken', }, @@ -111,6 +114,7 @@ test('SDK credentials are not persisted across subsequent invocations', async () }, physicalResourceId: { id: 'id' }, service: 'SSM', + logApiResponseData: true, } satisfies AwsSdkCall), ServiceToken: 'serviceToken', }, @@ -132,6 +136,7 @@ test('SDK credentials are not persisted across subsequent invocations', async () }, physicalResourceId: { id: 'id' }, service: 'SSM', + logApiResponseData: true, } satisfies AwsSdkCall), ServiceToken: 'serviceToken', }, diff --git a/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-sdk-v3-handler.test.ts b/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-sdk-v3-handler.test.ts index 61ff7fcbd9586..65a5c7a60435e 100644 --- a/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-sdk-v3-handler.test.ts +++ b/packages/@aws-cdk/custom-resource-handlers/test/custom-resources/aws-custom-resource/aws-sdk-v3-handler.test.ts @@ -1,9 +1,9 @@ /* eslint-disable import/no-extraneous-dependencies */ process.env.AWS_REGION = 'us-east-1'; +import { CloudWatchClient, GetMetricDataCommand } from '@aws-sdk/client-cloudwatch'; import { EncryptCommand, KMSClient } from '@aws-sdk/client-kms'; import * as S3 from '@aws-sdk/client-s3'; -import { CloudWatchClient, GetMetricDataCommand } from '@aws-sdk/client-cloudwatch'; import { mockClient } from 'aws-sdk-client-mock'; import * as fs from 'fs-extra'; import * as nock from 'nock'; @@ -108,6 +108,7 @@ test('create event with physical resource id path', async () => { Bucket: 'my-bucket', }, physicalResourceId: { responsePath: 'Contents.1.ETag' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -145,6 +146,7 @@ test('update event with physical resource id', async () => { Key: 'key', }, physicalResourceId: { id: 'key' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -175,6 +177,7 @@ test('delete event', async () => { Bucket: 'my-bucket', }, physicalResourceId: { responsePath: 'Contents.1.ETag' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -209,6 +212,7 @@ test('delete event with Delete call and no physical resource id in call', async Bucket: 'my-bucket', Key: 'my-object', }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -244,6 +248,7 @@ test('create event with Delete call only', async () => { Bucket: 'my-bucket', Key: 'my-object', }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -279,6 +284,7 @@ test('catch errors - name property', async () => { }, physicalResourceId: { id: 'physicalResourceId' }, ignoreErrorCodesMatching: 'NoSuchBucket', + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -316,6 +322,7 @@ test('catch errors - constructor name', async () => { }, physicalResourceId: { id: 'physicalResourceId' }, ignoreErrorCodesMatching: 'S3ServiceException', + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -358,6 +365,7 @@ test('restrict output path', async () => { }, physicalResourceId: { id: 'id' }, outputPath: 'Contents.0', + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -401,6 +409,7 @@ test('restrict output paths', async () => { }, physicalResourceId: { id: 'id' }, outputPaths: ['Contents.0.Key', 'Contents.1.Key'], + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -437,6 +446,7 @@ test('can specify apiVersion and region', async () => { apiVersion: '2010-03-31', region: 'eu-west-1', physicalResourceId: { id: 'id' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -480,6 +490,7 @@ test('installs the latest SDK', async () => { Key: 'key', }, physicalResourceId: { id: 'id' }, + logApiResponseData: true, } satisfies AwsSdkCall), InstallLatestAwsSdk: 'true', }, @@ -521,6 +532,7 @@ test('falls back to installed sdk if installation fails', async () => { Key: 'key', }, physicalResourceId: { id: 'id' }, + logApiResponseData: true, } satisfies AwsSdkCall), InstallLatestAwsSdk: 'true', }, @@ -635,6 +647,7 @@ test('Being able to call the AWS SDK v2 format', async () => { Bucket: 'foo', Key: 'bar', }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -669,6 +682,7 @@ test('invalid v3 package name throws explicit error', async () => { Key: 'key', }, physicalResourceId: { id: 'id' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -699,6 +713,7 @@ test('invalid v2 service name throws explicit error', async () => { Key: 'key', }, physicalResourceId: { id: 'id' }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }; @@ -733,6 +748,7 @@ test('automatic Uint8Array conversion when necessary', async () => { KeyId: 'key-id', Plaintext: 'dummy-data', }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }, {} as AWSLambda.Context); @@ -792,6 +808,7 @@ test('automatic Date conversion when necessary', async () => { StartTime: new Date('2023-01-01'), EndTime: new Date('2023-01-02'), }, + logApiResponseData: true, } satisfies AwsSdkCall), }, }, {} as AWSLambda.Context);