Giter Site home page Giter Site logo

diamong-dogs's Introduction

Deploying with the CLI and Terraform Cloud

Let's talk about the various options for deployment with Terraform Cloud. The new application you're using is not in source control at the moment, so we are going to deploy it using the CLI. We'll change that momentarily.

Demos

  • Creating a workspace on TFC with the CLI workflow
  • Configuring variable values and environment variables
  • Updating the Terraform configuration
  • Deploying the configuration with the CLI

Creating a workspace on TFC with the CLI workflow

Workspaces can be created using the UI, CLI, or API. To create a new workspace for the configuration, simply update the cloud block in the backend.tf file with your organization name. Save the file and run terraform init.

backend.tf

terraform {
  cloud {
    organization = <TFC Organization>

    workspaces {
      name = "diamond_dogs_dev"
    }
  }
}

While this will create your workspace, it will not configure any variables or environment variables. We can do that next.

Configuring variable values and environment variables

Terraform uses all Terraform and Environment variables for all plans and applies in this workspace. Workspaces using Terraform 0.10.0 or later can also load default values from any *.auto.tfvars files in the configuration. You may want to use the Terraform Cloud Provider or the variables API to add multiple variables at once.

Rename terraform.tfvars to terraform.auto.tfvars

Terraform requires credentials in order to communicate with your cloud provider's API. These API keys should never be stored directly in your terraform code. We will use Terraform Cloud environment variables to store our sensitive cloud credentials for AWS.

  • In the Variables tab of your workspace you can add environment variables for the AWS Credentials
  • Add a Environment variable named AWS_ACCESS_KEY_ID with your AWS Access Key
  • Add a second Environment variable named AWS_SECRET_ACCESS_KEY with your AWS Secret Key. Be sure to mark this variable as sensitive. Sensitive variables will not be displayed within the environment, and can only be overwritten - not read.

Deploying the configuration with the CLI

We can first run a terraform plan and then a terraform apply to generate our infrastructure. The output of the remote operations will be streamed to our local console.

terraform plan
terraform apply

diamong-dogs's People

Contributors

fvolo avatar

Watchers

 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.