You must install and configure Terraform before you can use its simple template language to define, preview, and deploy cloud infrastructure.
- Download the appropriate software package for your operating system from the official website of Terraform.
- Decompress the package to /usr/local/bin.If you decompress the executable file to another directory, you must set an environment variable for the file by using one of the following methods:
- For Linux operating systems, use the method as described in How to permanently set $PATH on Linux/Unix?
- For Windows operating systems, use the method as described in Where can I set path to make.exe on Windows?
- For macOS operating systems, use the method as described in How to permanently set $PATH on Linux/Unix?
- Run the
terraformcommand to verify the path.If the following similar list of available Terraform options is displayed, the installation is complete:
username:~$ terraform Usage: terraform [-version] [-help] <command> [args]
- For higher flexibility and security in permission management, we recommend that you
create a RAM user and grant permissions to the user.
- Log on to the RAM console.
- Create a RAM user named Terraform and create an AccessKey pair for the user. For more information, see Create a RAM user.
- Grant permissions to the RAM user. In this example, the
AliyunVPCFullAccesspermissions are granted to the Terraform user. For more information, see Grant permissions to a RAM user.
- Create an environment variable to store authentication information.
export ALICLOUD_ACCESS_KEY="LTAIUrZCw3********" export ALICLOUD_SECRET_KEY="zfwwWAMWIAiooj14GQ2*************" export ALICLOUD_REGION="cn-beijing"