Let your CI/CD workflow flexibly handle any repository folder structure so you can instead focus on writing the actual code!

Image for post
Image for post
Figure 0. Sample Git Repository Structure. Colored folders represent specific cloud infrastructure objects that are targets for deployment in the CI/CD workflow

Background

I was working on setting the CI/CD workflow of a large repository involving different infrastructure components, encapsulated in folders, the other day. Many questions had to be asked: do we need to separate repositories for different “blocks” having different deployment workflows? how should we organize directories within the same repository? how do we handle deployment dependencies — e.g., when one component (folder) needs to be deployed exactly before or after the other.

In order to remove the need for all these questions, I implemented a CI/CD workflow that does the following…


Image for post
Image for post

Organize your Mappings Section into subsections of common purpose for smooth integration with multiple templates with a plus for better readability!

The mappings section of a cloudformation template allows specific values to be mapped into keys to be used at different parts of your template. This might not seem all too important but as soon as the template of your stack gets longer with more resources, and as your stack references other stack resources, then this becomes a deciding factor in your final template’s readability and adaptability to changes.

I will explain here my approach to utilizing the mappings section. This is by no means an “official best practices” guide, but this is simply how I would often utilize the mappings section to organize my template structure. I will be demonstrating this approach by explaining snippets in a sample template I prepared, together with the reasons and benefits of following the approach. You can check out the complete cloudformation template (00.format-and-style.yaml)

About

Julian Oliveros

・Software Engineer — AWS, NodeJS, Python, Angular, Docker

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store