[root@s22222 5]# ls *.tf main.tf nat1.tf variables.tf versions.tf [root@s22222 5]# [root@s22222 5]# [root@s22222 5]# more *.tf :::::::::::::: main.tf :::::::::::::: # VPC > User scenario > Scenario 1. Single Public Subnet # https://docs.ncloud.com/ko/networking/vpc/vpc_userscenario1.html provider "ncloud" { support_vpc = true region = "KR" access_key = var.access_key secret_key = var.secret_key } resource "ncloud_login_key" "key_vpc" { key_name = var.name_vpc } resource "ncloud_vpc" "vpc_vpc" { name = var.name_vpc ipv4_cidr_block = "10.0.0.0/21" } resource "ncloud_subnet" "subnet_pri1" { name = var.name_pri1 vpc_no = ncloud_vpc.vpc_vpc.id subnet = cidrsubnet(ncloud_vpc.vpc_vpc.ipv4_cidr_block,2 ,0 ) zone = "KR-1" network_acl_no = ncloud_vpc.vpc_vpc.default_network_acl_no subnet_type = "PRIVATE" // PUBLIC(Public) | PRIVATE(Private) } resource "ncloud_subnet" "subnet_pub1" { name = var.name_pub1 vpc_no = ncloud_vpc.vpc_vpc.id subnet = cidrsubnet(ncloud_vpc.vpc_vpc.ipv4_cidr_block,3 , 2) zone = "KR-1" network_acl_no = ncloud_vpc.vpc_vpc.default_network_acl_no subnet_type = "PUBLIC" // PUBLIC(Public) | PRIVATE(Private) } resource "ncloud_subnet" "subnet_pri-db1" { name = var.name_pri-db1 vpc_no = ncloud_vpc.vpc_vpc.id subnet = cidrsubnet(ncloud_vpc.vpc_vpc.ipv4_cidr_block,3 , 3) zone = "KR-1" network_acl_no = ncloud_vpc.vpc_vpc.default_network_acl_no subnet_type = "PRIVATE" // PUBLIC(Public) | PRIVATE(Private) } resource "ncloud_subnet" "subnet_pub-nat1" { name = var.name_pub-nat1 vpc_no = ncloud_vpc.vpc_vpc.id subnet = cidrsubnet(ncloud_vpc.vpc_vpc.ipv4_cidr_block,3 , 4) zone = "KR-1" network_acl_no = ncloud_vpc.vpc_vpc.default_network_acl_no subnet_type = "PUBLIC" usage_type = "NATGW" // PUBLIC(Public) | PRIVATE(Private) } resource "ncloud_subnet" "subnet_pub-lb1" { name = var.name_pub-lb1 vpc_no = ncloud_vpc.vpc_vpc.id subnet = cidrsubnet(ncloud_vpc.vpc_vpc.ipv4_cidr_block,3 , 5) zone = "KR-1" network_acl_no = ncloud_vpc.vpc_vpc.default_network_acl_no subnet_type = "PUBLIC" usage_type = "LOADB" // PUBLIC(Public) | PRIVATE(Private) } resource "ncloud_subnet" "subnet_pri-lb1" { name = var.name_pri-lb1 vpc_no = ncloud_vpc.vpc_vpc.id subnet = cidrsubnet(ncloud_vpc.vpc_vpc.ipv4_cidr_block,3 , 6) zone = "KR-1" network_acl_no = ncloud_vpc.vpc_vpc.default_network_acl_no subnet_type = "PRIVATE" // PUBLIC(Public) | PRIVATE(Private) usage_type = "LOADB" } :::::::::::::: nat1.tf :::::::::::::: # NAT Gateway resource "ncloud_nat_gateway" "nat_gateway_scn_02" { vpc_no = ncloud_vpc.vpc_vpc.id subnet_no = ncloud_subnet.subnet_pub-nat1.id zone = "KR-1" name = var.name_pub-nat1 } # Route Table resource "ncloud_route" "route_scn_02_nat" { route_table_no = ncloud_vpc.vpc_vpc.default_private_route_table_no destination_cidr_block = "0.0.0.0/0" target_type = "NATGW" // NATGW (NAT Gateway) | VPCPEERING (VPC Peering) | VGW (Virtual Private Gateway). target_name = ncloud_nat_gateway.nat_gateway_scn_02.name target_no = ncloud_nat_gateway.nat_gateway_scn_02.id } :::::::::::::: variables.tf :::::::::::::: variable name_vpc { default = "agame-dev-vpc" } variable name_pri1 { default = "agame-dev-pri1" } variable name_pub1 { default = "agame-dev-pub1" } variable name_pri-db1 { default = "agame-dev-pri-db1" } variable name_pub-nat1 { default = "agame-dev-pub-nat1" } variable name_pub-lb1 { default = "agame-dev-pub-lb1" } variable name_pri-lb1 { default = "agame-dev-pri-lb1" } variable client_ip { default = "3.3.3.3" } variable access_key { default = "ncp_iam_BPAMKR5XsAr52VzPluqr" } variable secret_key { default = "ncp_iam_BPKMKR1DwyNq8NImKqZpe759MRZ3F6aeKD" } variable nks_version { default = "1.28" } variable name_scn_02 { default = "tf-scn02" } :::::::::::::: versions.tf :::::::::::::: terraform { required_providers { ncloud = { source = "navercloudplatform/ncloud" } } required_version = ">= 0.13" } [root@s22222 5]#