
Volcengine Iac
- 30 installs
- 16 repo stars
- Updated August 3, 2026
- volcengine/volcengine-skills
Helps with ai & agent building tasks.
About
volcengine-iac is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- volcengine-iac
- AI & Agent Building
- AI-coding skill
Volcengine Iac by the numbers
- 30 all-time installs (skills.sh)
- +1 installs in the week ending Jul 27, 2026 (Skillselion tracking)
- Ranked #9,223 of 16,556 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/volcengine/volcengine-skills --skill volcengine-iacAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 30 |
|---|---|
| repo stars | ★ 16 |
| Last updated | August 3, 2026 |
| Repository | volcengine/volcengine-skills ↗ |
What it does
Helps with ai & agent building tasks.
Files
terraform {
required_version = ">= 1.5"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
volcengine = {
source = "volcengine/volcengine"
version = "~> 0.0.196"
}
}
}
provider "volcenginecc" {}
provider "volcengine" {}
variable "prefix" {
type = string
description = "Unique lowercase prefix for temporary resources."
default = "iac-vke-cr-nginx"
validation {
condition = can(regex("^[a-z][a-z0-9-]{2,29}$", var.prefix)) && !endswith(var.prefix, "-")
error_message = "prefix must be 3-30 chars, start with a letter, contain only lowercase letters, digits, and hyphens, and not end with a hyphen."
}
}
variable "project" {
type = string
description = "Volcengine project name."
default = "default"
}
variable "region" {
type = string
description = "Volcengine region ID."
default = "cn-beijing"
}
variable "zone_a" {
type = string
description = "Primary availability zone."
default = "cn-beijing-a"
}
variable "zone_b" {
type = string
description = "Secondary availability zone."
default = "cn-beijing-b"
}
variable "node_password_base64" {
type = string
description = "Base64-encoded ECS root password required by VKE node pools."
sensitive = true
}
variable "kubeconfig_grantee_id" {
type = number
description = "Optional IAM user ID to grant vke:admin before creating a kubeconfig."
default = null
}
variable "manage_core_dns_addon" {
type = bool
description = "Whether to create core-dns as a Terraform addon resource. See the reference before destroying when true."
default = true
}
locals {
namespace_name = "app"
repository_name = "nginx"
tags = [
{
key = "purpose"
value = "iac-vke-cr-nginx"
},
{
key = "managed-by"
value = "terraform"
},
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${var.prefix}-vpc"
description = "VKE CR nginx IaC example VPC"
cidr_block = "10.94.0.0/16"
enable_ipv_6 = false
project_name = var.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = var.zone_a
subnet_name = "${var.prefix}-subnet-a"
description = "VKE CR nginx IaC example primary subnet"
cidr_block = "10.94.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "secondary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = var.zone_b
subnet_name = "${var.prefix}-subnet-b"
description = "VKE CR nginx IaC example secondary subnet"
cidr_block = "10.94.2.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${var.prefix}-rt"
description = "VKE CR nginx IaC example route table"
project_name = var.project
associate_type = "Subnet"
subnet_ids = [
volcenginecc_vpc_subnet.primary.subnet_id,
volcenginecc_vpc_subnet.secondary.subnet_id,
]
tags = local.tags
}
resource "volcengine_cr_registry" "main" {
name = var.prefix
project = var.project
type = "Enterprise"
delete_immediately = true
resource_tags {
key = "purpose"
value = "iac-vke-cr-nginx"
}
resource_tags {
key = "managed-by"
value = "terraform"
}
}
resource "volcengine_cr_endpoint" "public" {
registry = volcengine_cr_registry.main.name
enabled = true
}
resource "volcengine_cr_endpoint_acl_policy" "public" {
registry = volcengine_cr_registry.main.name
type = "Public"
entry = "0.0.0.0/0"
description = "Temporary public CR push/pull ACL for the IaC VKE nginx example"
depends_on = [
volcengine_cr_endpoint.public,
]
}
resource "volcengine_cr_namespace" "app" {
registry = volcengine_cr_registry.main.name
name = local.namespace_name
project = var.project
repository_default_access_level = "Private"
}
resource "volcengine_cr_repository" "nginx" {
registry = volcengine_cr_registry.main.name
namespace = volcengine_cr_namespace.app.name
name = local.repository_name
description = "Private nginx image repository for VKE pull validation"
access_level = "Private"
}
data "volcengine_cr_authorization_tokens" "main" {
registry = volcengine_cr_registry.main.name
depends_on = [
volcengine_cr_endpoint_acl_policy.public,
volcengine_cr_repository.nginx,
]
}
resource "volcenginecc_vke_cluster" "main" {
project_name = var.project
name = var.prefix
description = "VKE cluster for the IaC CR nginx example"
delete_protection_enabled = false
kubernetes_version_create = "1.30"
cluster_config = {
subnet_ids = [
volcenginecc_vpc_subnet.primary.subnet_id,
volcenginecc_vpc_subnet.secondary.subnet_id,
]
api_server_public_access_enabled = true
api_server_public_access_config = {
public_access_network_config = {
billing_type = 3
bandwidth = 1
isp = "BGP"
}
}
resource_public_access_default_enabled = false
}
pods_config = {
pod_network_mode = "Flannel"
flannel_config = {
max_pods_per_node = 64
pod_cidrs = ["172.20.0.0/16"]
}
}
services_config = {
service_cidrsv_4 = ["172.21.0.0/20"]
}
tags = local.tags
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_vke_node_pool" "main" {
cluster_id = volcenginecc_vke_cluster.main.cluster_id
name = "${var.prefix}-np"
auto_scaling = {
enabled = true
min_replicas = 0
max_replicas = 1
desired_replicas = 1
subnet_policy = "ZoneBalance"
}
node_config = {
instance_charge_type = "PostPaid"
image_id = "image-yd6lmt386vgqef1r7xpu"
instance_type_ids = ["ecs.g4i.large"]
project_name = var.project
public_access_enabled = true
public_access_config = {
bandwidth = 1
billing_type = 3
isp = "BGP"
}
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
security = {
login = {
password = var.node_password_base64
}
security_group_ids = tolist(volcenginecc_vke_cluster.main.cluster_config.security_group_ids)
}
system_volume = {
size = 40
type = "ESSD_PL0"
}
}
tags = local.tags
}
resource "volcenginecc_vke_node_pool" "dns" {
cluster_id = volcenginecc_vke_cluster.main.cluster_id
name = "${var.prefix}-dns-np"
auto_scaling = {
enabled = true
min_replicas = 0
max_replicas = 1
desired_replicas = 1
subnet_policy = "ZoneBalance"
}
node_config = {
instance_charge_type = "PostPaid"
image_id = "image-yd6lmt386vgqef1r7xpu"
instance_type_ids = ["ecs.g4i.2xlarge"]
project_name = var.project
public_access_enabled = true
public_access_config = {
bandwidth = 1
billing_type = 3
isp = "BGP"
}
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
security = {
login = {
password = var.node_password_base64
}
security_group_ids = tolist(volcenginecc_vke_cluster.main.cluster_config.security_group_ids)
}
system_volume = {
size = 40
type = "ESSD_PL0"
}
}
tags = local.tags
}
resource "volcenginecc_vke_default_node_pool" "default" {
cluster_id = volcenginecc_vke_cluster.main.cluster_id
node_config = {
security = {
login = {
password = var.node_password_base64
}
security_group_ids = tolist(volcenginecc_vke_cluster.main.cluster_config.security_group_ids)
}
}
}
resource "volcengine_vke_permission" "operator" {
count = var.kubeconfig_grantee_id == null ? 0 : 1
role_domain = "cluster"
cluster_id = volcenginecc_vke_cluster.main.cluster_id
role_name = "vke:admin"
grantee_id = var.kubeconfig_grantee_id
grantee_type = "User"
}
resource "volcenginecc_vke_addon" "core_dns" {
count = var.manage_core_dns_addon ? 1 : 0
cluster_id = volcenginecc_vke_cluster.main.cluster_id
name = "core-dns"
version = "1.11.3"
deploy_mode = "Unmanaged"
deploy_node_type = "Node"
depends_on = [
volcenginecc_vke_node_pool.dns,
]
}
resource "volcenginecc_vke_addon" "cr_credential_controller" {
cluster_id = volcenginecc_vke_cluster.main.cluster_id
name = "cr-credential-controller"
version = "v1.3.5"
deploy_mode = "Unmanaged"
deploy_node_type = "Node"
config = jsonencode({
CrConfigmapData = {
Namespace = "*"
ServiceAccount = "*"
Registries = [
{
Instance = volcengine_cr_registry.main.name
Region = var.region
Domains = [local.registry_endpoint]
}
]
}
})
depends_on = [
volcenginecc_vke_node_pool.dns,
volcengine_cr_repository.nginx,
]
}
resource "volcengine_vke_kubeconfig" "public" {
cluster_id = volcenginecc_vke_cluster.main.cluster_id
type = "Public"
valid_duration = 1
depends_on = [
volcenginecc_vke_node_pool.dns,
volcengine_vke_permission.operator,
]
}
data "volcengine_vke_kubeconfigs" "public" {
ids = [volcengine_vke_kubeconfig.public.id]
}
locals {
registry_endpoint = volcengine_cr_registry.main.domains[0].domain
repository_uri = "${local.registry_endpoint}/${volcengine_cr_namespace.app.name}/${volcengine_cr_repository.nginx.name}"
cr_token = tolist(data.volcengine_cr_authorization_tokens.main.tokens)[0]
}
output "cluster_id" {
value = volcenginecc_vke_cluster.main.cluster_id
}
output "kubeconfig" {
value = data.volcengine_vke_kubeconfigs.public.kubeconfigs[0].kubeconfig
sensitive = true
}
output "registry_name" {
value = volcengine_cr_registry.main.name
}
output "registry_endpoint" {
value = local.registry_endpoint
}
output "repository_uri" {
value = local.repository_uri
}
output "cr_username" {
value = local.cr_token.username
}
output "cr_token" {
value = local.cr_token.token
sensitive = true
}
terraform {
required_version = ">= 1.5"
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.35"
}
null = {
source = "hashicorp/null"
version = "~> 3.2"
}
}
}
variable "kubeconfig_path" {
type = string
description = "Path to decoded kubeconfig."
}
variable "registry_endpoint" {
type = string
description = "CR registry endpoint."
}
variable "repository_uri" {
type = string
description = "CR repository URI without tag."
}
variable "cr_username" {
type = string
description = "CR authorization username used only for pushing the image."
}
variable "cr_token" {
type = string
description = "CR authorization token used only for pushing the image."
sensitive = true
}
variable "image_tag" {
type = string
description = "Image tag to push and deploy."
default = "official-nginx-1.27-amd64"
}
variable "image_platform" {
type = string
description = "Required platform for the VKE ECS nodes used by this example."
default = "linux/amd64"
validation {
condition = var.image_platform == "linux/amd64"
error_message = "This VKE nginx example is verified only on linux/amd64 ECS nodes; keep image_platform set to linux/amd64."
}
}
variable "use_explicit_image_pull_secret" {
type = bool
description = "Use the verified explicit pull secret path. Set false only after verifying cr-credential-controller injection in your cluster."
default = true
}
variable "service_type" {
type = string
description = "Kubernetes Service type. Use LoadBalancer when a public address is required for manual verification."
default = "ClusterIP"
validation {
condition = contains(["ClusterIP", "LoadBalancer"], var.service_type)
error_message = "service_type must be ClusterIP or LoadBalancer."
}
}
locals {
namespace_name = "iac-nginx"
source_image = "nginx:1.27-alpine"
target_image = "${var.repository_uri}:${var.image_tag}"
dockerconfigjson = jsonencode({
auths = {
(var.registry_endpoint) = {
username = var.cr_username
password = var.cr_token
auth = base64encode("${var.cr_username}:${var.cr_token}")
}
}
})
}
provider "kubernetes" {
config_path = var.kubeconfig_path
}
resource "null_resource" "nginx_image" {
triggers = {
source_image = local.source_image
target_image = local.target_image
image_platform = var.image_platform
}
provisioner "local-exec" {
interpreter = ["/bin/sh", "-c"]
environment = {
CR_TOKEN = var.cr_token
CR_USERNAME = var.cr_username
IMAGE_PLATFORM = var.image_platform
REGISTRY_ENDPOINT = var.registry_endpoint
SOURCE_IMAGE = local.source_image
TARGET_IMAGE = local.target_image
}
command = <<EOT
set -eu
docker image rm "$TARGET_IMAGE" >/dev/null 2>&1 || true
docker image rm "$SOURCE_IMAGE" >/dev/null 2>&1 || true
printf '%s' "$CR_TOKEN" | docker login "$REGISTRY_ENDPOINT" --username "$CR_USERNAME" --password-stdin >/dev/null
docker pull --platform "$IMAGE_PLATFORM" "$SOURCE_IMAGE"
actual_platform="$(docker image inspect --format '{{.Os}}/{{.Architecture}}' "$SOURCE_IMAGE")"
if [ "$actual_platform" != "$IMAGE_PLATFORM" ]; then
echo "Expected $SOURCE_IMAGE to be $IMAGE_PLATFORM, got $actual_platform" >&2
exit 1
fi
docker tag "$SOURCE_IMAGE" "$TARGET_IMAGE"
docker push "$TARGET_IMAGE"
EOT
}
}
resource "kubernetes_namespace" "demo" {
metadata {
name = local.namespace_name
}
}
resource "kubernetes_secret" "cr" {
count = var.use_explicit_image_pull_secret ? 1 : 0
metadata {
name = "volcengine-cr-credential"
namespace = kubernetes_namespace.demo.metadata[0].name
}
type = "kubernetes.io/dockerconfigjson"
data = {
".dockerconfigjson" = local.dockerconfigjson
}
}
resource "kubernetes_deployment" "nginx" {
metadata {
name = "nginx"
namespace = kubernetes_namespace.demo.metadata[0].name
labels = {
app = "nginx"
}
}
spec {
replicas = 1
selector {
match_labels = {
app = "nginx"
}
}
template {
metadata {
labels = {
app = "nginx"
}
}
spec {
dynamic "image_pull_secrets" {
for_each = var.use_explicit_image_pull_secret ? [1] : []
content {
name = kubernetes_secret.cr[0].metadata[0].name
}
}
container {
name = "nginx"
image = null_resource.nginx_image.triggers.target_image
image_pull_policy = "Always"
port {
container_port = 80
}
resources {
requests = {
cpu = "50m"
memory = "64Mi"
}
limits = {
cpu = "250m"
memory = "128Mi"
}
}
}
}
}
}
}
resource "kubernetes_service" "nginx" {
metadata {
name = "nginx"
namespace = kubernetes_namespace.demo.metadata[0].name
}
spec {
selector = {
app = "nginx"
}
port {
port = 80
target_port = 80
}
type = var.service_type
}
}
output "image" {
value = null_resource.nginx_image.triggers.target_image
}
output "namespace" {
value = kubernetes_namespace.demo.metadata[0].name
}
output "service_type" {
value = kubernetes_service.nginx.spec[0].type
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
}
resource "volcenginecc_alb_acl" "main" {
acl_name = "cc-iac-alb-acl"
description = "volcenginecc ALB ACL example"
project_name = local.project
acl_entries = [
{
description = "example entry"
entry = "198.51.100.10/32"
}
]
}
output "acl_id" {
value = volcenginecc_alb_acl.main.acl_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "certificate_public_key" {
description = "PEM encoded server certificate. Pass with TF_VAR_certificate_public_key; do not commit certificate material."
type = string
sensitive = true
}
variable "certificate_private_key" {
description = "PEM encoded RSA private key. Pass with TF_VAR_certificate_private_key; this value is stored in Terraform state."
type = string
sensitive = true
}
locals {
project = "default"
prefix = "cc-iac-alb-cert"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_alb_certificate" "server" {
certificate_name = "${local.prefix}-server"
certificate_type = "Server"
public_key = var.certificate_public_key
private_key = var.certificate_private_key
description = "volcenginecc ALB server certificate example"
project_name = local.project
tags = local.tags
}
output "certificate_id" {
value = volcenginecc_alb_certificate.server.certificate_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
resource "volcenginecc_alb_customized_cfg" "main" {
customized_cfg_name = "cc-iac-alb-cfg"
description = "volcenginecc ALB customized config example"
project_name = "default"
customized_cfg_content = "client_max_body_size 60M;\r\nkeepalive_timeout 77s;\r\n"
}
output "customized_cfg_id" {
value = volcenginecc_alb_customized_cfg.main.customized_cfg_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-alb"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_alb_health_check_template" "http" {
health_check_template_name = "${local.prefix}-hc"
description = "volcenginecc ALB health check template example"
health_check_domain = "example.com"
health_check_http_code = "http_2xx,http_3xx"
health_check_http_version = "HTTP1.1"
health_check_interval = 2
health_check_method = "GET"
health_check_port = 0
health_check_protocol = "HTTP"
health_check_timeout = 2
health_check_uri = "/"
healthy_threshold = 3
unhealthy_threshold = 3
project_name = local.project
tags = local.tags
}
output "health_check_template_id" {
value = volcenginecc_alb_health_check_template.http.health_check_template_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-alb"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc ALB example VPC"
cidr_block = "10.92.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = "cn-beijing-a"
subnet_name = "${local.prefix}-subnet-a"
description = "volcenginecc ALB example subnet a"
cidr_block = "10.92.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "secondary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = "cn-beijing-b"
subnet_name = "${local.prefix}-subnet-b"
description = "volcenginecc ALB example subnet b"
cidr_block = "10.92.2.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt-a"
description = "volcenginecc ALB example route table a"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "secondary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt-b"
description = "volcenginecc ALB example route table b"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.secondary.subnet_id]
tags = local.tags
}
resource "volcenginecc_alb_load_balancer" "main" {
type = "private"
address_ip_version = "IPv4"
load_balancer_name = "${local.prefix}-alb"
description = "volcenginecc ALB example"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
load_balancer_billing_type = 1
delete_protection = "off"
project_name = local.project
modification_protection_status = "NonProtection"
load_balancer_edition = "Basic"
waf_protection_enabled = "off"
zone_mappings = [
{
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
zone_id = "cn-beijing-a"
},
{
subnet_id = volcenginecc_vpc_subnet.secondary.subnet_id
zone_id = "cn-beijing-b"
}
]
depends_on = [
volcenginecc_vpc_route_table.primary,
volcenginecc_vpc_route_table.secondary,
]
}
resource "volcenginecc_alb_server_group" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
server_group_name = "${local.prefix}-sg"
server_group_type = "ip"
protocol = "HTTP"
scheduler = "wrr"
ip_address_type = "IPv4"
project_name = local.project
description = "volcenginecc ALB example server group"
health_check = {
enabled = "off"
port = 0
interval = 2
timeout = 2
healthy_threshold = 3
unhealthy_threshold = 3
protocol = "HTTP"
method = "HEAD"
http_version = "HTTP1.0"
uri = "/"
http_code = "http_2xx,http_3xx"
}
sticky_session_config = {
sticky_session_enabled = "off"
}
}
resource "volcenginecc_alb_listener" "http" {
load_balancer_id = volcenginecc_alb_load_balancer.main.load_balancer_id
server_group_id = volcenginecc_alb_server_group.main.server_group_id
listener_name = "${local.prefix}-http"
protocol = "HTTP"
port = 8080
enabled = "off"
acl_status = "off"
description = "volcenginecc ALB example HTTP listener"
}
resource "volcenginecc_alb_rule" "app" {
listener_id = volcenginecc_alb_listener.http.listener_id
domain = "alb.example.com"
url = "/app"
server_group_id = volcenginecc_alb_server_group.main.server_group_id
rule_action = ""
traffic_limit_enabled = "off"
description = "volcenginecc ALB example forwarding rule"
}
output "load_balancer_id" {
value = volcenginecc_alb_load_balancer.main.load_balancer_id
}
output "server_group_id" {
value = volcenginecc_alb_server_group.main.server_group_id
}
output "listener_id" {
value = volcenginecc_alb_listener.http.listener_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-apig"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc APIG example VPC"
cidr_block = "172.30.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "main" {
subnet_name = "${local.prefix}-subnet-a"
description = "volcenginecc APIG example subnet"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
cidr_block = "172.30.10.0/24"
zone_id = "cn-beijing-a"
tags = local.tags
}
resource "volcenginecc_apig_gateway" "main" {
name = "${local.prefix}-gateway"
comments = "volcenginecc APIG private gateway example"
type = "standard"
project_name = local.project
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
subnet_ids = [volcenginecc_vpc_subnet.main.subnet_id]
resource_spec = {
instance_spec_code = "1c2g"
replicas = 2
public_network_bandwidth = 0
network_type = {
enable_public_network = false
enable_private_network = true
}
}
}
resource "volcenginecc_apig_gateway_service" "app" {
service_name = "${local.prefix}-service"
gateway_id = volcenginecc_apig_gateway.main.gateway_id
protocol = ["HTTP"]
comments = "volcenginecc APIG private HTTP service example"
auth_spec = {
enable = false
}
service_network_spec = {
enable_public_network = false
enable_private_network = true
}
}
output "vpc_id" {
value = volcenginecc_vpc_vpc.main.vpc_id
}
output "gateway_id" {
value = volcenginecc_apig_gateway.main.gateway_id
}
output "service_id" {
value = volcenginecc_apig_gateway_service.app.service_id
}
output "private_domains" {
value = volcenginecc_apig_gateway_service.app.domains
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "scheduled_launch_time" {
type = string
description = "One-off launch time for the scheduled scaling policy. Must be a near-future UTC timestamp in YYYY-MM-DDTHH:MMZ form, within the Auto Scaling scheduling window (a few days out, not years). Times far in the future fail with InvalidScheduledPolicyLaunchTime.Malformed."
}
locals {
project = "default"
prefix = "cc-iac-as"
zone_id = "cn-beijing-a"
image_id = "image-z0dpqndnmy8rpzcad9rz"
instance_type = "ecs.g4i.large"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc Auto Scaling example VPC"
cidr_block = "10.107.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet-a"
description = "volcenginecc Auto Scaling example subnet"
cidr_block = "10.107.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc Auto Scaling example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
tags = local.tags
}
resource "volcenginecc_vpc_security_group" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
security_group_name = "${local.prefix}-sg"
description = "volcenginecc Auto Scaling example security group"
project_name = local.project
egress_permissions = [
{
description = "allow-all-egress"
direction = "egress"
policy = "accept"
priority = 1
protocol = "all"
port_start = -1
port_end = -1
cidr_ip = "0.0.0.0/0"
prefix_list_id = ""
source_group_id = ""
}
]
tags = local.tags
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_ecs_keypair" "main" {
key_pair_name = "${local.prefix}-key"
project_name = local.project
description = "volcenginecc Auto Scaling example keypair"
tags = local.tags
}
resource "volcenginecc_ecs_launch_template" "main" {
launch_template_name = "${local.prefix}-lt"
launch_template_project_name = local.project
launch_template_tags = local.tags
launch_template_version = {
description = "volcenginecc Auto Scaling example launch template"
image_id = local.image_id
instance_charge_type = "PostPaid"
instance_name = "${local.prefix}-from-lt"
instance_type_id = local.instance_type
key_pair_name = volcenginecc_ecs_keypair.main.key_pair_name
project_name = local.project
security_enhancement_strategy = "InActive"
spot_strategy = "NoSpot"
user_data = "ZWNobyBoZWxsby1mcm9tLWF1dG9zY2FsaW5nLWxhdW5jaC10ZW1wbGF0ZQo="
version_description = "initial verified version"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
network_interfaces = [
{
security_group_ids = [volcenginecc_vpc_security_group.app.security_group_id]
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
}
]
volumes = [
{
delete_with_instance = true
extra_performance_iops = 0
extra_performance_throughput_mb = 0
extra_performance_type_id = ""
size = 20
snapshot_id = ""
volume_type = "ESSD_PL0"
}
]
tags = local.tags
}
}
resource "volcenginecc_autoscaling_scaling_group" "app" {
scaling_group_name = "${local.prefix}-group"
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
min_instance_number = 0
max_instance_number = 0
desire_instance_number = 0
default_cooldown = 300
health_check_type = "ECS"
scaling_mode = "release"
multi_az_policy = "PRIORITY"
is_enable_scaling_group = false
launch_template_id = volcenginecc_ecs_launch_template.main.launch_template_id
launch_template_version = "Default"
project_name = local.project
tags = local.tags
depends_on = [
volcenginecc_ecs_launch_template.main,
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_autoscaling_scaling_configuration" "app" {
scaling_group_id = volcenginecc_autoscaling_scaling_group.app.scaling_group_id
scaling_configuration_name = "${local.prefix}-config"
instance_name = "${local.prefix}-instance"
host_name = "cc-iac-as"
image_id = local.image_id
security_group_ids = [volcenginecc_vpc_security_group.app.security_group_id]
key_pair_name = volcenginecc_ecs_keypair.main.key_pair_name
instance_type_overrides = [
{
instance_type = local.instance_type
price_limit = 0
}
]
security_enhancement_strategy = "InActive"
spot_strategy = "NoSpot"
zone_id = local.zone_id
project_name = local.project
user_data = "ZWNobyB2b2xjZW5naW5lY2MtYXV0b3NjYWxpbmcK"
volumes = [
{
delete_with_instance = true
size = 20
volume_type = "ESSD_PL0"
}
]
tags = local.tags
}
resource "volcenginecc_autoscaling_scaling_lifecycle_hook" "scale_out" {
scaling_group_id = volcenginecc_autoscaling_scaling_group.app.scaling_group_id
lifecycle_hook_name = "${local.prefix}-scale-out"
lifecycle_hook_type = "SCALE_OUT"
lifecycle_hook_timeout = 30
lifecycle_hook_policy = "CONTINUE"
}
resource "volcenginecc_autoscaling_scaling_policy" "scheduled" {
scaling_group_id = volcenginecc_autoscaling_scaling_group.app.scaling_group_id
scaling_policy_name = "${local.prefix}-sched"
scaling_policy_type = "Scheduled"
adjustment_type = "QuantityChangeInCapacity"
adjustment_value = 1
cooldown = 300
scheduled_policy = {
launch_time = var.scheduled_launch_time
recurrence_end_time = ""
recurrence_type = ""
recurrence_value = ""
}
is_enabled_policy = false
}
output "scaling_policy_id" {
value = volcenginecc_autoscaling_scaling_policy.scheduled.scaling_policy_id
}
output "scaling_group_id" {
value = volcenginecc_autoscaling_scaling_group.app.scaling_group_id
}
output "scaling_configuration_id" {
value = volcenginecc_autoscaling_scaling_configuration.app.scaling_configuration_id
}
output "lifecycle_hook_id" {
value = volcenginecc_autoscaling_scaling_lifecycle_hook.scale_out.lifecycle_hook_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
resource "volcenginecc_cbr_vault" "app" {
vault_name = "cc-iac-cbr-vault"
project_name = "default"
}
resource "volcenginecc_cbr_backup_policy" "app" {
name = "cc-iac-cbr-policy"
backup_type = "INCREMENTAL"
crontab = "0 2 * * 1"
enable_policy = false
retention_day = 7
retention_num_max = -1
retention_num_min = 2
}
output "vault_id" {
value = volcenginecc_cbr_vault.app.id
}
output "backup_policy_id" {
value = volcenginecc_cbr_backup_policy.app.id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "account_id" {
type = string
description = "Volcengine account ID that owns the VPC attached to CEN."
}
locals {
project = "default"
prefix = "cc-iac-cen"
region = "cn-beijing"
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc CEN example VPC"
cidr_block = "10.98.0.0/16"
enable_ipv_6 = false
project_name = local.project
}
resource "volcenginecc_cen_cen" "main" {
cen_name = "${local.prefix}-cen"
description = "volcenginecc CEN example"
project_name = local.project
instances = [
{
instance_id = volcenginecc_vpc_vpc.main.vpc_id
instance_owner_id = var.account_id
instance_region_id = local.region
instance_type = "VPC"
}
]
}
output "vpc_id" {
value = volcenginecc_vpc_vpc.main.vpc_id
}
output "cen_id" {
value = volcenginecc_cen_cen.main.cen_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
}
resource "volcenginecc_clb_acl" "main" {
acl_name = "cc-iac-clb-acl"
description = "volcenginecc CLB ACL example"
project_name = local.project
acl_entries = [
{
description = "example entry"
entry = "198.51.100.11/32"
}
]
}
output "acl_id" {
value = volcenginecc_clb_acl.main.acl_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "certificate_public_key" {
description = "PEM encoded server certificate. Pass with TF_VAR_certificate_public_key; do not commit certificate material."
type = string
sensitive = true
}
variable "certificate_private_key" {
description = "PEM encoded RSA private key. Pass with TF_VAR_certificate_private_key; this value is stored in Terraform state."
type = string
sensitive = true
}
locals {
project = "default"
prefix = "cc-iac-clb-cert"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_clb_certificate" "server" {
certificate_name = "${local.prefix}-server"
public_key = var.certificate_public_key
private_key = var.certificate_private_key
description = "volcenginecc CLB server certificate example"
project_name = local.project
tags = local.tags
}
output "certificate_id" {
value = volcenginecc_clb_certificate.server.certificate_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-clb"
zone_a = "cn-beijing-a"
zone_b = "cn-beijing-b"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc CLB example VPC"
cidr_block = "10.91.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_a
subnet_name = "${local.prefix}-subnet"
description = "volcenginecc CLB example subnet"
cidr_block = "10.91.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc CLB example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
tags = local.tags
}
resource "volcenginecc_clb_clb" "main" {
load_balancer_name = "${local.prefix}-clb"
load_balancer_spec = "small_1"
address_ip_version = "ipv4"
bypass_security_group_enabled = "off"
description = "volcenginecc CLB example"
load_balancer_billing_type = 2
master_zone_id = local.zone_a
slave_zone_id = local.zone_b
project_name = local.project
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
type = "private"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
tags = local.tags
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
output "load_balancer_id" {
value = volcenginecc_clb_clb.main.load_balancer_id
}
output "vpc_id" {
value = volcenginecc_vpc_vpc.main.vpc_id
}
output "subnet_id" {
value = volcenginecc_vpc_subnet.primary.subnet_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
resource "volcenginecc_cloudmonitor_rule" "ecs_cpu" {
rule_name = "cc-iac-cm-ecs-cpu"
description = "volcenginecc CloudMonitor example disabled ECS CPU rule"
rule_type = "static"
namespace = "VCM_ECS"
sub_namespace = "Instance"
level = "warning"
evaluation_count = 1
enable_state = "disable"
regions = ["cn-beijing"]
project_name = "default"
original_dimensions = {
key = "ResourceID"
values = ["*"]
}
multiple_conditions = false
condition_operator = "&&"
conditions = [
{
metric_name = "CpuTotal"
statistics = "avg"
comparison_operator = ">"
threshold = "95"
period = "60"
metric_unit = "Percent"
}
]
no_data = {
enable = false
evaluation_count = 3
}
recovery_notify = {
enable = false
}
silence_time = 5
alert_methods = ["Webhook"]
webhook = "https://example.com/volcenginecc-cloudmonitor-disabled"
effect_start_at = "00:00"
effect_end_at = "23:59"
}
output "rule_id" {
value = volcenginecc_cloudmonitor_rule.ecs_cpu.rule_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-cr"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_cr_registry" "main" {
project = local.project
name = local.prefix
type = "Enterprise"
endpoint = {
enabled = true
}
tags = local.tags
}
resource "volcenginecc_cr_name_space" "app" {
registry = volcenginecc_cr_registry.main.name
name = "app"
project = local.project
}
resource "volcenginecc_cr_repository" "app" {
registry = volcenginecc_cr_registry.main.name
namespace = volcenginecc_cr_name_space.app.name
name = "demo"
description = "volcenginecc CR repository example"
access_level = "Public"
}
resource "volcenginecc_cr_endpoint_acl_policy" "public" {
registry = volcenginecc_cr_registry.main.name
type = "Public"
entry = "0.0.0.0/0"
description = "terraform volcenginecc CR endpoint ACL example"
depends_on = [
volcenginecc_cr_registry.main,
]
}
output "registry_name" {
value = volcenginecc_cr_registry.main.name
}
output "namespace_name" {
value = volcenginecc_cr_name_space.app.name
}
output "repository_name" {
value = volcenginecc_cr_repository.app.name
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-dc"
}
resource "volcenginecc_directconnect_direct_connect_gateway" "main" {
direct_connect_gateway_name = "${local.prefix}-gw"
description = "volcenginecc DirectConnect example gateway"
enable_ipv_6 = false
project_name = local.project
}
output "direct_connect_gateway_id" {
value = volcenginecc_directconnect_direct_connect_gateway.main.direct_connect_gateway_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
variable "zone_name" {
description = "A unique apex domain for Cloud DNS verification. Use a domain you own for real traffic."
type = string
default = "cc-iac-dns-0530043107.com"
}
resource "volcenginecc_dns_zone" "main" {
zone_name = var.zone_name
remark = "volcenginecc DNS example"
project_name = local.project
tags = local.tags
}
output "zone_id" {
value = volcenginecc_dns_zone.main.zid
}
output "allocated_dns_servers" {
value = volcenginecc_dns_zone.main.allocate_dns_server_list
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-ebs-sg"
zone_id = "cn-beijing-a"
image_id = "image-z0dpqndnmy8rpzcad9rz"
instance_type = "ecs.g4i.large"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc EBS snapshot group example VPC"
cidr_block = "10.106.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet-a"
description = "volcenginecc EBS snapshot group example subnet"
cidr_block = "10.106.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc EBS snapshot group example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
tags = local.tags
}
resource "volcenginecc_vpc_security_group" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
security_group_name = "${local.prefix}-sg"
description = "volcenginecc EBS snapshot group example security group"
project_name = local.project
egress_permissions = [
{
description = "allow-all-egress"
direction = "egress"
policy = "accept"
priority = 1
protocol = "all"
port_start = -1
port_end = -1
cidr_ip = "0.0.0.0/0"
prefix_list_id = ""
source_group_id = ""
}
]
tags = local.tags
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_ecs_keypair" "main" {
key_pair_name = "${local.prefix}-key"
project_name = local.project
description = "volcenginecc EBS snapshot group example keypair"
tags = local.tags
}
resource "volcenginecc_ecs_instance" "main" {
instance_name = "${local.prefix}-instance"
hostname = "cc-iac-ebs-sg"
description = "volcenginecc EBS snapshot group example instance"
instance_charge_type = "PostPaid"
instance_type = local.instance_type
zone_id = local.zone_id
project_name = local.project
spot_strategy = "NoSpot"
deletion_protection = false
image = {
image_id = local.image_id
security_enhancement_strategy = "InActive"
}
key_pair = {
key_pair_name = volcenginecc_ecs_keypair.main.key_pair_name
}
primary_network_interface = {
security_group_ids = [volcenginecc_vpc_security_group.app.security_group_id]
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
}
system_volume = {
delete_with_instance = true
size = 20
volume_type = "ESSD_PL0"
}
tags = local.tags
lifecycle {
ignore_changes = all
}
}
resource "volcenginecc_storageebs_snapshot_group" "system" {
name = "${local.prefix}-snap-group"
project_name = local.project
instance_id = volcenginecc_ecs_instance.main.instance_id
volume_ids = [volcenginecc_ecs_instance.main.system_volume.volume_id]
tags = local.tags
}
output "instance_id" {
value = volcenginecc_ecs_instance.main.instance_id
}
output "system_volume_id" {
value = volcenginecc_ecs_instance.main.system_volume.volume_id
}
output "snapshot_group_id" {
value = volcenginecc_storageebs_snapshot_group.system.snapshot_group_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-ebs-snap"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_storageebs_volume" "data" {
volume_name = "${local.prefix}-vol"
volume_type = "ESSD_PL0"
size = 10
zone_id = "cn-beijing-a"
pay_type = "post"
kind = "data"
project_name = local.project
tags = local.tags
}
resource "volcenginecc_storageebs_snapshot" "data" {
volume_id = volcenginecc_storageebs_volume.data.volume_id
snapshot_name = "${local.prefix}-snapshot"
project_name = local.project
tags = local.tags
}
output "volume_id" {
value = volcenginecc_storageebs_volume.data.volume_id
}
output "snapshot_id" {
value = volcenginecc_storageebs_snapshot.data.snapshot_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-ecs-extra"
zone_id = "cn-beijing-a"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_ecs_deployment_set" "availability" {
deployment_set_name = "${local.prefix}-dps"
description = "volcenginecc ECS deployment set example"
granularity = "host"
strategy = "Availability"
deployment_set_group_number = 1
}
resource "volcenginecc_ecs_hpc_cluster" "main" {
name = "${local.prefix}-hpc"
zone_id = local.zone_id
description = "volcenginecc ECS HPC cluster example"
project_name = local.project
tags = local.tags
}
output "deployment_set_id" {
value = volcenginecc_ecs_deployment_set.availability.deployment_set_id
}
output "hpc_cluster_id" {
value = volcenginecc_ecs_hpc_cluster.main.hpc_cluster_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-ltv"
zone_id = "cn-beijing-a"
image_id = "image-z0dpqndnmy8rpzcad9rz"
instance_type = "ecs.g4i.large"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc launch template version example VPC"
cidr_block = "10.96.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet-a"
description = "volcenginecc launch template version example subnet"
cidr_block = "10.96.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc launch template version example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
tags = local.tags
}
resource "volcenginecc_vpc_security_group" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
security_group_name = "${local.prefix}-sg"
description = "volcenginecc launch template version example security group"
project_name = local.project
egress_permissions = [
{
description = "allow-all-egress"
direction = "egress"
policy = "accept"
priority = 1
protocol = "all"
port_start = -1
port_end = -1
cidr_ip = "0.0.0.0/0"
prefix_list_id = ""
source_group_id = ""
}
]
tags = local.tags
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_ecs_launch_template" "main" {
launch_template_name = "${local.prefix}-lt"
launch_template_project_name = local.project
launch_template_tags = local.tags
launch_template_version = {
description = "volcenginecc initial launch template version"
image_id = local.image_id
instance_charge_type = "PostPaid"
instance_name = "${local.prefix}-from-lt"
instance_type_id = local.instance_type
project_name = local.project
security_enhancement_strategy = "InActive"
spot_strategy = "NoSpot"
user_data = "ZWNobyBoZWxsby1mcm9tLWx0Cg=="
version_description = "initial verified version"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
network_interfaces = [
{
security_group_ids = [volcenginecc_vpc_security_group.app.security_group_id]
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
}
]
tags = local.tags
}
}
resource "volcenginecc_ecs_launch_template_version" "second" {
launch_template_id = volcenginecc_ecs_launch_template.main.launch_template_id
description = "volcenginecc second launch template version"
image_id = local.image_id
instance_charge_type = "PostPaid"
instance_name = "${local.prefix}-second"
instance_type_id = local.instance_type
project_name = local.project
security_enhancement_strategy = "InActive"
spot_strategy = "NoSpot"
user_data = "ZWNobyBoZWxsby1mcm9tLWx0djIK"
version_description = "standalone verified version"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
network_interfaces = [
{
security_group_ids = [volcenginecc_vpc_security_group.app.security_group_id]
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
}
]
tags = local.tags
}
output "launch_template_id" {
value = volcenginecc_ecs_launch_template.main.launch_template_id
}
output "launch_template_version_number" {
value = volcenginecc_ecs_launch_template_version.second.version_number
}
# Rename this file to invocation.tf only after the ECS instance is running and
# Cloud Assistant has registered. See references/volcenginecc-ecs.md.
resource "volcenginecc_ecs_invocation" "hello" {
invocation_name = "${local.prefix}-invoke"
invocation_description = "volcenginecc ECS example invocation"
command_id = volcenginecc_ecs_command.hello.command_id
instance_ids = [volcenginecc_ecs_instance.main.instance_id]
repeat_mode = "Once"
timeout = 60
username = "root"
working_dir = "/tmp"
project_name = local.project
tags = local.tags
}
output "invocation_id" {
value = volcenginecc_ecs_invocation.hello.invocation_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-ecs"
zone_id = "cn-beijing-a"
image_id = "image-z0dpqndnmy8rpzcad9rz"
instance_type = "ecs.g4i.large"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc ECS example VPC"
cidr_block = "10.89.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet-a"
description = "volcenginecc ECS example subnet"
cidr_block = "10.89.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc ECS example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
tags = local.tags
}
resource "volcenginecc_vpc_security_group" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
security_group_name = "${local.prefix}-sg"
description = "volcenginecc ECS example security group"
project_name = local.project
ingress_permissions = [
{
description = "allow-http"
direction = "ingress"
policy = "accept"
priority = 1
protocol = "tcp"
port_start = 80
port_end = 80
cidr_ip = "0.0.0.0/0"
prefix_list_id = ""
source_group_id = ""
}
]
egress_permissions = [
{
description = "allow-all-egress"
direction = "egress"
policy = "accept"
priority = 1
protocol = "all"
port_start = -1
port_end = -1
cidr_ip = "0.0.0.0/0"
prefix_list_id = ""
source_group_id = ""
}
]
tags = local.tags
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_ecs_keypair" "main" {
key_pair_name = "${local.prefix}-key"
project_name = local.project
description = "volcenginecc ECS example keypair"
tags = local.tags
}
resource "volcenginecc_storageebs_volume" "data" {
volume_name = "${local.prefix}-data"
volume_type = "ESSD_PL0"
size = 10
zone_id = local.zone_id
pay_type = "post"
project_name = local.project
tags = local.tags
}
resource "volcenginecc_ecs_command" "hello" {
name = "${local.prefix}-hello"
type = "Shell"
command_content = "ZWNobyB2b2xjZW5naW5lY2MtZWNzLW9r"
description = "volcenginecc ECS example command"
project_name = local.project
timeout = 60
username = "root"
working_dir = "/tmp"
tags = local.tags
}
resource "volcenginecc_ecs_launch_template" "main" {
launch_template_name = "${local.prefix}-lt"
launch_template_project_name = local.project
launch_template_tags = local.tags
launch_template_version = {
description = "volcenginecc ECS example launch template"
image_id = local.image_id
instance_charge_type = "PostPaid"
instance_name = "${local.prefix}-from-lt"
instance_type_id = local.instance_type
key_pair_name = volcenginecc_ecs_keypair.main.key_pair_name
project_name = local.project
security_enhancement_strategy = "InActive"
spot_strategy = "NoSpot"
user_data = "ZWNobyBoZWxsby1mcm9tLWxhdW5jaC10ZW1wbGF0ZQo="
version_description = "initial verified version"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
network_interfaces = [
{
security_group_ids = [volcenginecc_vpc_security_group.app.security_group_id]
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
}
]
tags = local.tags
}
}
resource "volcenginecc_ecs_instance" "main" {
instance_name = "${local.prefix}-instance"
hostname = "cc-iac-ecs"
description = "volcenginecc ECS example instance"
instance_charge_type = "PostPaid"
instance_type = local.instance_type
zone_id = local.zone_id
project_name = local.project
spot_strategy = "NoSpot"
deletion_protection = false
install_run_command_agent = true
image = {
image_id = local.image_id
security_enhancement_strategy = "InActive"
}
key_pair = {
key_pair_name = volcenginecc_ecs_keypair.main.key_pair_name
}
primary_network_interface = {
security_group_ids = [volcenginecc_vpc_security_group.app.security_group_id]
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
}
system_volume = {
delete_with_instance = true
size = 20
volume_type = "ESSD_PL0"
}
tags = local.tags
lifecycle {
ignore_changes = all
}
}
output "key_pair_name" {
value = volcenginecc_ecs_keypair.main.key_pair_name
}
output "volume_id" {
value = volcenginecc_storageebs_volume.data.volume_id
}
output "command_id" {
value = volcenginecc_ecs_command.hello.command_id
}
output "launch_template_id" {
value = volcenginecc_ecs_launch_template.main.launch_template_id
}
output "instance_id" {
value = volcenginecc_ecs_instance.main.instance_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-efs"
zone = "cn-beijing-a"
}
resource "volcenginecc_efs_file_system" "main" {
file_system_name = "${local.prefix}-fs"
description = "volcenginecc EFS example file system"
charge_type = "PayAsYouGo"
zone_id = local.zone
instance_type = "Premium"
performance_density = "Premium_125"
project_name = local.project
performance = {
bandwidth_mode = "Provisioned"
provisioned_bandwidth = 300
}
}
output "file_system_id" {
value = volcenginecc_efs_file_system.main.file_system_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-filenas"
zone = "cn-beijing-a"
}
resource "volcenginecc_filenas_instance" "main" {
file_system_name = "${local.prefix}-fs"
description = "volcenginecc FileNAS example file system"
charge_type = "PayAsYouGo"
file_system_type = "Extreme"
protocol_type = "NFS"
storage_type = "Standard"
zone_id = local.zone
project_name = local.project
capacity = {
total = 105
}
}
output "file_system_id" {
value = volcenginecc_filenas_instance.main.file_system_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
resource "volcenginecc_iam_oidc_provider" "github" {
oidc_provider_name = "cc-iac-oidc-github"
issuer_url = "https://token.actions.githubusercontent.com"
client_ids = ["sts.volcengine.example"]
thumbprints = ["b41ae0832808ebc94951437bf7e92b93ccb6479364daf894d46d6001bee7a486"]
description = "volcenginecc OIDC provider example"
issuance_limit_time = 10
}
output "oidc_provider_name" {
value = volcenginecc_iam_oidc_provider.github.oidc_provider_name
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "encoded_saml_metadata_document" {
type = string
description = "Base64-encoded SAML IdP metadata XML. The metadata should contain a public signing certificate only."
}
resource "volcenginecc_iam_saml_provider" "main" {
saml_provider_name = "cc-iac-saml"
description = "volcenginecc SAML provider example"
encoded_saml_metadata_document = var.encoded_saml_metadata_document
sso_type = 1
}
output "saml_provider_name" {
value = volcenginecc_iam_saml_provider.main.saml_provider_name
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
prefix = "cc-iac-iam-users"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_iam_group" "readers" {
user_group_name = "${local.prefix}-group"
display_name = "cc iac iam users group"
description = "volcenginecc IAM group example"
attached_policies = [
{
policy_name = "ReadOnlyAccess"
policy_type = "System"
policy_scope = [
{
policy_scope_type = "Global"
}
]
}
]
}
resource "volcenginecc_iam_user" "app" {
user_name = "${local.prefix}-user"
display_name = "cc iac iam users app"
description = "volcenginecc IAM user example without login profile"
groups = [volcenginecc_iam_group.readers.user_group_name]
policies = [
{
policy_name = "ReadOnlyAccess"
policy_type = "System"
}
]
tags = local.tags
}
output "group_name" {
value = volcenginecc_iam_group.readers.user_group_name
}
output "user_name" {
value = volcenginecc_iam_user.app.user_name
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "account_id" {
type = string
description = "Volcengine account ID used in the role trust policy root principal."
}
locals {
project = "default"
prefix = "cc-iac-iam"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_iam_project" "main" {
project_name = local.prefix
display_name = "cc iac iam example"
description = "volcenginecc IAM example project"
parent_project_name = local.project
}
resource "volcenginecc_iam_role" "main" {
role_name = "${local.prefix}-role"
display_name = "cc iac iam example role"
description = "volcenginecc IAM example role"
max_session_duration = 3600
trust_policy_document = jsonencode({
Statement = [
{
Effect = "Allow"
Action = ["sts:AssumeRole"]
Principal = {
IAM = ["trn:iam::${var.account_id}:root"]
}
}
]
})
tags = local.tags
}
resource "volcenginecc_iam_policy" "main" {
policy_name = "${local.prefix}-policy"
policy_type = "Custom"
description = "volcenginecc IAM example policy"
policy_document = jsonencode({
Statement = [
{
Effect = "Allow"
Action = ["vpc:DescribeVpcs"]
Resource = ["*"]
}
]
})
}
output "project_name" {
value = volcenginecc_iam_project.main.project_name
}
output "role_name" {
value = volcenginecc_iam_role.main.role_name
}
output "policy_name" {
value = volcenginecc_iam_policy.main.policy_name
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
prefix = "cc-iac-kafka-allow"
}
resource "volcenginecc_kafka_allow_list" "app" {
allow_list_name = local.prefix
allow_list = "10.97.0.0/16"
}
output "allow_list_id" {
value = volcenginecc_kafka_allow_list.app.allow_list_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-kafka"
zone_id = "cn-beijing-a"
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc Kafka example VPC"
cidr_block = "10.97.0.0/16"
enable_ipv_6 = false
project_name = local.project
}
resource "volcenginecc_vpc_subnet" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet"
description = "volcenginecc Kafka example subnet"
cidr_block = "10.97.1.0/24"
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc Kafka example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.main.subnet_id]
}
resource "volcenginecc_kafka_allow_list" "app" {
allow_list_name = "${local.prefix}-allow"
allow_list = "10.97.0.0/16"
}
resource "volcenginecc_kafka_instance" "main" {
compute_spec = "kafka.20xrate.hw"
instance_description = "volcenginecc Kafka example instance"
instance_name = "${local.prefix}-instance"
subnet_id = volcenginecc_vpc_subnet.main.subnet_id
ip_white_list = [volcenginecc_kafka_allow_list.app.allow_list_id]
partition_number = 350
storage_space = 300
version = "2.8.2"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
project_name = local.project
charge_info = {
charge_type = "PostPaid"
auto_renew = false
}
depends_on = [volcenginecc_vpc_route_table.app]
}
resource "volcenginecc_kafka_topic" "app" {
instance_id = volcenginecc_kafka_instance.main.instance_id
topic_name = "cc-iac-kafka-topic"
partition_number = 3
replica_number = 3
}
output "instance_id" {
value = volcenginecc_kafka_instance.main.instance_id
}
output "allow_list_id" {
value = volcenginecc_kafka_allow_list.app.allow_list_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "mongodb_password" {
type = string
sensitive = true
}
locals {
project = "default"
prefix = "cc-iac-mongodb"
zone_id = "cn-beijing-a"
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc MongoDB example VPC"
cidr_block = "10.95.0.0/16"
enable_ipv_6 = false
project_name = local.project
}
resource "volcenginecc_vpc_subnet" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet"
description = "volcenginecc MongoDB example subnet"
cidr_block = "10.95.1.0/24"
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc MongoDB example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.main.subnet_id]
}
resource "volcenginecc_mongodb_allow_list" "app" {
allow_list_name = "${local.prefix}-allow"
allow_list_type = "IPv4"
allow_list_category = "Ordinary"
allow_list_desc = "volcenginecc MongoDB allowlist example"
project_name = local.project
allow_list = ["10.0.0.0/8"]
}
resource "volcenginecc_mongodb_instance" "main" {
zone_id = local.zone_id
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
subnet_id = volcenginecc_vpc_subnet.main.subnet_id
db_engine = "MongoDB"
db_engine_version = "MongoDB_7_0"
instance_type = "ReplicaSet"
node_spec = "mongo.1c2g"
node_number = 3
storage_space_gb = 20
super_account_name = "root"
super_account_password = var.mongodb_password
instance_name = "${local.prefix}-instance"
instance_count = 1
charge_type = "PostPaid"
project_name = local.project
allow_list_ids = [volcenginecc_mongodb_allow_list.app.allow_list_id]
depends_on = [volcenginecc_vpc_route_table.app]
}
output "instance_id" {
value = volcenginecc_mongodb_instance.main.id
}
output "allow_list_id" {
value = volcenginecc_mongodb_allow_list.app.allow_list_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-network"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc VPC example"
cidr_block = "10.88.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = "cn-beijing-a"
subnet_name = "${local.prefix}-subnet-a"
description = "volcenginecc subnet example a"
cidr_block = "10.88.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "secondary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = "cn-beijing-b"
subnet_name = "${local.prefix}-subnet-b"
description = "volcenginecc subnet example b"
cidr_block = "10.88.2.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc route table example"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [
volcenginecc_vpc_subnet.primary.subnet_id,
volcenginecc_vpc_subnet.secondary.subnet_id,
]
tags = local.tags
}
resource "volcenginecc_vpc_security_group" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
security_group_name = "${local.prefix}-sg"
description = "volcenginecc security group example"
project_name = local.project
ingress_permissions = [
{
description = "allow-http"
direction = "ingress"
policy = "accept"
priority = 1
protocol = "tcp"
port_start = 80
port_end = 80
cidr_ip = "0.0.0.0/0"
prefix_list_id = ""
source_group_id = ""
}
]
egress_permissions = [
{
description = "allow-all-egress"
direction = "egress"
policy = "accept"
priority = 1
protocol = "all"
port_start = -1
port_end = -1
cidr_ip = "0.0.0.0/0"
prefix_list_id = ""
source_group_id = ""
}
]
tags = local.tags
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_vpc_eip" "standalone" {
name = "${local.prefix}-eip"
description = "volcenginecc standalone EIP example"
isp = "BGP"
billing_type = 2
bandwidth = 1
project_name = local.project
tags = local.tags
}
resource "volcenginecc_natgateway_ngw" "public" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
nat_gateway_name = "${local.prefix}-nat"
description = "volcenginecc public NAT gateway example"
spec = "Small"
billing_type = 2
network_type = "internet"
project_name = local.project
tags = local.tags
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_vpc_eip" "nat" {
name = "${local.prefix}-nat-eip"
description = "volcenginecc NAT EIP example"
isp = "BGP"
billing_type = 2
bandwidth = 1
project_name = local.project
instance_id = volcenginecc_natgateway_ngw.public.nat_gateway_id
instance_type = "Nat"
tags = local.tags
}
resource "volcenginecc_natgateway_snatentry" "subnet_primary" {
nat_gateway_id = volcenginecc_natgateway_ngw.public.nat_gateway_id
eip_id = volcenginecc_vpc_eip.nat.allocation_id
snat_entry_name = "${local.prefix}-snat-a"
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
}
resource "volcenginecc_natgateway_dnatentry" "http_test" {
nat_gateway_id = volcenginecc_natgateway_ngw.public.nat_gateway_id
dnat_entry_name = "${local.prefix}-dnat-http"
external_ip = volcenginecc_vpc_eip.nat.eip_address
external_port = "8080"
internal_ip = "10.88.1.10"
internal_port = "80"
port_type = "specified"
protocol = "tcp"
}
output "vpc_id" {
value = volcenginecc_vpc_vpc.main.vpc_id
}
output "subnet_ids" {
value = [
volcenginecc_vpc_subnet.primary.subnet_id,
volcenginecc_vpc_subnet.secondary.subnet_id,
]
}
output "security_group_id" {
value = volcenginecc_vpc_security_group.app.security_group_id
}
output "route_table_id" {
value = volcenginecc_vpc_route_table.app.route_table_id
}
output "eip_id" {
value = volcenginecc_vpc_eip.standalone.allocation_id
}
output "nat_gateway_id" {
value = volcenginecc_natgateway_ngw.public.nat_gateway_id
}
output "snat_entry_id" {
value = volcenginecc_natgateway_snatentry.subnet_primary.snat_entry_id
}
output "dnat_entry_id" {
value = volcenginecc_natgateway_dnatentry.http_test.dnat_entry_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-pnat"
zone_id = "cn-beijing-a"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc private NAT example VPC"
cidr_block = "10.95.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet-a"
description = "volcenginecc private NAT example subnet"
cidr_block = "10.95.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc private NAT example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
tags = local.tags
}
resource "volcenginecc_natgateway_ngw" "private" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
nat_gateway_name = "${local.prefix}-nat"
description = "volcenginecc private NAT gateway example"
billing_type = 3
network_type = "intranet"
project_name = local.project
tags = local.tags
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_natgateway_nat_ip" "main" {
nat_gateway_id = volcenginecc_natgateway_ngw.private.nat_gateway_id
nat_ip_name = "${local.prefix}-nat-ip"
nat_ip_description = "volcenginecc private NAT transit IP example"
}
output "nat_gateway_id" {
value = volcenginecc_natgateway_ngw.private.nat_gateway_id
}
output "nat_ip_id" {
value = volcenginecc_natgateway_nat_ip.main.nat_ip_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-pl"
zone_a = "cn-beijing-a"
zone_b = "cn-beijing-b"
}
resource "volcenginecc_vpc_vpc" "service" {
vpc_name = "${local.prefix}-svc-vpc"
description = "volcenginecc PrivateLink service VPC"
cidr_block = "10.101.0.0/16"
enable_ipv_6 = false
project_name = local.project
}
resource "volcenginecc_vpc_subnet" "service" {
vpc_id = volcenginecc_vpc_vpc.service.vpc_id
zone_id = local.zone_a
subnet_name = "${local.prefix}-svc-subnet"
description = "volcenginecc PrivateLink service subnet"
cidr_block = "10.101.1.0/24"
}
resource "volcenginecc_vpc_route_table" "service" {
vpc_id = volcenginecc_vpc_vpc.service.vpc_id
route_table_name = "${local.prefix}-svc-rt"
description = "volcenginecc PrivateLink service route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.service.subnet_id]
}
resource "volcenginecc_clb_clb" "service" {
load_balancer_name = "${local.prefix}-clb"
load_balancer_spec = "small_1"
address_ip_version = "ipv4"
bypass_security_group_enabled = "off"
description = "volcenginecc PrivateLink service CLB"
load_balancer_billing_type = 2
master_zone_id = local.zone_a
slave_zone_id = local.zone_b
project_name = local.project
subnet_id = volcenginecc_vpc_subnet.service.subnet_id
type = "private"
vpc_id = volcenginecc_vpc_vpc.service.vpc_id
depends_on = [
volcenginecc_vpc_route_table.service,
]
}
resource "volcenginecc_privatelink_endpoint_service" "main" {
service_type = "Interface"
service_resource_type = "CLB"
ip_address_versions = ["ipv4"]
auto_accept_enabled = true
private_dns_enabled = false
description = "volcenginecc PrivateLink endpoint service"
project_name = local.project
payer = "Endpoint"
permit_account_ids = ["*"]
resources = [
{
resource_id = volcenginecc_clb_clb.service.load_balancer_id
zone_ids = [local.zone_a]
}
]
}
resource "volcenginecc_vpc_vpc" "consumer" {
vpc_name = "${local.prefix}-ep-vpc"
description = "volcenginecc PrivateLink endpoint VPC"
cidr_block = "10.102.0.0/16"
enable_ipv_6 = false
project_name = local.project
}
resource "volcenginecc_vpc_subnet" "consumer" {
vpc_id = volcenginecc_vpc_vpc.consumer.vpc_id
zone_id = local.zone_a
subnet_name = "${local.prefix}-ep-subnet"
description = "volcenginecc PrivateLink endpoint subnet"
cidr_block = "10.102.1.0/24"
}
resource "volcenginecc_vpc_route_table" "consumer" {
vpc_id = volcenginecc_vpc_vpc.consumer.vpc_id
route_table_name = "${local.prefix}-ep-rt"
description = "volcenginecc PrivateLink endpoint route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.consumer.subnet_id]
}
resource "volcenginecc_vpc_security_group" "endpoint" {
vpc_id = volcenginecc_vpc_vpc.consumer.vpc_id
security_group_name = "${local.prefix}-ep-sg"
description = "volcenginecc PrivateLink endpoint security group"
project_name = local.project
}
resource "volcenginecc_privatelink_vpc_endpoint" "main" {
endpoint_name = "${local.prefix}-endpoint"
description = "volcenginecc PrivateLink endpoint"
private_dns_enabled = false
project_name = local.project
security_group_ids = [volcenginecc_vpc_security_group.endpoint.security_group_id]
service_id = volcenginecc_privatelink_endpoint_service.main.service_id
service_name = volcenginecc_privatelink_endpoint_service.main.service_name
vpc_id = volcenginecc_vpc_vpc.consumer.vpc_id
zones = [
{
subnet_id = volcenginecc_vpc_subnet.consumer.subnet_id
zone_id = local.zone_a
}
]
depends_on = [
volcenginecc_vpc_route_table.consumer,
]
}
output "service_id" {
value = volcenginecc_privatelink_endpoint_service.main.service_id
}
output "service_name" {
value = volcenginecc_privatelink_endpoint_service.main.service_name
}
output "clb_id" {
value = volcenginecc_clb_clb.service.load_balancer_id
}
output "endpoint_id" {
value = volcenginecc_privatelink_vpc_endpoint.main.endpoint_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-pzone"
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc PrivateZone resolver example VPC"
cidr_block = "10.89.0.0/16"
enable_ipv_6 = false
project_name = local.project
}
resource "volcenginecc_vpc_subnet" "a" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = "cn-beijing-a"
subnet_name = "${local.prefix}-subnet-a"
cidr_block = "10.89.1.0/24"
}
resource "volcenginecc_vpc_subnet" "b" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = "cn-beijing-b"
subnet_name = "${local.prefix}-subnet-b"
cidr_block = "10.89.2.0/24"
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.a.subnet_id, volcenginecc_vpc_subnet.b.subnet_id]
}
resource "volcenginecc_privatezone_resolver_endpoint" "outbound" {
name = "${local.prefix}-endpoint"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
vpc_region = "cn-beijing"
direction = "OUTBOUND"
endpoint_type = "IPv4"
project_name = local.project
ip_configs = [
{ az_id = "cn-beijing-a", subnet_id = volcenginecc_vpc_subnet.a.subnet_id, ip = "10.89.1.44" },
{ az_id = "cn-beijing-b", subnet_id = volcenginecc_vpc_subnet.b.subnet_id, ip = "10.89.2.44" }
]
depends_on = [volcenginecc_vpc_route_table.app]
}
resource "volcenginecc_privatezone_resolver_rule" "outbound" {
name = "${local.prefix}-rule"
type = "OUTBOUND"
endpoint_id = tonumber(volcenginecc_privatezone_resolver_endpoint.outbound.endpoint_id)
zone_name = "corp.internal"
forward_i_ps = [
{ ip = "10.89.250.10", port = 53 }
]
vp_cs = [
{ region = "cn-beijing", vpc_id = volcenginecc_vpc_vpc.main.vpc_id }
]
}
output "endpoint_id" {
value = volcenginecc_privatezone_resolver_endpoint.outbound.endpoint_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-pzone"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc PrivateZone example VPC"
cidr_block = "10.97.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = "cn-beijing-a"
subnet_name = "${local.prefix}-subnet-a"
description = "volcenginecc PrivateZone example subnet a"
cidr_block = "10.97.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "secondary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = "cn-beijing-b"
subnet_name = "${local.prefix}-subnet-b"
description = "volcenginecc PrivateZone example subnet b"
cidr_block = "10.97.2.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc PrivateZone example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [
volcenginecc_vpc_subnet.primary.subnet_id,
volcenginecc_vpc_subnet.secondary.subnet_id,
]
tags = local.tags
}
resource "volcenginecc_privatezone_private_zone" "main" {
zone_name = "svc.internal"
project_name = local.project
line_mode = 1
recursion_mode = true
remark = "volcenginecc PrivateZone example"
tags = local.tags
vpcs = [
{
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
region = "cn-beijing"
}
]
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_privatezone_record" "app" {
zid = tonumber(volcenginecc_privatezone_private_zone.main.zid)
host = "app"
type = "A"
value = "10.97.1.10"
line = "default"
ttl = 600
enable = true
remark = "app"
}
output "vpc_id" {
value = volcenginecc_vpc_vpc.main.vpc_id
}
output "private_zone_id" {
value = volcenginecc_privatezone_private_zone.main.zid
}
output "private_record_id" {
value = volcenginecc_privatezone_record.app.record_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "rabbitmq_password" {
type = string
sensitive = true
}
locals {
project = "default"
prefix = "cc-iac-rabbit"
zone_id = "cn-beijing-a"
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc RabbitMQ example VPC"
cidr_block = "10.98.0.0/16"
enable_ipv_6 = false
project_name = local.project
}
resource "volcenginecc_vpc_subnet" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet"
description = "volcenginecc RabbitMQ example subnet"
cidr_block = "10.98.1.0/24"
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc RabbitMQ example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.main.subnet_id]
}
resource "volcenginecc_rabbitmq_allow_list" "app" {
allow_list_type = "IPv4"
allow_list = "10.98.0.0/16"
allow_list_name = "${local.prefix}-allow"
}
resource "volcenginecc_rabbitmq_instance" "main" {
zone_id = local.zone_id
user_name = "ccrabbituser"
user_password = var.rabbitmq_password
compute_spec = "rabbitmq.n1.x4.small"
version = "3.12"
storage_space = 100
instance_description = "volcenginecc RabbitMQ example instance"
instance_name = "${local.prefix}-instance"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
subnet_id = volcenginecc_vpc_subnet.main.subnet_id
project_name = local.project
charge_detail = {
charge_type = "PostPaid"
}
depends_on = [volcenginecc_vpc_route_table.app]
}
output "instance_id" {
value = volcenginecc_rabbitmq_instance.main.instance_id
}
output "allow_list_id" {
value = volcenginecc_rabbitmq_allow_list.app.allow_list_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
time = {
source = "hashicorp/time"
version = "~> 0.12"
}
}
}
provider "volcenginecc" {}
variable "mssql_password" {
type = string
sensitive = true
description = "Password for the SQL Server super account. This still lands in Terraform state."
}
locals {
project = "default"
prefix = "cc-iac-mssql"
zone = "cn-beijing-a"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc RDS SQL Server example VPC"
cidr_block = "10.98.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone
subnet_name = "${local.prefix}-subnet"
description = "volcenginecc RDS SQL Server example subnet"
cidr_block = "10.98.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc RDS SQL Server example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.main.subnet_id]
tags = local.tags
}
resource "time_sleep" "network_release_delay" {
depends_on = [
volcenginecc_rdsmssql_allow_list.app,
volcenginecc_vpc_route_table.main,
]
create_duration = "60s"
destroy_duration = "60s"
}
resource "volcenginecc_rdsmssql_allow_list" "app" {
project_name = local.project
allow_list_name = "${local.prefix}-allow"
allow_list_desc = "volcenginecc RDS SQL Server example allowlist"
allow_list_type = "IPv4"
allow_list_category = "Ordinary"
user_allow_list = "10.98.0.0/16"
}
resource "volcenginecc_rdsmssql_instance" "main" {
node_spec = "rds.mssql.3il.x8.medium.s1"
zone_id = local.zone
subnet_id = volcenginecc_vpc_subnet.main.subnet_id
db_engine_version = "SQLServer_2019_Std"
instance_type = "Basic"
storage_space = 20
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
instance_name = "${local.prefix}-instance"
super_account_password = var.mssql_password
server_collation = "Chinese_PRC_CI_AS"
time_zone = "China Standard Time"
project_name = local.project
maintenance_time = "18:00Z-21:59Z"
allow_list_ids = [volcenginecc_rdsmssql_allow_list.app.allow_list_id]
charge_info = {
charge_type = "PostPaid"
}
depends_on = [
time_sleep.network_release_delay,
]
}
output "instance_id" {
value = volcenginecc_rdsmssql_instance.main.instance_id
}
output "allow_list_id" {
value = volcenginecc_rdsmssql_allow_list.app.allow_list_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "mysql_password" {
type = string
sensitive = true
description = "Password for the MySQL super account and example app account."
}
locals {
project = "default"
prefix = "cc-iac-mysql"
zone = "cn-beijing-a"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc RDS MySQL example VPC"
cidr_block = "10.94.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone
subnet_name = "${local.prefix}-subnet"
description = "volcenginecc RDS MySQL example subnet"
cidr_block = "10.94.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc RDS MySQL example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.main.subnet_id]
tags = local.tags
}
resource "volcenginecc_rdsmysql_allow_list" "app" {
allow_list_name = "${local.prefix}-allow"
allow_list_type = "IPv4"
user_allow_list = ["10.94.0.0/16"]
project_name = local.project
}
resource "volcenginecc_rdsmysql_parameter_template" "app" {
template_name = "${local.prefix}-params"
template_type = "Mysql"
template_type_version = "MySQL_5_7"
engine_type = "InnoDB"
template_desc = "volcenginecc RDS MySQL example parameter template"
project_name = local.project
template_params = [
{
name = "auto_increment_increment"
running_value = "1"
}
]
}
resource "volcenginecc_rdsmysql_instance" "main" {
deletion_protection = "Disabled"
db_engine_version = "MySQL_5_7"
storage_type = "CloudESSD_PL0"
storage_space = 100
instance_type = "DoubleNode"
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
subnet_id = volcenginecc_vpc_subnet.main.subnet_id
instance_name = "${local.prefix}-instance"
super_account_name = "adminuser"
super_account_password = var.mysql_password
lower_case_table_names = "1"
db_time_zone = "UTC +08:00"
allow_list_ids = [volcenginecc_rdsmysql_allow_list.app.allow_list_id]
port = 3306
project_name = local.project
tags = local.tags
charge_detail = {
charge_type = "PostPaid"
auto_renew = false
number = 1
}
nodes = [
{
zone_id = local.zone
node_spec = "rds.mysql.c.s.1c2g"
node_type = "Primary"
},
{
zone_id = local.zone
node_spec = "rds.mysql.c.s.1c2g"
node_type = "Secondary"
}
]
depends_on = [
volcenginecc_vpc_route_table.main,
]
}
resource "volcenginecc_rdsmysql_database" "app" {
instance_id = volcenginecc_rdsmysql_instance.main.instance_id
name = "appdb"
character_set_name = "utf8mb4"
description = "volcenginecc RDS MySQL example database"
}
resource "volcenginecc_rdsmysql_db_account" "app" {
instance_id = volcenginecc_rdsmysql_instance.main.instance_id
account_name = "appuser"
account_password = var.mysql_password
account_type = "Normal"
account_desc = "volcenginecc RDS MySQL example app account"
host = "%"
account_privileges = [
{
account_privilege = "Custom"
account_privilege_detail = ["SELECT", "INSERT", "UPDATE", "DELETE"]
db_name = volcenginecc_rdsmysql_database.app.name
},
{
account_privilege = "Global"
account_privilege_detail = ["PROCESS", "REPLICATION CLIENT", "REPLICATION SLAVE"]
db_name = ""
}
]
}
output "instance_id" {
value = volcenginecc_rdsmysql_instance.main.instance_id
}
output "allow_list_id" {
value = volcenginecc_rdsmysql_allow_list.app.allow_list_id
}
output "parameter_template_id" {
value = volcenginecc_rdsmysql_parameter_template.app.template_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "postgres_password" {
type = string
sensitive = true
description = "Password for the PostgreSQL application account."
}
locals {
project = "default"
prefix = "cc-iac-pg"
zone = "cn-beijing-a"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc RDS PostgreSQL example VPC"
cidr_block = "10.95.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone
subnet_name = "${local.prefix}-subnet"
description = "volcenginecc RDS PostgreSQL example subnet"
cidr_block = "10.95.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc RDS PostgreSQL example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.main.subnet_id]
tags = local.tags
}
resource "volcenginecc_rdspostgresql_allow_list" "app" {
allow_list_name = "${local.prefix}-allow"
allow_list_type = "IPv4"
user_allow_list = "10.95.0.0/16"
}
resource "volcenginecc_rdspostgresql_instance" "main" {
db_engine_version = "PostgreSQL_14"
storage_type = "LocalSSD"
storage_space = 100
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
subnet_id = volcenginecc_vpc_subnet.main.subnet_id
instance_name = "${local.prefix}-instance"
project_name = local.project
allow_list_ids = [volcenginecc_rdspostgresql_allow_list.app.allow_list_id]
tags = local.tags
charge_detail = {
charge_type = "PostPaid"
}
node_info = [
{
zone_id = local.zone
node_spec = "rds.postgres.1c2g"
node_type = "Primary"
},
{
zone_id = local.zone
node_spec = "rds.postgres.1c2g"
node_type = "Secondary"
}
]
depends_on = [
volcenginecc_vpc_route_table.main,
]
}
resource "volcenginecc_rdspostgresql_db_account" "app" {
instance_id = volcenginecc_rdspostgresql_instance.main.instance_id
account_name = "appuser"
account_password = var.postgres_password
account_type = "Normal"
account_privileges = "Inherit,Login"
}
resource "volcenginecc_rdspostgresql_database" "app" {
instance_id = volcenginecc_rdspostgresql_instance.main.instance_id
db_name = "appdb"
character_set_name = "utf8"
collate = "C"
c_type = "C"
owner = volcenginecc_rdspostgresql_db_account.app.account_name
}
resource "volcenginecc_rdspostgresql_schema" "app" {
instance_id = volcenginecc_rdspostgresql_instance.main.instance_id
db_name = volcenginecc_rdspostgresql_database.app.db_name
schema_name = "appschema"
owner = volcenginecc_rdspostgresql_db_account.app.account_name
}
resource "volcenginecc_rdspostgresql_db_endpoint" "custom" {
instance_id = volcenginecc_rdspostgresql_instance.main.instance_id
endpoint_name = "${local.prefix}-custom"
endpoint_type = "Custom"
nodes = "Primary"
read_write_mode = "ReadWrite"
private_addresses = {
domain_prefix = "cciacpgextra"
dns_visibility = false
port = "5432"
}
}
resource "volcenginecc_rdspostgresql_backup" "manual" {
instance_id = volcenginecc_rdspostgresql_instance.main.instance_id
backup_method = "Logical"
backup_scope = "Database"
backup_description = "volcenginecc PostgreSQL logical backup verification"
backup_meta = [
{
db_name = volcenginecc_rdspostgresql_database.app.db_name
}
]
depends_on = [
volcenginecc_rdspostgresql_database.app,
]
}
output "instance_id" {
value = volcenginecc_rdspostgresql_instance.main.instance_id
}
output "custom_endpoint_id" {
value = volcenginecc_rdspostgresql_db_endpoint.custom.endpoint_id
}
output "backup_id" {
value = volcenginecc_rdspostgresql_backup.manual.backup_id
}
output "allow_list_id" {
value = volcenginecc_rdspostgresql_allow_list.app.allow_list_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "redis_password" {
type = string
sensitive = true
}
locals {
project = "default"
prefix = "cc-iac-redis-pub"
zone_id = "cn-beijing-a"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc Redis public endpoint example VPC"
cidr_block = "10.97.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet"
description = "volcenginecc Redis public endpoint example subnet"
cidr_block = "10.97.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc Redis public endpoint example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
tags = local.tags
}
resource "volcenginecc_vpc_eip" "redis" {
name = "${local.prefix}-eip"
description = "volcenginecc Redis public endpoint example EIP"
isp = "BGP"
billing_type = 2
bandwidth = 1
project_name = local.project
tags = local.tags
}
resource "volcenginecc_redis_allow_list" "app" {
allow_list = "127.0.0.1"
allow_list_name = "${local.prefix}-acl"
allow_list_desc = "volcenginecc Redis public endpoint example allow list"
allow_list_category = "Ordinary"
project_name = local.project
}
resource "volcenginecc_redis_instance" "main" {
instance_name = "${local.prefix}-instance"
project_name = local.project
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
deletion_protection = "disabled"
charge_type = "PostPaid"
engine_version = "6.0"
shard_capacity = 512
shard_number = 1
node_number = 1
sharded_cluster = 0
multi_az = "disabled"
port = 6379
no_auth_mode = "close"
password = var.redis_password
allow_list_ids = [volcenginecc_redis_allow_list.app.allow_list_id]
tags = local.tags
configure_nodes = [
{
az = local.zone_id
}
]
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_redis_endpoint_public_address" "main" {
instance_id = volcenginecc_redis_instance.main.instance_id
eip_id = volcenginecc_vpc_eip.redis.allocation_id
port = 6379
new_address_prefix = "cciacredispub0530"
}
output "instance_id" {
value = volcenginecc_redis_instance.main.instance_id
}
output "public_endpoint_address" {
value = volcenginecc_redis_endpoint_public_address.main.address
}
output "eip_id" {
value = volcenginecc_vpc_eip.redis.allocation_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
variable "redis_password" {
type = string
sensitive = true
}
locals {
project = "default"
prefix = "cc-iac-redis"
zone_id = "cn-beijing-a"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc Redis example VPC"
cidr_block = "10.90.0.0/16"
enable_ipv_6 = false
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_subnet" "primary" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet"
description = "volcenginecc Redis example subnet"
cidr_block = "10.90.1.0/24"
tags = local.tags
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc Redis example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.primary.subnet_id]
tags = local.tags
}
resource "volcenginecc_redis_allow_list" "app" {
allow_list = "127.0.0.1"
allow_list_name = "${local.prefix}-acl"
allow_list_desc = "volcenginecc Redis example allow list"
allow_list_category = "Ordinary"
project_name = local.project
}
resource "volcenginecc_redis_parameter_group" "app" {
engine_version = "6.0"
name = "${local.prefix}-pg"
description = "volcenginecc Redis example parameter group"
param_values = [
{
name = "maxmemory-policy"
value = "allkeys-lru"
}
]
}
resource "volcenginecc_redis_instance" "main" {
instance_name = "${local.prefix}-instance"
project_name = local.project
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
subnet_id = volcenginecc_vpc_subnet.primary.subnet_id
deletion_protection = "disabled"
charge_type = "PostPaid"
engine_version = "6.0"
shard_capacity = 512
shard_number = 1
node_number = 1
sharded_cluster = 0
multi_az = "disabled"
port = 6379
no_auth_mode = "close"
password = var.redis_password
allow_list_ids = [volcenginecc_redis_allow_list.app.allow_list_id]
parameter_group_id = volcenginecc_redis_parameter_group.app.parameter_group_id
tags = local.tags
configure_nodes = [
{
az = local.zone_id
}
]
depends_on = [
volcenginecc_vpc_route_table.app,
]
}
resource "volcenginecc_redis_account" "app" {
instance_id = volcenginecc_redis_instance.main.instance_id
account_name = "appuser"
description = "volcenginecc Redis example account"
password = var.redis_password
role_name = "ReadWrite"
}
output "instance_id" {
value = volcenginecc_redis_instance.main.instance_id
}
output "allow_list_id" {
value = volcenginecc_redis_allow_list.app.allow_list_id
}
output "parameter_group_id" {
value = volcenginecc_redis_parameter_group.app.parameter_group_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-rocket"
zone_id = "cn-beijing-a"
}
resource "volcenginecc_vpc_vpc" "main" {
vpc_name = "${local.prefix}-vpc"
description = "volcenginecc RocketMQ example VPC"
cidr_block = "10.99.0.0/16"
enable_ipv_6 = false
project_name = local.project
}
resource "volcenginecc_vpc_subnet" "main" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
zone_id = local.zone_id
subnet_name = "${local.prefix}-subnet"
description = "volcenginecc RocketMQ example subnet"
cidr_block = "10.99.1.0/24"
}
resource "volcenginecc_vpc_route_table" "app" {
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
route_table_name = "${local.prefix}-rt"
description = "volcenginecc RocketMQ example route table"
project_name = local.project
associate_type = "Subnet"
subnet_ids = [volcenginecc_vpc_subnet.main.subnet_id]
}
resource "volcenginecc_rocketmq_allow_list" "app" {
allow_list_name = "${local.prefix}-allow"
allow_list_type = "IPv4"
allow_list = "10.99.0.0/16"
}
resource "volcenginecc_rocketmq_instance" "main" {
allow_list_ids = [volcenginecc_rocketmq_allow_list.app.allow_list_id]
ip_version_type = "IPv4"
enable_ssl = false
version = "4.8"
zone_id = local.zone_id
compute_spec = "rocketmq.n1.x2.micro"
storage_space = 300
vpc_id = volcenginecc_vpc_vpc.main.vpc_id
subnet_id = volcenginecc_vpc_subnet.main.subnet_id
file_reserved_time = 24
instance_name = "${local.prefix}-instance"
network_types = "PrivateNetwork"
project_name = local.project
instance_description = "volcenginecc RocketMQ example instance"
charge_detail = {
charge_type = "PostPaid"
}
depends_on = [volcenginecc_vpc_route_table.app]
}
resource "volcenginecc_rocketmq_topic" "app" {
instance_id = volcenginecc_rocketmq_instance.main.instance_id
topic_name = "cc-iac-rocket-topic"
message_type = 0
description = "volcenginecc RocketMQ example topic"
queue_number = 4
}
resource "volcenginecc_rocketmq_group" "app" {
instance_id = volcenginecc_rocketmq_instance.main.instance_id
group_id = "GID_cc_iac_rocket"
group_type = "TCP"
description = "volcenginecc RocketMQ example group"
}
output "instance_id" {
value = volcenginecc_rocketmq_instance.main.instance_id
}
output "allow_list_id" {
value = volcenginecc_rocketmq_allow_list.app.allow_list_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
region = "cn-beijing"
prefix = "cc-iac-tls-import"
bucket_name = "cc-iac-tls-import-example"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_tls_project" "main" {
project_name = local.prefix
description = "volcenginecc TLS import task example project"
iam_project_name = local.project
tags = local.tags
}
resource "volcenginecc_tls_topic" "target" {
project_id = volcenginecc_tls_project.main.project_id
topic_name = "${local.prefix}-target"
description = "volcenginecc TLS import task target topic"
shard_count = 1
ttl = 30
auto_split = false
log_public_ip = false
allow_consume = true
tags = local.tags
}
resource "volcenginecc_tls_index" "target" {
topic_id = volcenginecc_tls_topic.target.topic_id
enable_auto_index = false
max_text_len = 2048
full_text = {
case_sensitive = false
delimiter = " ,;:"
include_chinese = true
}
}
resource "volcenginecc_tos_bucket" "source" {
name = local.bucket_name
project_name = local.project
storage_class = "STANDARD"
bucket_type = "fns"
enable_version_status = "Enabled"
tags = local.tags
}
resource "volcenginecc_tls_import_task" "tos" {
task_name = "${local.prefix}-tos"
description = "volcenginecc TLS import task from TOS example"
source_type = "tos"
project_id = volcenginecc_tls_project.main.project_id
topic_id = volcenginecc_tls_topic.target.topic_id
import_source_info = {
tos_source_info = {
bucket = volcenginecc_tos_bucket.source.name
region = local.region
prefix = "logs/"
compress_type = "none"
}
}
target_info = {
region = local.region
log_type = "json_log"
log_sample = "{\"time\":\"2026-05-30 00:00:00\",\"level\":\"info\",\"message\":\"example\"}"
extract_rule = {
extract_rule = {
time_key = "time"
time_format = "%Y-%m-%d %H:%M:%S"
time_sample = "2026-05-30 00:00:00"
un_match_log_key = "LogParseFailed"
un_match_up_load_switch = true
}
time_zone = "Asia/Shanghai"
}
}
depends_on = [
volcenginecc_tls_index.target,
]
}
output "task_id" {
value = volcenginecc_tls_import_task.tos.task_id
}
output "bucket_name" {
value = volcenginecc_tos_bucket.source.name
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-tls-sql"
}
resource "volcenginecc_tls_project" "main" {
project_name = local.prefix
description = "volcenginecc TLS schedule SQL example project"
iam_project_name = local.project
}
resource "volcenginecc_tls_topic" "source" {
project_id = volcenginecc_tls_project.main.project_id
topic_name = "${local.prefix}-source"
description = "volcenginecc TLS schedule SQL source topic"
shard_count = 1
ttl = 30
auto_split = false
log_public_ip = false
allow_consume = false
}
resource "volcenginecc_tls_topic" "dest" {
project_id = volcenginecc_tls_project.main.project_id
topic_name = "${local.prefix}-dest"
description = "volcenginecc TLS schedule SQL destination topic"
shard_count = 1
ttl = 30
auto_split = false
log_public_ip = false
allow_consume = false
}
resource "volcenginecc_tls_index" "source" {
topic_id = volcenginecc_tls_topic.source.topic_id
enable_auto_index = false
max_text_len = 2048
full_text = {
case_sensitive = false
delimiter = " ,;:"
include_chinese = true
}
}
resource "volcenginecc_tls_index" "dest" {
topic_id = volcenginecc_tls_topic.dest.topic_id
enable_auto_index = false
max_text_len = 2048
full_text = {
case_sensitive = false
delimiter = " ,;:"
include_chinese = true
}
}
resource "volcenginecc_tls_schedule_sql_task" "main" {
task_name = "${local.prefix}-task"
description = "volcenginecc TLS schedule SQL example"
task_type = 0
source_topic_id = volcenginecc_tls_topic.source.topic_id
dest_topic_id = volcenginecc_tls_topic.dest.topic_id
dest_region = "cn-beijing"
query = "* | SELECT count(*) AS count"
status = 0
process_start_time = 1780096500
process_end_time = 1780097100
process_sql_delay = 60
process_time_window = "@m-15m,@m"
depends_on = [
volcenginecc_tls_index.source,
volcenginecc_tls_index.dest,
]
request_cycle = {
type = "Period"
time = 15
}
}
output "task_id" {
value = volcenginecc_tls_schedule_sql_task.main.task_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-tls"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_tls_project" "main" {
project_name = local.prefix
description = "volcenginecc TLS example project"
iam_project_name = local.project
tags = local.tags
}
resource "volcenginecc_tls_topic" "app" {
project_id = volcenginecc_tls_project.main.project_id
topic_name = "${local.prefix}-topic"
description = "volcenginecc TLS example topic"
shard_count = 1
ttl = 30
auto_split = false
log_public_ip = false
allow_consume = true
tags = local.tags
}
resource "volcenginecc_tls_index" "app" {
topic_id = volcenginecc_tls_topic.app.topic_id
enable_auto_index = false
max_text_len = 2048
full_text = {
case_sensitive = false
delimiter = " ,;:"
include_chinese = true
}
key_value = [
{
key = "level"
value = {
auto_index_flag = false
case_sensitive = false
delimiter = " ,;:"
include_chinese = false
index_all = false
index_sql_all = false
sql_flag = true
value_type = "text"
}
}
]
}
resource "volcenginecc_tls_rule" "host_file" {
topic_id = volcenginecc_tls_topic.app.topic_id
rule_name = "${local.prefix}-host-file"
input_type = 0
log_type = "minimalist_log"
paths = ["/var/log/messages"]
}
resource "volcenginecc_tls_consumer_group" "app" {
project_id = volcenginecc_tls_project.main.project_id
topic_id_list = [volcenginecc_tls_topic.app.topic_id]
consumer_group_name = "${local.prefix}-consumer-group"
heartbeat_ttl = 10
ordered_consume = false
}
output "project_id" {
value = volcenginecc_tls_project.main.project_id
}
output "topic_id" {
value = volcenginecc_tls_topic.app.topic_id
}
output "rule_id" {
value = volcenginecc_tls_rule.host_file.rule_id
}
output "consumer_group_id" {
value = volcenginecc_tls_consumer_group.app.id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-tos-noti"
bucket_name = "cc-iac-tos-noti-example"
# ZIP containing a root-level index.py with:
# def handler(event, context):
# return {"statusCode": 200, "headers": {"Content-Type": "application/json"}, "body": "{\"ok\": true}"}
function_zip_base64 = "UEsDBBQAAAAIAAQWvlwiFdCVfgAAAKYAAAAIABwAaW5kZXgucHlVVAkAA2jfGWpo3xlqdXgLAAEE9QEAAAQAAAAATYwxDsIwDEX3niLyBFIRFWPXXoGxS6iNWqjsKHEqqih3J4EB3mT//2yku5kt40r+QBuxtmYSVnrpsW9MwZNGzyZ9lgoEtRrDIEjQm0vXtb9qJovkQ8kTDPUN6+m6uyqCdW5dJquL8PkRhCH/Hd4E9yqlEeQ5lkl9pAxfIzdvUEsBAh4DFAAAAAgABBa+XCIV0JV+AAAApgAAAAgAGAAAAAAAAQAAAKSBAAAAAGluZGV4LnB5VVQFAANo3xlqdXgLAAEE9QEAAAQAAAAAUEsFBgAAAAABAAEATgAAAMAAAAAAAA=="
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_tos_bucket" "main" {
name = local.bucket_name
project_name = local.project
storage_class = "STANDARD"
bucket_type = "fns"
enable_version_status = "Enabled"
tags = local.tags
}
resource "volcenginecc_vefaas_function" "target" {
name = "${local.prefix}-function"
description = "volcenginecc TOS notification target function"
runtime = "python3.9/v1"
source_type = "zip"
source = local.function_zip_base64
memory_mb = 512
request_timeout = 30
max_concurrency = 10
exclusive_mode = false
enable_apmplus = false
enable_dependency_install = false
project_name = local.project
tags = local.tags
lifecycle {
ignore_changes = [
source_type,
]
}
}
resource "volcenginecc_vefaas_release" "target" {
function_id = volcenginecc_vefaas_function.target.function_id
revision_number = 0
target_traffic_weight = 100
rolling_step = 100
description = "volcenginecc TOS notification function release"
max_instance = 1
}
resource "volcenginecc_tos_bucket_notification" "main" {
bucket_name = volcenginecc_tos_bucket.main.name
notification_rules = [
{
rule_id = "object-created-vefaas"
events = ["tos:ObjectCreated:Put"]
destination = {
ve_faa_s = [
{
function_id = volcenginecc_vefaas_function.target.function_id
}
]
}
filter = {
tos_key = {
filter_rules = [
{
name = "prefix"
value = "events/"
}
]
}
}
}
]
depends_on = [
volcenginecc_vefaas_release.target,
]
}
output "bucket_name" {
value = volcenginecc_tos_bucket.main.name
}
output "function_id" {
value = volcenginecc_vefaas_function.target.function_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
bucket_name = "cc-iac-tos-example"
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_tos_bucket" "main" {
name = local.bucket_name
project_name = local.project
storage_class = "STANDARD"
bucket_type = "fns"
enable_version_status = "Enabled"
tags = local.tags
}
resource "volcenginecc_tos_bucket_cors" "main" {
bucket_name = volcenginecc_tos_bucket.main.name
cors_rules = [
{
allowed_origins = ["https://example.com"]
allowed_methods = ["GET", "PUT"]
allowed_headers = ["Content-Type", "Authorization"]
expose_headers = ["x-tos-request-id"]
max_age_seconds = 3600
response_vary = true
}
]
}
resource "volcenginecc_tos_bucket_encryption" "main" {
name = volcenginecc_tos_bucket.main.name
sse_algorithm = "AES256"
}
output "bucket_name" {
value = volcenginecc_tos_bucket.main.name
}
output "intranet_endpoint" {
value = volcenginecc_tos_bucket.main.intranet_endpoint
}
output "extranet_endpoint" {
value = volcenginecc_tos_bucket.main.extranet_endpoint
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-tr"
}
resource "volcenginecc_transitrouter_transit_router" "main" {
transit_router_name = "${local.prefix}-router"
description = "volcenginecc TransitRouter example"
asn = 64512
multicast_enabled = false
project_name = local.project
}
output "transit_router_id" {
value = volcenginecc_transitrouter_transit_router.main.transit_router_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-vefaas"
# ZIP containing a root-level index.py with:
# def handler(event, context):
# return {"statusCode": 200, "headers": {"Content-Type": "application/json"}, "body": "{\"ok\": true}"}
function_zip_base64 = "UEsDBBQAAAAIAAQWvlwiFdCVfgAAAKYAAAAIABwAaW5kZXgucHlVVAkAA2jfGWpo3xlqdXgLAAEE9QEAAAQAAAAATYwxDsIwDEX3niLyBFIRFWPXXoGxS6iNWqjsKHEqqih3J4EB3mT//2yku5kt40r+QBuxtmYSVnrpsW9MwZNGzyZ9lgoEtRrDIEjQm0vXtb9qJovkQ8kTDPUN6+m6uyqCdW5dJquL8PkRhCH/Hd4E9yqlEeQ5lkl9pAxfIzdvUEsBAh4DFAAAAAgABBa+XCIV0JV+AAAApgAAAAgAGAAAAAAAAQAAAKSBAAAAAGluZGV4LnB5VVQFAANo3xlqdXgLAAEE9QEAAAQAAAAAUEsFBgAAAAABAAEATgAAAMAAAAAAAA=="
tags = [
{
key = "purpose"
value = "terraform-volcenginecc-example"
}
]
}
resource "volcenginecc_vefaas_function" "main" {
name = "${local.prefix}-function"
description = "volcenginecc veFaaS example function"
runtime = "python3.9/v1"
source_type = "zip"
source = local.function_zip_base64
memory_mb = 512
request_timeout = 30
max_concurrency = 10
exclusive_mode = false
enable_apmplus = false
enable_dependency_install = false
project_name = local.project
envs = [
{
key = "EXAMPLE_MODE"
value = "terraform"
}
]
tags = local.tags
lifecycle {
ignore_changes = [
source_type,
]
}
}
resource "volcenginecc_vefaas_release" "main" {
function_id = volcenginecc_vefaas_function.main.function_id
revision_number = 0
target_traffic_weight = 100
rolling_step = 100
description = "volcenginecc veFaaS example release"
max_instance = 1
}
resource "volcenginecc_vefaas_timer" "main" {
function_id = volcenginecc_vefaas_release.main.function_id
name = "${replace(local.prefix, "-", "_")}_timer"
description = "volcenginecc veFaaS example disabled timer"
enabled = false
crontab = "*/30 * * * *"
payload = jsonencode({ source = "terraform" })
enable_concurrency = false
retries = 1
}
output "function_id" {
value = volcenginecc_vefaas_function.main.function_id
}
output "release_record_id" {
value = volcenginecc_vefaas_release.main.release_record_id
}
output "timer_id" {
value = volcenginecc_vefaas_timer.main.timer_id
}
terraform {
required_version = ">= 1.0.7"
required_providers {
volcenginecc = {
source = "volcengine/volcenginecc"
version = "~> 0.0.46"
}
}
}
provider "volcenginecc" {}
locals {
project = "default"
prefix = "cc-iac-tmf"
tags = [
{
key = "env"
value = "test"
}
]
}
resource "volcenginecc_vpc_traffic_mirror_filter" "app" {
traffic_mirror_filter_name = local.prefix
description = "volcenginecc traffic mirror filter example"
project_name = local.project
tags = local.tags
}
resource "volcenginecc_vpc_traffic_mirror_filter_rule" "ingress_http" {
traffic_mirror_filter_id = volcenginecc_vpc_traffic_mirror_filter.app.traffic_mirror_filter_id
traffic_direction = "ingress"
priority = 100
policy = "accept"
protocol = "tcp"
source_cidr_block = "10.0.0.0/8"
source_port_range = "1/65535"
destination_cidr_block = "10.0.0.0/8"
destination_port_range = "80/80"
description = "Mirror inbound HTTP traffic inside private CIDRs"
}
output "traffic_mirror_filter_id" {
value = volcenginecc_vpc_traffic_mirror_filter.app.traffic_mirror_filter_id
}
output "traffic_mirror_filter_rule_id" {
value = volcenginecc_vpc_traffic_mirror_filter_rule.ingress_http.traffic_mirror_filter_rule_id
}
terraform {
required_version = ">= 1.5"
required_providers {
volcengine = {
source = "volcengine/volcengine"
version = "~> 0.0.196"
}
}
}
resource "volcengine_cr_registry" "main" {
name = var.registry_name
type = var.registry_type
}
resource "volcengine_cr_namespace" "main" {
registry = volcengine_cr_registry.main.name
name = var.namespace
project = var.project
}
resource "volcengine_cr_repository" "main" {
registry = volcengine_cr_registry.main.name
namespace = volcengine_cr_namespace.main.name
name = var.repository_name
access_level = var.access_level
description = "Managed by volcengine-iac for project ${var.project}"
}
Related skills
AI & Agent Buildingagents