Skip to content

Commit 1a5a024

Browse files
authored
fix(cfn-include): correctly handle the 'AWS::CloudFormation::CustomResource' 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*
1 parent e9ffa67 commit 1a5a024

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/@aws-cdk/cloudformation-include/lib/cfn-include.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,11 @@ export class CfnInclude extends core.CfnElement {
634634
l1Instance = this.createNestedStack(logicalId, cfnParser);
635635
} else {
636636
const l1ClassFqn = cfn_type_to_l1_mapping.lookup(resourceAttributes.Type);
637-
if (l1ClassFqn) {
637+
// The AWS::CloudFormation::CustomResource type corresponds to the CfnCustomResource class.
638+
// Unfortunately, it's quite useless; it only has a single property, ServiceToken.
639+
// For that reason, even the CustomResource class from @core doesn't use it!
640+
// So, special-case the handling of this one resource type
641+
if (l1ClassFqn && resourceAttributes.Type !== 'AWS::CloudFormation::CustomResource') {
638642
const options: cfn_parse.FromCloudFormationOptions = {
639643
parser: cfnParser,
640644
};

packages/@aws-cdk/cloudformation-include/test/test-templates/custom-resource-with-attributes.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"DependsOn": [ "CustomResource" ]
2828
},
2929
"CustomResource": {
30-
"Type": "AWS::MyService::AnotherCustom",
30+
"Type": "AWS::CloudFormation::CustomResource",
3131
"Properties": {
32-
"CustomProp": "CustomValue",
32+
"ServiceToken": "CustomValue",
3333
"CustomFuncProp": {
3434
"Ref": "AWS::NoValue"
3535
}

0 commit comments

Comments
 (0)