-
Notifications
You must be signed in to change notification settings - Fork 4k
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 mono-CDK
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 #11342
- Loading branch information
Showing
3 changed files
with
22 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.js | ||
!cfn-include-rewrite-mappings.js | ||
*.d.ts | ||
!deps.js | ||
!gen.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,17 @@ | ||
/* | ||
* This script modifies the cfn-types-2-classes.json | ||
* file that is generated by the build of the cloudformation-include package. | ||
* It changes the values of the mappings to point to monocdk instead of the service-specific packages. | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const mappingFilePath = path.resolve(path.join(__dirname, 'lib', 'cloudformation-include', 'cfn-types-2-classes.json')); | ||
const cfnTypes2Classes = require(mappingFilePath); | ||
for (const cfnType of Object.keys(cfnTypes2Classes)) { | ||
const fqn = cfnTypes2Classes[cfnType]; | ||
// replace @aws-cdk/aws-<service> with monocdk/aws-<service> | ||
cfnTypes2Classes[cfnType] = fqn.replace('@aws-cdk', 'monocdk') | ||
} | ||
fs.writeFileSync(mappingFilePath, JSON.stringify(cfnTypes2Classes, undefined, 2) + '\n'); |
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