- Newest
- Most votes
- Most comments
To resolve the issue you're facing with passing parameters from your main template to the include file, you need to modify your approach slightly. The AWS::Include transform doesn't automatically pass parameters from the main template to the included file. Instead, you'll need to pass the parameters explicitly.
Here's how you can modify your main template to pass the required parameters to the include file:
- In your main template, modify the AWS::Include transform section to pass the necessary parameters:
'Fn::Transform': Name: 'AWS::Include' Parameters: Location: !Ref UsgPlanReminderResS3Location SupportEmailAddress: !Ref SupportEmailAddress
- In your include file, you need to declare the parameters at the top, similar to how you would in a regular CloudFormation template:
Parameters: SupportEmailAddress: Type: String Resources: UsagePlanReminderTopic: Type: AWS::SNS::Topic UsagePlanReminderSubscription: Type: AWS::SNS::Subscription Properties: Protocol: email Endpoint: !Ref SupportEmailAddress TopicArn: !Ref UsagePlanReminderTopic
By making these changes, you're explicitly passing the SupportEmailAddress parameter to the include file, and then declaring it within the include file so it can be used.
Remember that the include file should be a valid CloudFormation template snippet on its own. It should contain only the sections you want to include (like Parameters and Resources), but it doesn't need the AWSTemplateFormatVersion or Description sections.
This approach should resolve the "Transform AWS::Include failed" error you're encountering and allow you to successfully split your resources into separate files while still being able to use parameters defined in the main template.
Sources
s3 bucket i m getting an error please help me to resolve this | AWS re:Post
Cloud formation Stacks creating and deploying fail S3 access error. | AWS re:Post
Hi there,
looking at the official documentation here [ 1 ], it is mentioned:
"You can use the AWS::Include transform anywhere within the CloudFormation template except in the template parameters section or the template version field".
At the moment, leveraging the AWS:Include type cannot be passed as a parameter even after making use of the changes shared above.
A workaround you can look into would be to make use of exports and outputs following the document here [ 2 ] [ 3 ]
References:
[ 2 ] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-exports.html
[ 3 ] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html
Hi
As per the template snippets that you provided, you encountered the error Transform AWS::Include failed with: The specified S3 object's content should be valid Yaml/JSON
because your AWS::Include boilerplate content includes short hand syntax of Ref intrinsic function.
As per the document here, AWS::Include transform currently does not support shorthand notations for YAML snippets. Your AWS::Include template snippet should look like as shown below:
UsagePlanReminderTopic:
Type: AWS::SNS::Topic
UsagePlanReminderSubscription:
Type: AWS::SNS::Subscription
Properties:
Protocol: email
Endpoint:
Ref: SupportEmailAddress
TopicArn:
Ref: UsagePlanReminderTopic
.....
Thanks
I tried with the auto suggested solution of passing parameters to include file. But still after passing all the required parameters, I am getting the same error. Do I need to pass "location" parameter too to include file? It is is no use there.