Terraform is a popular IaC tool. You can create VMs on public cloud with one command.
AWS & Aliyun templates are used as example providers. You can modify terraform.tf
file to use other cloud providers.
- spec/aws.tf : AWS 4 node CentOS7 environment
- spec/aliyun.tf : Aliyun 4 node CentOS7 environment
brew install terraform # install via homebrew
terraform init # install terraform provider: aliyun , aws, only required for the first time
terraform apply # plan and apply: create VMs, etc...
Print public IP Address:
terraform output | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
You have to set up aws config & credential to use AWS provider.
# ~/.aws
# ~/.aws/config
[default]
region = cn-northwest-1
# ~/.aws/credentials
[default]
aws_access_key_id = <YOUR_AWS_ACCESS_KEY>
aws_secret_access_key = <AWS_ACCESS_SECRET>
# ~/.aws/pigsty-key
# ~/.aws/pigsty-key.pub
Aliyun CentOS 7 have a problem with nscd
package, remove them to avoid glibc conflict.