Skip to content

Commit

Permalink
chore(custom-resources): import the AWSLambda package explicitly (#14643
Browse files Browse the repository at this point in the history
)

When linking the aws-cdk repository to a CDK app using the `link-all.sh` script,
if the app uses `ts-node`,
the Lambda code in the @aws-cdk/custom-resources package gets picked up by the TypeScript compiler.
That code relied on the `aws-lambda` package being implicitly available,
but that would cause `ts-node` to fail.
Add an explicit import of it in the code -
I checked the only difference in the generated JS code is the sourceMappingUrl,
so it shouldn't make a difference at runtime,
but allows `ts-node` to load that file successfully.

Fixes #11627

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
skinny85 committed May 13, 2021
1 parent 9a4d624 commit 282d242
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
18 changes: 9 additions & 9 deletions packages/@aws-cdk/aws-msk/test/integ.cluster.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7"
"Ref": "AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483S3Bucket9DEDD0AB"
},
"S3Key": {
"Fn::Join": [
Expand All @@ -537,7 +537,7 @@
"Fn::Split": [
"||",
{
"Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7"
"Ref": "AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483S3VersionKeyA54743D3"
}
]
}
Expand All @@ -550,7 +550,7 @@
"Fn::Split": [
"||",
{
"Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7"
"Ref": "AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483S3VersionKeyA54743D3"
}
]
}
Expand All @@ -576,17 +576,17 @@
}
},
"Parameters": {
"AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7": {
"AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483S3Bucket9DEDD0AB": {
"Type": "String",
"Description": "S3 bucket for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\""
"Description": "S3 bucket for asset \"f56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483\""
},
"AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7": {
"AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483S3VersionKeyA54743D3": {
"Type": "String",
"Description": "S3 key for asset version \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\""
"Description": "S3 key for asset version \"f56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483\""
},
"AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98ArtifactHash35A756EB": {
"AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483ArtifactHash228F5AF4": {
"Type": "String",
"Description": "Artifact hash for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\""
"Description": "Artifact hash for asset \"f56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483\""
}
},
"Outputs": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/* eslint-disable no-console */
import { execSync } from 'child_process';
// import the AWSLambda package explicitly,
// which is globally available in the Lambda runtime,
// as otherwise linking this repository with link-all.sh
// fails in the CDK app executed with ts-node
/* eslint-disable-next-line import/no-extraneous-dependencies,import/no-unresolved */
import * as AWSLambda from 'aws-lambda';
import { AwsSdkCall } from '../aws-custom-resource';

/**
Expand Down Expand Up @@ -204,4 +210,4 @@ export async function handler(event: AWSLambda.CloudFormationCustomResourceEvent
function decodeCall(call: string | undefined) {
if (!call) { return undefined; }
return JSON.parse(call);
}
}

0 comments on commit 282d242

Please sign in to comment.