Terraform on Alibaba Cloud

So let’s get a basic instance stood up on Alibaba Cloud. It’s surprisingly easy and parallels how its done on AWS.

I’ve published my source code on GitHub so you can get started quickly just by pulling the code. You may want to check out my other post on getting started with Alibaba Cloud.

Provider

The provider specifies the configuration you’ll need to talk to Alibaba Cloud. Just like AWS this is using an Access Key but instead of IAM Access Key we’re using a RAM (Resource Access Management) Access Key.

Setup a Virtual Network

This is exactly the same as VPC in AWS.

Setup a Subnet (Virtual Switch)

This is exactly the same as a subnet in AWS. Complete with specifying the availability zone.

Setup a Security Group

This is again exactly the same as in AWS.

Reference an Instance Type

This is a little different in that we do not have SKUs in the same way we do in AWS. We specify Core and memory size. It’s a bit strange coming from AWS / Azure but its probably more familiar for those coming from traditional hypervisors.

Create an instance

The instance needs the bare miniumum values:

  1. AMI (image): the image_id
  2. Instance Type: the sku that we looked up using 2 cores and 4gb ram stored as a variable called “2c4g”
  3. Security group: used to place the instance inside
  4. Subnet (Virtual Switch): used to place the instance inside

Apply

Using terraform we can apply the plan and we are off to the races (assuming we’ve provided the access key to authenticate appropriately).

Now we log into the console and we can see our new instance!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s