github.com/candidpartners/terraform@v0.9.5-0.20171005231213-29f5f88820f6/examples/alicloud-ecs-slb/main.tf (about)

     1  resource "alicloud_security_group" "group" {
     2    name = "${var.short_name}"
     3    description = "New security group"
     4  }
     5  
     6  resource "alicloud_security_group_rule" "http-in" {
     7    type = "ingress"
     8    ip_protocol = "tcp"
     9    nic_type = "internet"
    10    policy = "accept"
    11    port_range = "80/80"
    12    priority = 1
    13    security_group_id = "${alicloud_security_group.group.id}"
    14    cidr_ip = "0.0.0.0/0"
    15  }
    16  
    17  resource "alicloud_security_group_rule" "https-in" {
    18    type = "ingress"
    19    ip_protocol = "tcp"
    20    nic_type = "internet"
    21    policy = "accept"
    22    port_range = "443/443"
    23    priority = 1
    24    security_group_id = "${alicloud_security_group.group.id}"
    25    cidr_ip = "0.0.0.0/0"
    26  }
    27  
    28  resource "alicloud_security_group_rule" "ssh-in" {
    29    type = "ingress"
    30    ip_protocol = "tcp"
    31    nic_type = "internet"
    32    policy = "accept"
    33    port_range = "22/22"
    34    priority = 1
    35    security_group_id = "${alicloud_security_group.group.id}"
    36    cidr_ip = "0.0.0.0/0"
    37  }
    38  
    39  resource "alicloud_instance" "instance" {
    40    instance_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}"
    41    host_name = "${var.short_name}-${var.role}-${format(var.count_format, count.index+1)}"
    42    image_id = "${var.image_id}"
    43    instance_type = "${var.ecs_type}"
    44    count = "${var.count}"
    45    security_groups = ["${alicloud_security_group.group.*.id}"]
    46    internet_charge_type = "${var.internet_charge_type}"
    47    internet_max_bandwidth_out = "${var.internet_max_bandwidth_out}"
    48    io_optimized = "${var.io_optimized}"
    49    password = "${var.ecs_password}"
    50    allocate_public_ip = "${var.allocate_public_ip}"
    51    availability_zone = ""
    52    instance_charge_type = "PostPaid"
    53    system_disk_category = "cloud_efficiency"
    54  
    55    tags {
    56      role = "${var.role}"
    57      dc = "${var.datacenter}"
    58    }
    59  }
    60  
    61  resource "alicloud_slb" "instance" {
    62    name = "${var.slb_name}"
    63    internet_charge_type = "${var.slb_internet_charge_type}"
    64    internet = "${var.internet}"
    65  
    66    listener = [
    67      {
    68        "instance_port" = "2111"
    69        "lb_port" = "21"
    70        "lb_protocol" = "tcp"
    71        "bandwidth" = "5"
    72      }]
    73  }
    74  
    75  
    76  resource "alicloud_slb_attachment" "default" {
    77    slb_id = "${alicloud_slb.instance.id}"
    78    instances = ["${alicloud_instance.instance.*.id}"]
    79  }