Skip to content

Commit

Permalink
fix(cfn-include): correctly handle the 'AWS::CloudFormation::CustomRe…
Browse files Browse the repository at this point in the history
…source' resource type (#10415)

The resource type 'AWS::CloudFormation::CustomResource' corresponds to the class CfnCustomResource.
However, that class is automatically generated, and quite useless; it only supports one property, ServiceToken.
It does not support passing in an arbitrary collection of properties,
like custom resources in CloudFormation do.
As a result, cfn-include would "lose" all properties of resources of type 'AWS::CloudFormation::CustomResource'
other than ServiceToken.
Fix the problem by handling this resource type with the CfnResource class,
that does support an arbitrary collection of properties.

----

*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 Sep 21, 2020
1 parent e9ffa67 commit 1a5a024
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/@aws-cdk/cloudformation-include/lib/cfn-include.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,11 @@ export class CfnInclude extends core.CfnElement {
l1Instance = this.createNestedStack(logicalId, cfnParser);
} else {
const l1ClassFqn = cfn_type_to_l1_mapping.lookup(resourceAttributes.Type);
if (l1ClassFqn) {
// The AWS::CloudFormation::CustomResource type corresponds to the CfnCustomResource class.
// Unfortunately, it's quite useless; it only has a single property, ServiceToken.
// For that reason, even the CustomResource class from @core doesn't use it!
// So, special-case the handling of this one resource type
if (l1ClassFqn && resourceAttributes.Type !== 'AWS::CloudFormation::CustomResource') {
const options: cfn_parse.FromCloudFormationOptions = {
parser: cfnParser,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"DependsOn": [ "CustomResource" ]
},
"CustomResource": {
"Type": "AWS::MyService::AnotherCustom",
"Type": "AWS::CloudFormation::CustomResource",
"Properties": {
"CustomProp": "CustomValue",
"ServiceToken": "CustomValue",
"CustomFuncProp": {
"Ref": "AWS::NoValue"
}
Expand Down

0 comments on commit 1a5a024

Please sign in to comment.