GithubHelp home page GithubHelp logo

terraform-aws's Introduction

terraform-aws

Terraform AWS provisioning examples for beginners

Hit the Star! ⭐

If you are planning to use this Terraform repo for learning, please hit the star. Thanks!

Terraform Init With s3 Backend

terraform init \
    -backend-config="key=dev/vpc.tfstate" \
    -backend-config="bucket=dcube-terraform-state" \
    -backend-config="region=us-west-2" \
    -backend-config="dynamodb_table=terraform-state-lock" \
    -var-file=../../../vars/dev/vpc.tfvars

VPC Provisioning

cd into the environments/dev/vpc directory and run the following commands:

  1. Init Terraform in the directory environments/dev/vpc
terraform init
  1. To preview the changes in code
terraform plan -var-file=../../../vars/dev/vpc.tfvars
  1. To apply the changes
terraform apply -var-file=../../../vars/dev/vpc.tfvars
  1. To destroy the resources created using the code
terraform destroy -var-file=../../../vars/dev/vpc.tfvars


#### RDS Provisioning

cd into the `environments/dev/rds` directory and run the following commands:

1. Init Terraform in the directory `environments/dev/rds`

terraform init

2. To preview the changes in code

terraform plan -var-file=../../../vars/dev/rds.tfvars

3. To apply the changes

terraform apply -var-file=../../../vars/dev/rds.tfvars

4. To destroy the resources created using the code

terraform destroy -var-file=../../../vars/dev/rds.tfvars


### ALB and ASG Provisioning

cd into the `environments/dev/alb-asg` directory and run the following commands:

1. Init Terraform in the directory `environments/dev/alb-asg`

terraform init

2. To preview the changes in code

terraform plan -var-file=../../../vars/dev/alb-asg.tfvars

3. To apply the changes

terraform apply -var-file=../../../vars/dev/alb-asg.tfvars

4. To destroy the resources created using the code

terraform destroy -var-file=../../../vars/dev/alb-asg.tfvars


## EC2 Instance Provisioning

1. Navigate to the `environment/dev` folder:

```bash
cd environment/dev
  1. Open the ec2.tfvars file and modify it with your desired details. This file contains variables used in the Terraform configuration.

Deployment

  1. Initialize Terraform in the working directory:
terraform init
  1. Create an execution plan:
terraform plan -var-file=../../../vars/dev/ec2.tfvars
  1. Apply the changes to create the EC2 instance:
terraform apply -var-file=../../../vars/dev/ec2.tfvars
  1. To destroy the EC2 instance and associated resources:
terraform destroy -var-file=../../../vars/dev/ec2.tfvars

Note: Always review the execution plan (terraform plan) before applying changes to avoid unintended modifications.

AWS Organization Tag Policy Creation.

  1. Navigate to the environment/dev folder:
cd environment/tag-policy
  1. Open the tag-policy.tfvars file and modify it with your desired details. This file contains variables used in the Terraform configuration.

Deployment

  1. Initialize Terraform in the working directory:
terraform init
  1. Create an execution plan:
terraform plan -var-file=../../../vars/dev/tag-policy.tfvars
  1. Apply the changes to create the Tag Policy:
terraform apply -var-file=../../../vars/dev/tag-policy.tfvars
  1. To destroy the Tag Policy:
terraform destroy -var-file=../../../vars/dev/tag-policy.tfvars

Note: Always review the execution plan (terraform plan) before applying changes to avoid unintended modifications.

Terraform Command Reference

Update all outputs:

terraform refresh

Show all outputs:

terraform show

terraform-aws's People

Contributors

aswin-vijayan avatar techiescamp avatar arunlalp avatar scriptcamp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.