DEV Community

Cover image for AWS CloudFormation Git Sync

AWS CloudFormation Git Sync

Infrastructure as Code (IaC) has become the cornerstone of modern cloud management, empowering developers and DevOps teams to declaratively define and provision their cloud resources. CloudFormation is a leading IaC tool from Amazon Web Services (AWS), enabling you to define your infrastructure in templates and then automate its deployment and management. However, maintaining and updating these templates can be a time-consuming and error-prone task.

CloudFormation allows you to sync with your Git repo now, so there is no need for manual deployments, your infrastructure always reflects the latest version of your code.

Let’s speak about the benefits of Git Sync:

Continuous Deployment for Infrastructure: Automate the deployment of your infrastructure changes with every commit or pull request to your Git repository.

Improved Collaboration and Version Control: Leverage the power of Git for collaboration and version control.

Simplified Infrastructure Management: Automate infrastructure updates and reduce the burden of manual deployments. You don’t need GitHub Action to deploy to AWS.

Let’s start with Git Sync:

Create a Git Repository: Initialize a new Git repository to store your CloudFormation templates.

Configure CloudFormation Git Sync.

Create a CloudFormation Stack.

Deploy Infrastructure Changes: Commit your changes to your Git repository, and CloudFormation Git Sync will automatically deploy the updated infrastructure.

Let’s discuss the points 2 and 3.

Configuring Git SYNC in CloudFormation

  • Firstly, you need to create a connection. As you can see, there are several repository providers.

Image description

Once the connection is ready, you need 2 roles:

Image description

  • CF role to interact with AWS resources. You can add an admin policy just for testing purposes.

Image description

Once roles are ready, let’s create a stack:

Image description

As you can see, the Git sync status is enabled. My deployment-file.yaml looks this way:

Image description

So Git will constantly monitor changes in vpc.yaml file. Let’s add some SG to our template:

Image description

Now, CF after a few seconds after commit will create a changeset:

Image description

Finally, we will check a template in CF console, our template is updated and SG was successfully created:

Image description


CloudFormation Git Sync is a valuable tool for streamlining your infrastructure automation and deployment processes. By integrating your CloudFormation templates with your Git repository, you can automate infrastructure updates, improve collaboration, and simplify infrastructure management. Embrace the power of continuous deployment for your infrastructure and experience the benefits of enhanced agility and reduced risk.

Thank you for your time.


Top comments (0)