Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create ecs in beijing #1

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-"
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
}
Loading