How to Include/Reference Multiple Resource files in CloudFormation?

Viewed 1224

I am new to cloud formation templates. I am trying to organize the templates based on AWS services so that I can easily manage it. For example, iam-roles in one file, dynamodb tables on another, s3, lambda resources in individual files. When I try to make a master file from these partials I am able to include only one partial in the resource section on Fn::Transform. I need two suggestions, am I going in the right direction? and how to include all the partials into my main.yml? enter image description here

Resources:
  "Fn::Transform":
    Name: 'AWS::Include'
    Parameters:
      Location: 
        Fn::Sub: "s3://s3url/iam-roles.yml"
  "Fn::Transform":
    Name: 'AWS::Include'
    Parameters:
      Location: 
        Fn::Sub: "s3://s3url/ddbtables.yml"

The above code definitely throws an error. How to merge these partials?

1 Answers

From the images you have shared in the question, the templates you have created have to be included using AWS::CloudFormation::Stack.

Fn::Transform is a macro which is used to do preprocessing of a cloudformation templates. For example, we can do search and replace of some strings in the cloudformation templates using Macros.

Related