How to Convert Existing Cloud Infrastructure To Terraform

In partnership with

Good day. It's Tuesday, Sep. 3, and in this issue, we're covering:

  • How to Convert Existing Cloud Infrastructure To Terraform

  • Slack Expands Build time-saving automations

  • Google Cloud: Introducing Compute Engine instant snapshots

  • Free O'Reilly eBook: Generative AI on AWS

  • Kubectl Get Context : Current Context, Switching & Listing

  • AWS DevOps Project: Advanced Automated CI/CD Pipeline with IaC, Microservices, Service Mesh, and Monitoring

You share. We listen. As always, send us feedback at [email protected]

Before moving ahead....a great news  

We partnered with 1440 to bring you this FREE offering.

Receive Honest News Today

Join over 4 million Americans who start their day with 1440 – your daily digest for unbiased, fact-centric news. From politics to sports, we cover it all by analyzing over 100 sources. Our concise, 5-minute read lands in your inbox each morning at no cost. Experience news without the noise; let 1440 help you make up your own mind. Sign up now and invite your friends and family to be part of the informed.

Use Case

How To Convert Existing Cloud Infrastructure To Terraform

DevOps and cloud engineers often find themselves in scenarios where implementing Infrastructure as Code (IaC) isn't about building from scratch but about retrofitting existing cloud infrastructures.

Terraformer helps a great deal in this.

What is Terraformer ?

Terraformer is a CLI tool that reverse-engineers existing infrastructure, generating Terraform files (`.tf`), JSON, and tfstate files for easy integration into IaC workflows.

It supports multiple cloud providers, such as AWS, Google Cloud Platform, Microsoft Azure, and others...

How it works ?

Terraformer fetches the current infrastructure state using provider APIs and converts it into Terraform code.

The process involves:

1. Authentication: Uses cloud provider credentials to access the provider's API.

2. Discovery: Identifies existing resources and their configurations.

3. Transformation: Converts the retrieved data into Terraform HCL code.

4. Output: Generates and exports the Terraform code in the chosen format.

Sample Terraformer Output:

$ tree generated/
generated/
└── gcp
    ├── compute_instance
    │   ├── compute_instance.tf
    │   ├── outputs.tf
    │   ├── provider.tf
    │   └── terraform.tfstate
    ├── storage_bucket
    │   ├── storage_bucket.tf
    │   ├── outputs.tf
    │   ├── provider.tf
    │   └── terraform.tfstate
    └── sql_database_instance
        ├── sql_database_instance.tf
        ├── outputs.tf
        ├── provider.tf
        └── terraform.tfstate

Since the installation is straight forward, let’s not go there.

Instead, let’s talk about the more crucial element that helps you achieve smoother operations - what you should consider after an export?

1. State File Management:

  • Secure state files in a remote backend (e.g., S3, GCS) with encryption enabled.

  • Enable state locking to prevent concurrent operations that could corrupt the state.

  • Regularly back up state files and manage state versions to recover from any issues.

2. Resource Naming Conventions:

  • Establish consistent naming patterns that include resource type, environment, and purpose.

  • Apply the same naming conventions across all environments to maintain uniformity.

3. Modularizing Terraform Code:

  • Break down your Terraform configurations into reusable modules for easier management.

  • Create separate modules for common resources like VPCs, IAM roles, or databases.

  • Use module versions to track and update changes consistently across environments.

4. Environment-Specific Configurations:

  • Separate environment-specific configurations into different workspaces or variable files.

  • Use terraform.tfvars files to define environment-specific variables.

5. Version Control:

  • Store Terraform files in a version-controlled repository (e.g., Git) for collaboration.

  • Use pull requests (PRs) for code reviews and to ensure changes are peer-reviewed.

  • Implement branch protection rules to prevent unreviewed code from being merged.

Remember, IaC implementation is not a ‘Set it and Forget it’—it's a constant work in progress.

p.s. I am on twitter (X) now - Your support would mean a lot  

Drop by to Say Hello and Smash that ‘Follow’ Button !!

Tool Of The Day

novops - Cross-platform secret & config manager for development and CI environments

Trends & Updates

Resources & Tutorials

Picture Of The Day

When Jeff Bezos posted a job opening at Amazon back in 1994.

Did someone forward this email to you? Sign up here

Interested in reaching smart techies?

Our newsletter puts your products and services in front of the right people - engineering leaders and senior engineers - who make important tech decisions and big purchases.