Skip to content

Commit

Permalink
feat: create ecs in beijing
Browse files Browse the repository at this point in the history
  • Loading branch information
msq177 committed Jan 8, 2025
1 parent 2bd5fee commit 09ed274
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 0 deletions.
12 changes: 12 additions & 0 deletions regions/cn-beijing/backend.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
bucket = "terraform-demo-beijing" #存储桶名称
key = "terraform-demo-beijing/terraform.tfstate" #对象名称
region = "cn-beijing" #存储桶所在地域
endpoints = {
s3 = "https://tos-s3-cn-beijing.volces.com" #TOS的S3域名
}

skip_region_validation = true
skip_metadata_api_check = true
skip_credentials_validation = true
skip_requesting_account_id = true
skip_s3_checksum = true
20 changes: 20 additions & 0 deletions regions/cn-beijing/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module "network" {
source = "../../modules/network"

vpc_name = var.vpc_name
vpc_cidr = var.vpc_cidr
subnet_name = var.subnet_name
subnet_cidr = var.subnet_cidr
zone_id = var.zone_id
bandwidth = 2
}

module "ecs" {
source = "../../modules/ecs"

subnet_id = module.network.subnet_id
security_group_ids = [module.network.security_group_id]
associate_eip = true
eip_id = module.network.eip_id
image_id = var.image_id
}
16 changes: 16 additions & 0 deletions regions/cn-beijing/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
terraform {
required_version = ">= 1.6.0"

required_providers {
volcengine = {
source = "volcengine/volcengine"
version = "=0.0.156"
}
}

backend "s3" {}
}

provider "volcengine" {
region = var.region
}
9 changes: 9 additions & 0 deletions regions/cn-beijing/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
region = "cn-beijing"
vpc_name = "tf-test-vpc-demo"
vpc_cidr = "172.16.0.0/16"
subnet_name = "tf-test-subnet-demo"
subnet_cidr = "172.16.0.0/24"
zone_id = "cn-beijing-a"

instance_name_prefix = "tf-test-ecs-demo-"
image_id = "image-ybqi99s7yq8rx7mnk44b"
76 changes: 76 additions & 0 deletions regions/cn-beijing/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
## Network
variable "region" {
type = string
}

variable "vpc_name" {
default = "tf-demo-vpc"
}

variable "vpc_cidr" {
default = "172.16.0.0/16"
}

variable "zone_id" {
type = string
default = "cn-beijing-a"
}

variable "subnet_name" {
type = string
default = "tf-demo-subnet"
}

variable "subnet_cidr" {
type = string
default = "172.16.0.0/24"
}

variable "bandwidth" {
type = number
default = 1
}

## ECS

variable "instance_name_prefix" {
description = "Instance name prefix, will be used to generate unique instance name. Will be ignored if var.instance_name is specified"
type = string
default = "tf-prefix-"
}

variable "instance_type" {
description = "Instance type"
type = string
default = "ecs.g1.large"
}

variable "image_id" {
description = "The Image ID of ECS instance"
type = string
}

variable "system_volume_type" {
description = "Valid values: PTSSD, ESSD_PL0, ESSD_PL1, ESSD_PL2, ESSD_FlexPL etc."
type = string
default = "ESSD_PL0"
}

variable "system_volume_size" {
description = "System volume size"
type = string
default = 40
}

variable "password" {
description = "The Password of ECS instance"
nullable = true
sensitive = true
default = null
}

variable "associate_eip" {
description = "Whether associate the Eip for ECS instance"
type = bool
default = false
}

0 comments on commit 09ed274

Please sign in to comment.