Skip to content

Commit b049064

Browse files
authored
feat(custom-resources): add logging property to AwsSdkCall and create Logging class (#29648)
### Reason for this change SDK v2 and v3 handlers for `AwsCustomResource` log the event object passed to the handler, API responses, and caught /uncaught errors for each SDK call made. This can potentially result in logging sensitive information that a user may wish to hide. This PR introduces a new `logging` property on the `AwsSdkCall` interface that can be used to provide more control over logging in the SDK v2 and v3 handlers on a per SDK call basis. The `logging` flag is configurable via a new `Logging` class which exposes two static methods: - all: all logging during lambda execution is turned on - withDataHidden: hides all logged data associated with the API call response. This includes the raw response as well as the `Data` field on the response object Additional logging configurations can be added in the future. ### Description of changes Added a `logging` flag to the `AwsSdkCall` interface which is configurable via the new `Logging` class. The `Logging` class has an internal `render` method which renders the specified logging configuration which is passed as part of the `create`, `update`, and `delete` `ResourceProperties` to the lambda handler. These `logging` properties are then used throughout the handler to control what is logged based on their value ### Description of how you validated changes * A new integ test with `logging` as `withDataHidden` was added * Unit tests to ensure calling `render` on a `Logging` instance produces the expected result * Unit tests to ensure that using `logging` with `AwsSdkCall` while using `AwsCustomResource` produces the correct CloudFormation template ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent f10494c commit b049064

File tree

299 files changed

+69164
-108364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

299 files changed

+69164
-108364
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/LambdaDeploymentConfigTestDefaultTestDeployAssert161B09F6.assets.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/asset.6c34b6e864223e202d50bb862e2bf066393d4cdf36229f8e1646425a5224a10b/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/asset.e5178afc49b7c6a85127a67856ce958e4f0879ce6aad5e974cac2a088bf939db/index.js

-1
This file was deleted.

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/aws-cdk-codedeploy-lambda-config.assets.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/aws-cdk-codedeploy-lambda-config.template.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"Arn"
2323
]
2424
},
25-
"Create": "{\"service\":\"CodeDeploy\",\"action\":\"createDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\",\"computePlatform\":\"Lambda\",\"trafficRoutingConfig\":{\"type\":\"TimeBasedLinear\",\"timeBasedLinear\":{\"linearInterval\":1,\"linearPercentage\":5}}},\"physicalResourceId\":{\"id\":\"hello\"}}",
26-
"Update": "{\"service\":\"CodeDeploy\",\"action\":\"createDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\",\"computePlatform\":\"Lambda\",\"trafficRoutingConfig\":{\"type\":\"TimeBasedLinear\",\"timeBasedLinear\":{\"linearInterval\":1,\"linearPercentage\":5}}},\"physicalResourceId\":{\"id\":\"hello\"}}",
27-
"Delete": "{\"service\":\"CodeDeploy\",\"action\":\"deleteDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\"}}",
25+
"Create": "{\"service\":\"CodeDeploy\",\"action\":\"createDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\",\"computePlatform\":\"Lambda\",\"trafficRoutingConfig\":{\"type\":\"TimeBasedLinear\",\"timeBasedLinear\":{\"linearInterval\":1,\"linearPercentage\":5}}},\"physicalResourceId\":{\"id\":\"hello\"},\"logApiResponseData\":true}",
26+
"Update": "{\"service\":\"CodeDeploy\",\"action\":\"createDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\",\"computePlatform\":\"Lambda\",\"trafficRoutingConfig\":{\"type\":\"TimeBasedLinear\",\"timeBasedLinear\":{\"linearInterval\":1,\"linearPercentage\":5}}},\"physicalResourceId\":{\"id\":\"hello\"},\"logApiResponseData\":true}",
27+
"Delete": "{\"service\":\"CodeDeploy\",\"action\":\"deleteDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\"},\"logApiResponseData\":true}",
2828
"InstallLatestAwsSdk": false
2929
},
3030
"DependsOn": [
@@ -95,7 +95,7 @@
9595
"S3Bucket": {
9696
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
9797
},
98-
"S3Key": "e5178afc49b7c6a85127a67856ce958e4f0879ce6aad5e974cac2a088bf939db.zip"
98+
"S3Key": "6c34b6e864223e202d50bb862e2bf066393d4cdf36229f8e1646425a5224a10b.zip"
9999
},
100100
"Handler": "index.handler",
101101
"Role": {

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/manifest.json

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/tree.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-explicit-props.js.snapshot/asset.6c34b6e864223e202d50bb862e2bf066393d4cdf36229f8e1646425a5224a10b/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-explicit-props.js.snapshot/asset.e5178afc49b7c6a85127a67856ce958e4f0879ce6aad5e974cac2a088bf939db/index.js

-1
This file was deleted.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-explicit-props.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-explicit-props.js.snapshot/integ-user-pool-client-explicit-props.assets.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-explicit-props.js.snapshot/integ-user-pool-client-explicit-props.template.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
{
129129
"Ref": "myuserpoolmyuserpoolclientAFB2274E"
130130
},
131-
"\"}}"
131+
"\"},\"logApiResponseData\":true}"
132132
]
133133
]
134134
},
@@ -152,7 +152,7 @@
152152
{
153153
"Ref": "myuserpoolmyuserpoolclientAFB2274E"
154154
},
155-
"\"}}"
155+
"\"},\"logApiResponseData\":true}"
156156
]
157157
]
158158
},
@@ -228,7 +228,7 @@
228228
"S3Bucket": {
229229
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
230230
},
231-
"S3Key": "e5178afc49b7c6a85127a67856ce958e4f0879ce6aad5e974cac2a088bf939db.zip"
231+
"S3Key": "6c34b6e864223e202d50bb862e2bf066393d4cdf36229f8e1646425a5224a10b.zip"
232232
},
233233
"Handler": "index.handler",
234234
"Role": {

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-explicit-props.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-explicit-props.js.snapshot/manifest.json

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-explicit-props.js.snapshot/tree.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-secret.js.snapshot/asset.6c34b6e864223e202d50bb862e2bf066393d4cdf36229f8e1646425a5224a10b/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-secret.js.snapshot/asset.e5178afc49b7c6a85127a67856ce958e4f0879ce6aad5e974cac2a088bf939db/index.js

-1
This file was deleted.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-secret.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-secret.js.snapshot/integ-user-pool-client-secret.assets.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-secret.js.snapshot/integ-user-pool-client-secret.template.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
{
8888
"Ref": "poolclient2623294C"
8989
},
90-
"\"}}"
90+
"\"},\"logApiResponseData\":true}"
9191
]
9292
]
9393
},
@@ -111,7 +111,7 @@
111111
{
112112
"Ref": "poolclient2623294C"
113113
},
114-
"\"}}"
114+
"\"},\"logApiResponseData\":true}"
115115
]
116116
]
117117
},
@@ -187,7 +187,7 @@
187187
"S3Bucket": {
188188
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
189189
},
190-
"S3Key": "e5178afc49b7c6a85127a67856ce958e4f0879ce6aad5e974cac2a088bf939db.zip"
190+
"S3Key": "6c34b6e864223e202d50bb862e2bf066393d4cdf36229f8e1646425a5224a10b.zip"
191191
},
192192
"Handler": "index.handler",
193193
"Role": {

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-secret.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-secret.js.snapshot/integuserpoolclientsecrettestDefaultTestDeployAssert4FDD1661.assets.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-secret.js.snapshot/manifest.json

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-client-secret.js.snapshot/tree.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-domain-cfdist.js.snapshot/asset.6c34b6e864223e202d50bb862e2bf066393d4cdf36229f8e1646425a5224a10b/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-domain-cfdist.js.snapshot/asset.e5178afc49b7c6a85127a67856ce958e4f0879ce6aad5e974cac2a088bf939db/index.js

-1
This file was deleted.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-domain-cfdist.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)