Before you can use the simple template language of Terraform to define, preview, and deploy cloud infrastructure, you must install and configure Terraform.
- Download a software package suitable for your operating system from the official Terraform website.
- Decompress the package to the /usr/local/bin directory. If you want to extract the executable file into another directory when you decompress the package, you must set an environment variable for the file by using one of the following methods:
- For Linux operating systems, use the method described in How to permanently set $PATH on Linux/Unix?
- For Windows operating systems, use the method described in Where can I set path to make.exe on Windows?
- For macOS operating systems, use the method described in How to permanently set $PATH on Linux/Unix?
- Run the
terraformcommand to verify the path configurations.If Terraform is installed, a command output similar to the following one is returned and contains available Terraform options:
username:~$ terraform Usage: terraform [-version] [-help] <command> [args]
- Create a Resource Access Management (RAM) user and grant permissions to the user to
ensure high flexibility and security in permission management.
- 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 and Obtain an AccessKey pair.
- Grant permissions to the RAM user. In this example, grant the AliyunECSFullAccess and
AliyunVPCFullAccesspermissions to the
TerraformRAM 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"