Launch an Alibaba Cloud ECS with Docker using Terraform

Posted on 31 August 2018 by Alberto Roura.
alibaba cloudaliyundevopsecsterraform

This example will show you how to launch an Alibaba Cloud (阿里云) ECS Instance using Ubuntu and packed with Docker and Docker Compose. Very simple but can be used as good start for other project.

For this, you just need to create a folder with this 2 files in it:

provider "alicloud" {}

data "template_file" "user_data" {
  template = "${file("")}"

data "alicloud_images" "default" {
  name_regex = "^ubuntu_16.*_64"

data "alicloud_instance_types" "default" {
  instance_type_family = "ecs.xn4"
  cpu_core_count       = 1
  memory_size          = 1

data "alicloud_vpcs" "default" {
  is_default = true

data "alicloud_vswitches" "default" {
  is_default = true

data "alicloud_security_groups" "default" {
  vpc_id = "${}"

resource "alicloud_instance" "ecs" {
  instance_name = "ubuntu-docker"
  image_id      = "${data.alicloud_images.default.images.0.image_id}"
  instance_type = "${}"

  vswitch_id      = "${}"
  security_groups = [
  internet_max_bandwidth_out = 100

  password = "Test1234!"

  user_data = "${data.template_file.user_data.template}"

#!/usr/bin/env bash

apt-get update && apt-get install -y apt-transport-https ca-certificates curl git-core software-properties-common
curl -fsSL | apt-key add -
add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"
apt-get update && apt-get install -y docker-ce docker-compose
curl -L`uname -s`-`uname -m` -o /usr/bin/docker-compose


Original article: Launch an Alibaba Cloud ECS with Docker using Terraform.

✉️ Contact

Ready to take the next step? Don't wait any longer! If you're interested in learning more about Guztia products and services, or if you have any questions or concerns, book a meeting today.

Book a Meeting

Our team of experts is standing by, ready to assist you with anything you need. Book a Meeting, and Guztia will take care of the rest.