Skip to content

Latest commit

 

History

History
55 lines (43 loc) · 2.25 KB

File metadata and controls

55 lines (43 loc) · 2.25 KB

Terraform

Terraform is an open-source infrastructure as code software tool created by HashiCorp. It enables users to define and provision cloud infrastructure using a high-level configuration language known as Hashicorp Configuration Language (HCL).

The main advantage of using Terraform is that it allows you to define your infrastructure as code once and then deploy it in multiple environments, having always the same result.

We will provision a simple infrastructure that we can use to deploy the my-awesome-app example. This infrastructure will consist of a VPC, a public subnet, an internet gateway, a security group, and an EKS instance.

Requirements:

AWS

To provision the infrastructure in AWS, we will use the AWS Terraform provider. You can find the Terraform code in the aws directory.

Requirements:

Provision the infrastructure

  1. Select the cloud provider you want to use and follow the instructions in the respective directory. In this example, we will use AWS.
    cd aws
  2. Adjust the values in the _config.tf file to match your environment.
  3. Initialize the Terraform working directory and download the AWS provider plugin.
    terraform init
  4. Create an execution plan.
    terraform plan -out tfplan
  5. Apply the changes to the infrastructure.
     terraform apply tfplan

Once the infrastructure is provisioned, you can update your kubeconfig file to connect to the EKS cluster by running the following command:

aws eks --region us-east-1 update-kubeconfig --name learn-devops

Clean up

Once you are done with the infrastructure, you can destroy it by running the following command:

terraform destroy