You must install and configure Terraform before you can use its simple template language to define, preview, and deploy the cloud infrastructure.

Procedure

  1. Download an appropriate software package for your operating system from the official website of Terraform.
  2. Decompress the package to /usr/local/bin.
    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:
  3. Run the terraform command to verify the path.
    If Terraform is installed, a command output similar to the following one is returned and available Terraform options are listed:
    username:~$ terraform
    Usage: terraform [-version] [-help] <command> [args]
  4. Create a RAM user and grant permissions to the user to ensure higher flexibility and security in permission management.
    1. Log on to the RAM console.
    2. Create a RAM user named Terraform and create an AccessKey pair for the user. For more information, see Create a RAM user and Create an AccessKey pair.
    3. Grant permissions to the RAM user. In this example, grant the AliyunECSFullAccess and AliyunVPCFullAccess permissions to the Terraform RAM user. For more information, see Grant permissions to a RAM user.
  5. Create an environment variable to store authentication information.
    export ALICLOUD_ACCESS_KEY="LTAIUrZCw3********"
    export ALICLOUD_SECRET_KEY="zfwwWAMWIAiooj14GQ2*************"
    export ALICLOUD_REGION="cn-beijing"