Terraform Install for Beginners

Terraform Install for Beginners

My new team is all about Terraform from HashiCorp. We often train customers on how to write Infrastructure as Code and the tool seems to do it well for most scenarios.

As I build out new service offerings in this area, I thought I'd learn a bit about this tool so I can speak intelligently about it. I spend a ton of time on the business side of tech and can sometimes go months before touching Terminal or Bash commands. So when I do, I'm usually searching for answers to very basic questions like what are the basic "vi commands" or "how to set a PATH in bash".

After spending 2 hours on Friday night trying to figure out how to set my PATH correctly and follow the supposed "5 minute" instructions from HashiCorp, I realized I was editing the wrong file. For Mac, you want to edit ~/.bash_profile and not ~/.profile.

For those of you dabbling in this area and hitting the same issue, here's a quick video to show you how to set your PATH and move Terraform to the correct directory so that it runs via Terminal.

Basic stuff my friends... but stuff I forget all the time since I don't sit in Bash each day.

Basically, change directories to where your Terraform zip file is located. For me it was in Downloads on my local user (stefana).

$ cd Downloads

Downloads$ unzip terraform_0.11.11_darwin_amd64.zip 

Archive:  terraform_0.11.11_darwin_amd64.zip

  inflating: terraform               

Now change directories back to your home directory and check the contents of the existing /bash_profile file using the cat command.

Downloads$ cd

$ cat ~/.bash_profile

export PATH=/usr/local/bin:$PATH

In the video, I already had edited that file so the export line was there. If you don't have it there, here's how to quickly edit the file using vi.

$ vi ~/.bash_profile

Use O to insert a line and type in the export line below:

export PATH=/usr/local/bin:$PATH

Hit ESC, then :wq to save the file.

Now type pwd to remember where you are in Bash :)

$ pwd

/Users/user1

Then type the move command to move the terraform file from the Downloads directory to the /usr/bin/ directory. NOTE: make sure you sub out "/Users/user1" with what returned from above. In the video, mine stated "/Users/stefana/".

$ mv /Users/user1/Downloads/terraform /usr/local/bin/terraform

Now confirm that Terraform will run from Bash by typing in terraform and hitting enter.

$ terraform

You should see this... if you do, you're good to go!

Usage: terraform [-version] [-help] <command> [args]



The available commands for execution are listed below.

The most common, useful commands are shown first, followed by

less common or more advanced commands. If you're just getting

started with Terraform, stick with the common commands. For the

other commands, please read the help and docs before usage.



Common commands:

    apply              Builds or changes infrastructure

    console            Interactive console for Terraform interpolations

    destroy            Destroy Terraform-managed infrastructure

    env                Workspace management

    fmt                Rewrites config files to canonical format

    get                Download and install modules for the configuration

    graph              Create a visual graph of Terraform resources

    import             Import existing infrastructure into Terraform

    init               Initialize a Terraform working directory

    output             Read an output from a state file

    plan               Generate and show an execution plan

    providers          Prints a tree of the providers used in the configuration

    push               Upload this Terraform module to Atlas to run

    refresh            Update local state file against real resources

    show               Inspect Terraform state or plan

    taint              Manually mark a resource for recreation

    untaint            Manually unmark a resource as tainted

    validate           Validates the Terraform files

    version            Prints the Terraform version

    workspace          Workspace management



All other commands:

    debug              Debug output management (experimental)

    force-unlock       Manually unlock the terraform state

    state              Advanced state management

 
  






要查看或添加评论,请登录

Stefana Muller的更多文章

  • The CALMS Model: Assessing Your Readiness for a DevOps Transformation

    The CALMS Model: Assessing Your Readiness for a DevOps Transformation

    If you’re considering beginning a DevOps transformation, we recommend starting by identifying where you are now and…

    3 条评论
  • 4 DevOps Myths Debunked

    4 DevOps Myths Debunked

    DevOps is a set of cultural values and organizational practices that improve business outcomes by increasing…

    1 条评论
  • A DevOps Transformation Overview: What, How, Who, and Why

    A DevOps Transformation Overview: What, How, Who, and Why

    When your organization needs to address a specific problem, change the status quo, follow new trends, add a premier…

  • Gaining Buy-In on DevOps

    Gaining Buy-In on DevOps

    Understanding what DevOps means and brings to the business is critical in order to gain buy-in at the beginning of the…

    4 条评论
  • Podcast Guest Tips

    Podcast Guest Tips

    Tips and tricks to prepare for your first podcast interview. Over the past 2 months, I've joined in as a guest and as a…

    2 条评论
  • Fully-Managed DevOps – Is It Possible?

    Fully-Managed DevOps – Is It Possible?

    If you’re in a development or operations role, you probably gawked at this title. The truth is, having some other…

  • 10 Tips for Your First DevOpsDays NYC

    10 Tips for Your First DevOpsDays NYC

    This year I have the privilege of being part of the organizing committee for DevOpsDays New York City. It's been an…

  • Demystifying DevOps

    Demystifying DevOps

    Blog originally posted on 2nd Watch blog. My second week at 2nd Watch, it happened.

    1 条评论
  • A Case for Enterprises to Leverage Managed Cloud Services

    A Case for Enterprises to Leverage Managed Cloud Services

    Cloud Adoption is almost mainstream. What are you doing to get on board? Originally posted on 2nd Watch Blog If you…

  • 5 Steps to Cloud Cost Optimization

    5 Steps to Cloud Cost Optimization

    Hurdles to Optimization are Organizational, Not Technical Originally published on 2nd Watch Blog. ?Edited by Charisma…

社区洞察

其他会员也浏览了