使用之前首先必须将 Terraform 安装在你的机器上。Terraform 是以二进制安装包发布的,它可以支持所有的平台和架构。在本章节我们将不会涉及如何通过源代码编译 Terraform,但是对于那些需要通过源代码编译来构建可信任的二进制的用户,我们在指南的其他章节会有阐述。

  • 安装 Terraform

Terraform 安装包是zip格式的压缩文件,安装之前需首先根据系统类型下载合适的安装包。

Terraform 安装包下载完成后进行解压。Terraform 是一个名称为 terraform 的可执行的二进制文件,包中的其他任何文件都可以删除也不影响 Terraform 正常工作。

最后,确保 terraform 二进制文件路径添加到 PATH 环境变量中。请参见本指南中关于在Linux、Mac、Windows上如何设置 PATH。

  • 验证安装

Terraform 安装完成之后,打开终端检查 terraform 是否可用,执行 terraform 命令可以看到如下类似的帮助提示:

$ terraform
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 infrastructureconsole            Interactive console for Terraform interpolations
# ...

如果看到 terrform 无法找到的错误信息,那么就是 PATH 环境变量没有设置正确。请检查确保 PATH 变量包含 Terrform 的安装路径。

  • 获取帮助

Terraform CLI 内置了在线帮助,所有命令都可以使用 --help 参数来获得帮助信息,例如:

$ terraform -help
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 are 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 infrastructureconsole            Interactive console for Terraform interpolationsdestroy            Destroy Terraform-managed infrastructureenv                Workspace managementfmt                Rewrites config files to canonical formatget                Download and install modules for the configurationgraph              Create a visual graph of Terraform resourcesimport             Import existing infrastructure into Terraforminit               Initialize a Terraform working directoryoutput             Read an output from a state fileplan               Generate and show an execution planproviders          Prints a tree of the providers used in the configurationrefresh            Update local state file against real resourcesshow               Inspect Terraform state or plantaint              Manually mark a resource for recreationuntaint            Manually unmark a resource as taintedvalidate           Validates the Terraform filesversion            Prints the Terraform versionworkspace          Workspace managementAll other commands:0.12upgrade        Rewrites pre-0.12 module source code for v0.12debug              Debug output management (experimental)force-unlock       Manually unlock the terraform statepush               Obsolete command for Terraform Enterprise legacy (v1)state              Advanced state management

任意这些子命令都可以加上 --help 参数获取更多的帮助信息,例如:

$ terraform --help planUsage: terraform plan [options] [DIR]Generates an execution plan for Terraform.This execution plan can be reviewed prior to running apply to get asense for what Terraform will do. Optionally, the plan can be saved toa Terraform plan file, and apply can take this plan file to executethis plan exactly.Options:-destroy            If set, a plan will be generated to destroy all resourcesmanaged by the given configuration and state.-detailed-exitcode  Return detailed exit codes when the command exits. Thiswill change the meaning of exit codes to:0 - Succeeded, diff is empty (no changes)1 - Errored2 - Succeeded, there is a diff-input=true         Ask for input for variables if not directly set.-lock=true          Lock the state file when locking is supported.-lock-timeout=0s    Duration to retry a state lock.-no-color           If specified, output will not contain any color.-out=path           Write a plan file to the given path. This can be used asinput to the "apply" command.-parallelism=n      Limit the number of concurrent operations. Defaults to 10.-refresh=true       Update state prior to checking for differences.-state=statefile    Path to a Terraform state file to use to lookup Terraform-managed resources. By default it willuse the state "terraform.tfstate" if it exists.-target=resource    Resource to target. Operation will be limited to thisresource and its dependencies. This flag can be usedmultiple times.-var "foo=bar"      Set a variable in the Terraform configuration. Thisflag can be set multiple times.-var-file=foo       Set variables in the Terraform configuration froma file. If "terraform.tfvars" or any ".auto.tfvars"files are present, they will be automatically loaded.

Terraform指南:安装相关推荐

  1. Arch Linux 指南——安装基本系统

    目录 Arch Linux 指南--安装基本系统 安装前准备 环境检查 分区 安装 配置基础系统 完成安装 Arch Linux 指南--安装基本系统 本文是自己安装 Arch Linux 的过程,记 ...

  2. Terraform的安装

    1.下载地址为: https://www.terraform.io/downloads.html 2. 上传到linux服务器上,解压. unzip terraform_1.0.1_linux_amd ...

  3. terraform_Kubernetes初学者的Terraform指南

    terraform 构建基础结构时,我将其作为代码来完成. 朝着基础结构即代码的方向发展意味着无论是通过配置管理文件还是功能完善的GitOps ,每个更改都是可见的. Terraform是用于以代码形 ...

  4. 指南--安装 NVU HTML 编辑器

    At the moment NVU is not in universe. If you want to use NVU you need to install it manually. 目前NVU并 ...

  5. 指南--安装带GTK前端的 F-Prot(杀毒)

    Q: Is viruses, trojans and malware a threat to a linux system as in Windows? 问:在Linux系统中象Windows中一样有 ...

  6. Ganglia 权威指南-安装Ganglia过程

    转自于:http://blog.csdn.net/xxd851116/article/details/21527055 http://www.dataguru.cn/article-3816-1.ht ...

  7. Kali使用指南————安装中文输入法

    Kali安装中文输入法 作为一个中国人,国语是我们最熟悉的,也是最容易.最常用的,但是我们在Kali中却并没有默认的中文输入法,我们在使用Kali进行一些搜索时会变得非常非常麻烦,当然,上有政策,下有 ...

  8. ThinkPad E520下CentOS 6.2配置指南 --安装无线网卡RTL8188CE驱动、ATI6630显卡驱动、配置更新源、挂载NTFS...

    安装环境: 1.联想Thinkad E520笔记本 2.网卡RTL8188CE 3.显卡ATI6630 4.系统CentOS 6.2 5.VirtualBox 4.10 *************** ...

  9. 华为虚拟机服务器怎么使用教程,HUAWEI USG6000V V500R001C20 安装部署指南-安装与部署(VMWare)...

    组网需求 USG6000V的接口GigabitEthernet1/0/0和GigabitEthernet1/0/1连接到不同VLAN的端口组中,多个端口组属于同一个vSwitch共用一个物理接口来接入 ...

最新文章

  1. 深度学习中的3个秘密:集成、知识蒸馏和蒸馏
  2. Elasticsearch设置最大返回条数
  3. javase-NIO
  4. java 静态类的实现_[Java教程]Javascript 静态类的实现
  5. ArcGIS Engine代码共享-可以直接移植到你的工程中
  6. 获取时间,并将时间的空格和特殊字符去掉,作为一个变量来使用
  7. 十七条黄金定律!(心态是命运的控制塔)
  8. 【2019 NLP汇总】论文、博客、教程、工程进展全梳理(长文预警)
  9. 基于vitamio的网络电视直播源代码
  10. Hyper-V 2016 系列教程44 System Center 2016 Data Protection Manager 介绍和工作原理
  11. c#一个项目同时兼容浩辰cad和AutoCad
  12. Maya 基础教程 、 基础操作讲解
  13. 坐火车硬座20小时是怎样的体验?
  14. 详解ARM的AMBA设备中的DMA设备(Linux驱动之DMA)
  15. 房卡麻将分析系列之断线重连
  16. 对计算机专业最难的,计算机专业: 最好的7所大学! 也是全中国“最难考”的大学!...
  17. 与、或、非、与非、或非、异或、同或的区别
  18. python中的while语句
  19. 仿“真心祝福你”微信小程序源码
  20. acrh17华硕固件_真香选择—华硕rt-acrh17,不止稳定……

热门文章

  1. 算法设计与分析——第五章回溯法 批处理作业调度 + 最大团问题+图的m着色问题
  2. 求和函数 sum详解
  3. win7防火墙入站规则 出站规则 什么意思
  4. 纯CSS3实现旋转风车
  5. 滁州市化工厂人员定位系统,新导智能
  6. 基于Arduino IDE开发的LD3320语音识别模块
  7. 杰理-BLE连接后打开经典蓝牙
  8. Win10文件夹中图片不显示预览图解决方法
  9. 强大的头像制作神器_支持外卖CPS等优惠劵小程序源码
  10. 计算机鼠标不动了,计算机鼠标不动了怎么解决?