forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cfn-include): cfn-include fails in monocdk (aws#11595)
The cloudformation-include module generates a big JSON file at build time that contains the mapping from the CloudFormation resource type to the fully-qualified class name of the corresponding L1 (something like "AWS::S3::Bucket": "@aws-cdk/aws-s3.CfnBucket"). The problem is that mono-CDK re-packages all of the per-service modules into one big module, and requiring the module from the mapping fails for it. Solve the issue by adding an additional build step in mono-CDK that re-writes that file with the mapping values changed (to something like "monocdk/aws-s3.CfnBucket"). Fixes aws#11342 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
22 changed files
with
173 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function invokeJest() { | ||
# Install these dependencies that the tests (written in Jest) need. | ||
# Only if we're not running from the repo, because if we are the | ||
# dependencies have already been installed by the containing 'aws-cdk' package's | ||
# package.json. | ||
if ! npx --no-install jest --version; then | ||
echo 'Looks like we need to install jest first. Hold on.' >& 2 | ||
npm install --prefix . jest jest-junit aws-sdk | ||
fi | ||
|
||
# This must --runInBand because parallelism is arranged for inside the tests | ||
# themselves and they must run in the same process in order to coordinate to | ||
# make sure no 2 tests use the same region at the same time. | ||
npx jest --runInBand --verbose "$@" | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/aws-cdk/test/integ/uberpackage/cfn-include-app/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!cfn-include-app.js |
4 changes: 4 additions & 0 deletions
4
packages/aws-cdk/test/integ/uberpackage/cfn-include-app/cdk.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"app": "node cfn-include-app.js", | ||
"versionReporting": false | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/aws-cdk/test/integ/uberpackage/cfn-include-app/cfn-include-app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const path = require('path'); | ||
|
||
const uberPackage = process.env.UBERPACKAGE; | ||
if (!uberPackage) { | ||
throw new Error('The UBERPACKAGE environment variable is required for running this app!'); | ||
} | ||
|
||
const cfn_inc = require(`${uberPackage}/cloudformation-include`); | ||
const core = require(`${uberPackage}`); | ||
|
||
const app = new core.App(); | ||
const stack = new core.Stack(app, 'Stack'); | ||
const cfnInclude = new cfn_inc.CfnInclude(stack, 'Template', { | ||
templateFile: path.join(__dirname, 'example-template.json'), | ||
}); | ||
const cfnBucket = cfnInclude.getResource('Bucket'); | ||
if (cfnBucket.bucketName !== 'my-example-bucket') { | ||
throw new Error(`Expected bucketName to be 'my-example-bucket', got: '${cfnBucket.bucketName}'`); | ||
} | ||
|
||
app.synth(); |
10 changes: 10 additions & 0 deletions
10
packages/aws-cdk/test/integ/uberpackage/cfn-include-app/example-template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Resources": { | ||
"Bucket": { | ||
"Type": "AWS::S3::Bucket", | ||
"Properties": { | ||
"BucketName": "my-example-bucket" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
moduleFileExtensions: [ | ||
"js", | ||
], | ||
testMatch: [ | ||
"**/*.integtest.js", | ||
], | ||
testEnvironment: "node", | ||
bail: 1, | ||
verbose: true, | ||
reporters: [ | ||
"default", | ||
[ "jest-junit", { suiteName: "jest tests", outputDirectory: "coverage" } ] | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
scriptdir=$(cd $(dirname $0) && pwd) | ||
|
||
echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' | ||
echo 'UberCDK Integration Tests' | ||
echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' | ||
|
||
cd $scriptdir | ||
|
||
source ../common/jest-test.bash | ||
invokeJest "$@" |
12 changes: 12 additions & 0 deletions
12
packages/aws-cdk/test/integ/uberpackage/uberpackage.integtest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { withMonolithicCfnIncludeCdkApp } from '../helpers/cdk'; | ||
import { integTest } from '../helpers/test-helpers'; | ||
|
||
jest.setTimeout(600_000); | ||
|
||
describe('uberpackage', () => { | ||
integTest('works with cloudformation-include', withMonolithicCfnIncludeCdkApp(async (fixture) => { | ||
fixture.log('Starting test of cfn-include with monolithic CDK'); | ||
|
||
await fixture.cdkSynth(); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters