alicloud_eci_container_group

Provides ECI Container Group resource.

For information about ECI Container Group and how to use it, see What is Container Group.

Example Usage

Basic Usage

provider "alicloud" {
  region = "cn-beijing"
}
variable "name" {
  default = "tf-example"
}

data "alicloud_eci_zones" "default" {}
resource "alicloud_vpc" "default" {
  vpc_name   = var.name
  cidr_block = "10.0.0.0/8"
}
resource "alicloud_vswitch" "default" {
  vswitch_name = var.name
  cidr_block   = "10.1.0.0/16"
  vpc_id       = alicloud_vpc.default.id
  zone_id      = data.alicloud_eci_zones.default.zones.0.zone_ids.0
}
resource "alicloud_security_group" "default" {
  name   = var.name
  vpc_id = alicloud_vpc.default.id
}

resource "alicloud_eci_container_group" "default" {
  container_group_name = var.name
  cpu                  = 8.0
  memory               = 16.0
  restart_policy       = "OnFailure"
  security_group_id    = alicloud_security_group.default.id
  vswitch_id           = alicloud_vswitch.default.id
  auto_create_eip      = true
  tags = {
    Created = "TF",
    For     = "example",
  }

  containers {
    image             = "registry.cn-beijing.aliyuncs.com/eci_open/nginx:alpine"
    name              = "nginx"
    working_dir       = "/tmp/nginx"
    image_pull_policy = "IfNotPresent"
    commands          = ["/bin/sh", "-c", "sleep 9999"]
    volume_mounts {
      mount_path = "/tmp/example"
      read_only  = false
      name       = "empty1"
    }
    ports {
      port     = 80
      protocol = "TCP"
    }
    environment_vars {
      key   = "name"
      value = "nginx"
    }
    liveness_probe {
      period_seconds        = "5"
      initial_delay_seconds = "5"
      success_threshold     = "1"
      failure_threshold     = "3"
      timeout_seconds       = "1"
      exec {
        commands = ["cat /tmp/healthy"]
      }
    }
    readiness_probe {
      period_seconds        = "5"
      initial_delay_seconds = "5"
      success_threshold     = "1"
      failure_threshold     = "3"
      timeout_seconds       = "1"
      exec {
        commands = ["cat /tmp/healthy"]
      }
    }
  }
  init_containers {
    name              = "init-busybox"
    image             = "registry.cn-beijing.aliyuncs.com/eci_open/busybox:1.30"
    image_pull_policy = "IfNotPresent"
    commands          = ["echo"]
    args              = ["hello initcontainer"]
  }
  volumes {
    name = "empty1"
    type = "EmptyDirVolume"
  }
  volumes {
    name = "empty2"
    type = "EmptyDirVolume"
  }
}

Argument Reference

The following arguments are supported:

acr_registry_info

The acr_registry_info supports the following:

image_registry_credential

The image_registry_credential supports the following:

volumes

The volumes supports the following:

volumes-config_file_volume_config_file_to_paths

The config_file_volume_config_file_to_paths supports the following:

host_aliases

The host_aliases supports the following:

eci_security_context

The eci_security_context supports the following:

eci_security_context-sysctls

The sysctls supports the following:

security_context

The security_context supports the following:

security_context-sysctl

The sysctls supports the following:

dns_config

The dns_config supports the following:

dns_config-options

The options supports the following:

init_containers

The init_containers supports the following:

init_containers-ports

The ports supports the following:

init_containers-environment_vars

The environment_vars supports the following:

init_containers-environment_vars-field_ref

init_containers-volume_mounts

The volume_mounts supports the following:

init_containers-security_context

The security_context supports the following:

init_containers-security_context-capability

The capability supports the following:

containers

The containers supports the following:

containers-ports

The ports supports the following:

containers-environment_vars

The environment_vars supports the following:

containers-environment_vars-field_ref

containers-volume_mounts

The volume_mounts supports the following:

containers-liveness_probe

The liveness_probe supports the following:

containers-liveness_probe-exec

The exec supports the following:

containers-liveness_probe-tcp_socket

The tcp_socket supports the following:

containers-liveness_probe-http_get

The http_get supports the following:

containers-readiness_probe

The readiness_probe supports the following:

containers-readiness_probe-exec

The exec supports the following:

containers-readiness_probe-tcp_socket

The tcp_socket supports the following:

containers-readiness_probe-http_get

The http_get supports the following:

containers-security_context

The security_context supports the following:

containers-security_context-capability

The capability supports the following:

Attributes Reference

The following attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

ECI Container Group can be imported using the id, e.g.

$ terraform import alicloud_eci_container_group.example <container_group_id>