- AWS CloudFormation,(IaC) lets you provision, and manage AWS and third-party resources, now offers Git sync support.
- This feature automatically triggers deployments upon updates to a tracked Git repository. The integration, compatible with GitHub, GitHub Enterprise, GitLab, and Bitbucket.
- CloudFormation development cycles by seamlessly integrating with Git workflows, reducing time lost to context switching.
Key Highlights:
Git Sync Integration: AWS CloudFormation now supports Git sync, triggering automatic deployments on Git repository updates.
Compatibility: GitHub, GitHub Enterprise, GitLab, and Bitbucket are directly integrated with AWS CloudFormation.
Development Experience: Explore a modern development experience utilizing GitHub's native tools and CloudFormation's Git sync integration.
Cloud Development Environment: Create a cloud development environment using GitHub CodeSpaces.
Integration with GitHub Actions: Integrate direct feedback into Pull Requests using GitHub Actions and the CloudFormation Linter.
Requirements:
AWS Account: Ensure you have an AWS account for deploying S3 Bucket.
GitHub Account: Access to GitHub Codespaces and Actions is necessary.
GIT Setup
Step 1: Creating an empty Git Repository
Step 2: Clone repository in your workspace and you can install the linter.
Next, you’ll create your template in the base directory called s3.yaml
Below template will create s3 bucket.
You can verify the template gives no errors by running cfn-lint in the terminal and verifying it returns no errors.
Please install package if cf-lint is not installed
pip3 install cfn-lint
Step 3: Need to add the deployment file
Git sync supports a deployment file to provide flexibility for managing CloudFormation stacks from within a Git repository.
This config file manages the location of the template file, and any parameters or tags you may be interested in using.
You’ll be creating a new file called deployment-file.yaml in your repository. Since this stack doesn’t have parameters or tags, it’ll be relatively simple:
template-file-path: ./s3.yaml
Your code working directory look look this
AWS Setup
First, create the role that will deploy our CloudFormation template. Be sure to note the name you select for this as you’ll be using it to manage your stack later. This example uses s3-deployment-iam-role.
Creat stack.
Here, you can see the new option to select Sync from Git template source, which you can configure on the next screen. Since you already created your stack deployment file, you can select I am providing my own file in my repository.
Select GitHub, your connection, the repository, and branch, the deployment file location.
Finally, you will select New IAM Role to create a service managed role
Finally, you can see the status of your sync in the new “Git sync” tab, including the configuration you provided earlier as well as the status of your sync, your previous deployments, and the option to retry or disconnect the sync if needed.
FINAL RESULT:
I updated the GitHub repository by changing the bucket name from 'cf-s3-git-bucket-v1' to 'cf-s3-git-bucket-v2'."
"After updating the GitHub repository, the modified bucket name 'cf-s3-git-bucket-v2' will automatically trigger the deployment of your stack. This enhancement reflects a resilient and scalable CI/CD system designed for efficient management of your infrastructure as code."
Thanks for reading. Happy learning
Top comments (0)