Skip to content

HeeZJee/terraform-aws

Repository files navigation

Provision infrastructure on AWS Cloud

Prerequisites

To follow this tutorial you will need:

  1. The Terraform CLI (0.14.9+) installed.
  2. The AWS CLI installed.
  3. An AWS account.
  4. Your AWS credentials. You can create a new Access Key on this page.

Set Environment Variables

  1. Copy all your environment variables from set_env.bash.example file set_env.bash file.

    cp -v set_env.bash.example set_env.bash
    
  2. Replace all AWS and Project Secrets based on your requirements in set_env.bash file.

  3. Assign exutable permission to your set_env.bash file.

    chmod +x ./set_env.bash
    
  4. Run the set_env.bash scripts to update the environment variables.

    ./set_env.bash
    
    source ./set_env.bash
    

Provision Infrastructure

  1. When you create a new configuration — or check out an existing configuration from version control — you need to initialize the directory with terraform init. Initializing a configuration directory downloads and installs the providers defined in the configuration, which in this case is the aws provider

    terraform init
    
  2. You can also make sure your configuration is syntactically valid and internally consistent by using

    terraform validate
    
  3. To preview the changes that Terraform plans to make to your infrastructure and store them in file.

    terraform plan -out main.tf.out
    
  4. Finally, To executes the actions proposed in a Terraform plan.

    terraform apply "main.tf.out"
    
  5. from the console output, you will recieve public ip of your EC2 instance, you can connect it via your provided ssh key or via AWS Management Console. E.g.

    Outputs:
    
    instance_ip = "1.1.1.1"
    
  6. To ensure that the planned operations are executed as expected, or to inspect the current state as Terraform sees it.

    terraform show
    

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages