This is most basic example. This will create following resources. Architecture overview is here. This example use Ansible for server provisioning.
- Create VPC
- Create Vswitch
- Create Security Group and set some rules
- Create an ECS instance in Vswitch
- Create EIP and bind it to ECS instance
- Provision httpd to ECS instance with Userdata function
Userdata code supports shell script and cloud-init. But both isn't suitable for complex provisioning. When you provision complex and many configuration, I reccomend using provisioning tools like Ansible, Chef, Puppet and so on.
First you need to chnage configuration to yours.
$ cp terraform.tfvars.sample terrafrom.tfvars
$ vim terraform.tfvars
=> Edit variables with your favorite editor.
Deploy to Alibaba Cloud
$ terraform apply
Apply complete! Resources: 7 added, 0 changed, 0 destroyed.
Outputs:
eip = xx.xx.xx.xx