![]() I believe the best place for reusable code is a source code management system (SCM) like GitHub, BitBucket, GitLab, or Artifactory. A “source module” can be any network folder in your local area network (LAN) or Wide Area Network (WAN), so long as you, the user, has permission to read and write to the network shared folder. The folder can be your local drive or a source code management system (SCM) like GitHub, Artifactory, or Bitbucket. In this exercise, we will place our Terraform code into a shared location and, as per normal practice, refer to the shared location as the “source module.” We can create a “source module” in any folder. Terraform uses this during the module installation step terraform init to download the source code to a directory on a local disk so that it can be used by other Terraform commands. The source argument in a module block tells Terraform where to find the source code for the desired child module. The Terraform method for reusable code is to use Terraform module source. The Development Team and the QA team will use the same modules (dry code) to deploy different resources in the same region or regions using the same AWS account but different credentials or even launching from different accounts. After deploying resources for the development team, we will simulate a Quality Assurance (QA) team using the same modules (with different variables) to deploy a QA environment. We will then simulate a Development team using the reusable modules to deploy resources into a development environment. This exercise will create a “reusable module” for a VPC and another “reusable module” to create an EC2 instance as a website server. As we progress in writing Infrastructure as Code, we need to share code between teams like production, development, and Quality Assurance environments. We’ll start by understanding the use of reusable modules (dry code). Then finally, a deployment team pulls the different modules from a published location and deploys the modules to production. Have another person develop and publish the Web Template, and yet another developer create the Auto Scaling Group (ASG) and Load Balancer (ALB) modules. We can have a developer publish the VPC module and Security Groups. ![]() Each folder represents a module, and each module contributes to a complete deployment solution. In the chart above, we have an example of five different folders. Think of modules as putting the pieces together to make a complete solution. ![]() We put some Terraform code into that folder, and Terraform understands the content of a folder as a “MODULE.” The folders (Terraform modules) separate our Code into logical groups. This blog post will discuss in detail not just the how and the why of modular coding, but also I’m trying to express the logic behind some of the requirements as I understand them. NAT Gateways in a free tier account will incur costs if left in the running state for more than an hour, so I opt to use NAT instances instead of NAT gateways to save a bit of change.Īssumption: You are interested in the methods to create modular code. You can technically use your docker container or any generic website container.Īssumption: To keep costs down, we are using the latest NAT instance published by AWS. It is a simple Docker container that is a website developed for this demonstration. It doesn’t accommodate choosing more than two availability zones, it doesn’t accommodate choices like if you want to disable or enable IPV6 or set up a VPN gateway, etc.Ĭaveat: Docker Website is also very simple. Code for a Reusable module (Docker Website)Ĭaveat: The VPC reusable module is simple, creating private and public subnets with only two availability zones in any region.Code for a Reusable module (new VPC in any region by different teams).Creating an S3 bucket, Terraform remote state, and DynamoDB table.The code discussed in this example is posted in my GitHub repository What is discussed in this Post This exercise will show continuous improvement (CI) elements by creating reusable modules and continuous development (CD) by deploying the modules. After all, working together is where a team has advantages to form a better solution when we collaborate and share our knowledge and expertise. The reality is that we create technical solutions by working together as a team. Well, that is just not reality, now is it? Just me, myself, and I deploying architectural wonders into the cloud. The method used in previous examples works great if I am the only person to use the code. In the previous examples, I’ve shown more and more complicated deployments of AWS infrastructure and resources.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |