Skip to content

Commit

Permalink
fix(cfn-include): AWS::CloudFormation resources fail in monocdk (#12758)
Browse files Browse the repository at this point in the history
When we did the changes to fix cloudformation-include in #11595,
we did not account for the fact that the `@aws-cdk/core` is not mapped to `uberpackage/core`,
but instead just to the `uberpackage` root namespace.

Special-case the `@aws-cdk/core` module in ubergen when transforming the `cfn-types-2-classes.json` file.

----

*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 authored Jan 31, 2021
1 parent 8434294 commit 5060782
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"Resources": {
"NoopHandle": {
"Type": "AWS::CloudFormation::WaitConditionHandle"
},
"Bucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
Expand Down
7 changes: 5 additions & 2 deletions tools/ubergen/bin/ubergen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,11 @@ async function copyOrTransformFiles(from: string, to: string, libraries: readonl
const cfnTypes2Classes: { [key: string]: string } = await fs.readJson(source);
for (const cfnType of Object.keys(cfnTypes2Classes)) {
const fqn = cfnTypes2Classes[cfnType];
// replace @aws-cdk/aws-<service> with <uber-package-name>/aws-<service>
cfnTypes2Classes[cfnType] = fqn.replace('@aws-cdk', uberPackageJson.name);
// replace @aws-cdk/aws-<service> with <uber-package-name>/aws-<service>,
// except for @aws-cdk/core, which maps just to the name of the uberpackage
cfnTypes2Classes[cfnType] = fqn.startsWith('@aws-cdk/core.')
? fqn.replace('@aws-cdk/core', uberPackageJson.name)
: fqn.replace('@aws-cdk', uberPackageJson.name);
}
await fs.writeJson(destination, cfnTypes2Classes, { spaces: 2 });
} else {
Expand Down

0 comments on commit 5060782

Please sign in to comment.