Resolving Circular Dependency between multiple AWS CloudFormation templates
Hi, I am Wai. I am a software developer who is a big fan of AWS CloudFormation. In this article, I will show you how to resolve one of the issues I experienced using AWS CloudFormation service which is Circular Dependency.
First, let’s try to understand what the problem is.
Let’s imaging you have multiple CloudFormation templates, called core.yaml and resources.yaml. The core.yaml template will be importing the resources from resources.yaml template which is the core.yaml template is depending on the resources.yaml template. We will need to deploy the resources.yaml before the core.yaml.
The following is the dummy resources.yaml template.
Resources:
StorageBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: test-storage
//other resources declarion lie here
....
.... DBSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Database security group
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '3306'
ToPort: '3306'
SourceSecurityGroupId: !GetAtt WebServerSecurityGroup.GroupIdOutputs:
StorageBucket:
Description: "S3 storage bucket"
Value: !Ref StorageBucket
Export…