From 51d2505a1fdf3b2ff2c4a2bbf44b48dad26d19f7 Mon Sep 17 00:00:00 2001 From: Seong-dong Date: Wed, 28 Dec 2022 14:24:56 +0900 Subject: [PATCH] =?UTF-8?q?=ED=85=8C=EB=9D=BC=ED=8F=BC=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=ED=8C=8C=EC=9D=BC=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + modules/vpc-subnet/main.tf | 2 +- {prod => prod-hq-bak}/.terraform.lock.hcl | 0 prod-hq/.terraformrc | 1 + {prod => prod-hq}/main.tf | 27 +++++++++++++++++++---- {prod => prod-hq}/outputs.tf | 0 {prod => prod-hq}/valiables.tf | 0 7 files changed, 26 insertions(+), 5 deletions(-) rename {prod => prod-hq-bak}/.terraform.lock.hcl (100%) create mode 100644 prod-hq/.terraformrc rename {prod => prod-hq}/main.tf (73%) rename {prod => prod-hq}/outputs.tf (100%) rename {prod => prod-hq}/valiables.tf (100%) diff --git a/.gitignore b/.gitignore index 7a3e2fd..0d61624 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ override.tf.json # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan # example: *tfplan* +**/.teraformmrc diff --git a/modules/vpc-subnet/main.tf b/modules/vpc-subnet/main.tf index 6520781..5a9843a 100644 --- a/modules/vpc-subnet/main.tf +++ b/modules/vpc-subnet/main.tf @@ -6,7 +6,7 @@ resource "aws_subnet" "subnets" { availability_zone = each.value.name cidr_block = each.value.cidr - map_public_ip_on_launch = var.public_ip_on + map_public_ip_on_launch = var.public_ip_on ? true : false tags = { Name = var.vpc_name diff --git a/prod/.terraform.lock.hcl b/prod-hq-bak/.terraform.lock.hcl similarity index 100% rename from prod/.terraform.lock.hcl rename to prod-hq-bak/.terraform.lock.hcl diff --git a/prod-hq/.terraformrc b/prod-hq/.terraformrc new file mode 100644 index 0000000..30d74d2 --- /dev/null +++ b/prod-hq/.terraformrc @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/prod/main.tf b/prod-hq/main.tf similarity index 73% rename from prod/main.tf rename to prod-hq/main.tf index 98579f2..e8e7bfa 100644 --- a/prod/main.tf +++ b/prod-hq/main.tf @@ -1,5 +1,15 @@ // prod - main +terraform { + backend "remote"{ + hostname = "app.terraform.io" + organization = "22shop" + workspaces { + name = "tf-cloud-backend" + } + } + +} provider "aws" { region = "ap-northeast-2" @@ -8,19 +18,28 @@ provider "aws" { } +locals { + common_tags = { + project = "22shop" + owner = "icurfer" + + } +} # module "vpc_hq" { module "vpc_hq" { source = "../modules/vpc" # source = "github.com/Seong-dong/team_prj/tree/main/modules/vpc" - tag_name = var.prod_name + tag_name = "${local.common_tags.project}-vpc" cidr_block = "10.3.0.0/16" } module "vpc_igw" { source = "../modules/igw" - tag_name = var.prod_name + vpc_id = module.vpc_hq.vpc_hq_id + + tag_name = "${local.common_tags.project}-vpc_igw" } module "subnet_public" { @@ -29,13 +48,13 @@ module "subnet_public" { vpc_id = module.vpc_hq.vpc_hq_id subnet-az-list = var.subnet-az-list public_ip_on = true - vpc_name = "${module.vpc_hq.vpc_name}-public" + vpc_name = "${local.common_tags.project}-public" } // public route module "route_public" { source = "../modules/route-table" - tag_name = var.prod_name + tag_name = "${local.common_tags.project}-route_table" vpc_id = module.vpc_hq.vpc_hq_id } diff --git a/prod/outputs.tf b/prod-hq/outputs.tf similarity index 100% rename from prod/outputs.tf rename to prod-hq/outputs.tf diff --git a/prod/valiables.tf b/prod-hq/valiables.tf similarity index 100% rename from prod/valiables.tf rename to prod-hq/valiables.tf