Why we should provide standard for IaC on our team
Watcharin(start)
Posted on December 25, 2023
😺 Today, let's delve into a common challenge faced by non-developers who take on roles that mimic those of actual developers, such as DevOps Engineers
, Cloud Engineers
, Automated QA
, and others. As we navigate through the intricate landscape of the modern tech world, we encounter numerous like application design patterns, frameworks, and architectural designs.
In this dynamic environment, the ability to craft applications and share them within your team or with others becomes a pivotal aspect. The cohesion achieved by adopting shared standards and frameworks ensures that your ideas, designs, and functionalities are comprehensible to everyone involved. This shared foundation not only facilitates mutual understanding but also provides a guiding framework and utility tools that enhance overall performance.
By adhering to a common working standard, you not only streamline communication within your team but also benefit from the efficiency and support offered by standardized frameworks. This collaborative approach not only fosters understanding but also contributes to a more efficient and high-performing work environment.
Understand several software design principle
📄 Understand about several design pattern and framework for programming languages.
🧑🏼💻 Software design principles are fundamental guidelines that software developers follow to achieve high-quality software design. The principles provide a framework for making design decisions that lead to more maintainable, scalable, and robust software.
Example are here:
- DRY (Don't Repeat Yourself): This principle emphasizes the importance of reducing repetition in code. Every piece of knowledge or logic should be unique and single-represented in a system. This reduces the risk of inconsistencies and makes code more maintainable. Read more here.
- KISS (Keep It Simple, Stupid): This principle suggests that systems work better if they are kept simple rather than made complex. Simplicity should be a key goal in design, and unnecessary complexity should be avoided. Read more here.
From the principle of designs, it provide us to Design patterns and Frameworks that we actually do on our application. It just a common standard for our team to collaborative in the same project that we work together.
The IaC programmings
📄 Definition of IaC, What is purpose to use programming to control infrastructure.
🔨 The Infrastructure as Code(also IaC) is a key concept in modern software deployment and operation, fundamentally transforming infrastructure managed in IT environment via readable documentation for developer and machine. We’re trying to reduce the manually setting up and configuring resources. We’re use code to automate the process, which can be more consistent and error-free than manual process.
Example tools of IaC.
- Terraform: An open-source tool that uses a declarative configuration language for building, changing, and versioning infrastructure safely and efficiently.
- Ansible: An open-source tool that uses YAML for defining infrastructure configurations, primarily for automation of application deployment and intra-service orchestration.
Relationship between IaC and several programming languages
📄 Said about same purpose and different on both
🤝 We must experience about programming and infrastructure before apply the IaC. The IaC can be implemented using standard programming language like Python, Javascript, Golang or specialized domain-specific language(DSLs). The DSLs are designed specifically for defining and managing infrastructure resources like Hashicorp’s Terraform and AWS Cloudformation.
📜 In the IaC, script or code are written to automatically set up and manage infrastructure. This code act as a blueprint for our resources. You can be executed to deploy, manage and destroy the infrastructure. We can integrates closely modern deployment practices as the same common programming like CI and CD.
How to adopt development practices to IaC
📄 Talk about current tools and a community experience to improve IaC writing.
⚒️ Adoption the software development principle in IaC is essential for maintaining the quality, efficiency, and reliability of our the source code to infrastructure automation. Here are several key programming principle and practices that can be effectively applied to IaC.
- Use version control: Just like code, our infrastructure configuration should be stored in a version control system like Git. This practices allow tracking changes, collaborate with team and maintaining a history of our infrastructure state.
- Write modularity: Write modular script, just as with traditional programming, break down your code into smaller, reusable modules can make them more manageable, and understandable.
- DRY principle(Don’t Repeat Yourself): Avoid duplication in your code. You can use templates, modules, or function to reuse code as most as possible, which makes it easier to manage and reduces the risk of error.
- Code review: We must implement code review process to IaC, just as you would for code. This principle encourages collaboration, improve code quality, and help in sharing knowledge among team member.
- Use automate testing: Apply automate testing into your IaC. You can implement tools and frameworks to IaC script to ensure they perform as expected before deployment.
- Documentation: Write the document of IaC script and configurations. Good documentation helps in understanding the purpose and function of your infrastructure, especially in complex environment.
- Keep it idempotency: Ensure your script is idempotent, meaning running your script multiple times in the same environment result in the same state, without unintended side effects. This is crucial for reliability and predictability in automated environments.
- Apply security practices: Most important to embedded the security practice on your IaC development process. This includes using secure access credentials, encrypting sensitive data, and should follow the principle of least privilege.
- Often refactoring: Regularly refactor your IaC code for improvements and optimizations, similar to how you would refactor application code for better performance, readability, and maintainability.
By adopting these practices, team can ensure that their IaC approach is as robust, efficient, and maintainable as their software development process.
Example guideline to contribute IaC
📄 Show my standard to writing Terraform and Ansible
You can apply the previous practices into your IaC code and see what happen in your work. I can sharing some guideline to initial your IaC project here.
For the Hashicorp’s Terraform:
- You might to create a new repository for versioning your script. You can create a folder structure in different purpose like
-
components
to store your reusable and maintainable for script in consistent modules. -
deployments
to store your variable files that contain each environment configurations. -
modules
in optional to download and freeze external Terraform’s module for your environments.
-
- You can integrates automation plugins for verify syntax, credentials leak, and missing fields. Use third party tools like Terrasec, TFlint, and other.
- For documentation, you can use
terraform-docs
for automate provision code spec when you write a description in your scripts. - You can integrates your process with CI/CD pipeline for Jenkins, Github-action, and other platforms.
- For integration testing your script, you can use
Grantwork’s Terratest
to verify your actually provisioning resources.
You can see my example terraform code for initialize from Github repo.
Conclusions
📄 Recap all topics and drop some question to audiences.
🧳 In our journey towards modernizing infrastructure management, we have embraced to use modern technology for provisioning, managing, and maintaining infrastructure. This is achieved through programming languages and domain-specific languages(DSLs). By writing code and script, we’re revolutionizing the way we handle infrastructure.
The purpose of this is to establish standard practices for our team in crafting code that enhances collaboration, readability, and maintainability. This adoption will not only streamline our development processes but also significantly improve the quality of code.
Posted on December 25, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.