Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/cd_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
aws_secret_access_key = "${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}"
rds_username = "${{ secrets.RDS_USERNAME }}"
rds_password = "${{ secrets.RDS_PASSWORD }}"
domain_name = "${{ secrets.DEV_DOMAIN_NAME }}"
EOF

- name: Terraform Apply (dev)
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/cd_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
aws_secret_access_key = "${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }}"
rds_username = "${{ secrets.RDS_USERNAME }}"
rds_password = "${{ secrets.RDS_PASSWORD }}"
domain_name = "${{ secrets.PROD_DOMAIN_NAME }}"
EOF

- name: Terraform Apply (prod)
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
aws_secret_access_key = "${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}"
rds_username = "${{ secrets.RDS_USERNAME }}"
rds_password = "${{ secrets.RDS_PASSWORD }}"
domain_name = "${{ secrets.DEV_DOMAIN_NAME }}"
EOF

- name: Terraform Plan (dev)
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
aws_secret_access_key = "${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }}"
rds_username = "${{ secrets.RDS_USERNAME }}"
rds_password = "${{ secrets.RDS_PASSWORD }}"
domain_name = "${{ secrets.PROD_DOMAIN_NAME }}"
EOF

- name: Terraform Plan (prod)
Expand Down
7 changes: 0 additions & 7 deletions terraform/env/dev/compute.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,3 @@ module "ec2" {
user_data = local.user_data_base64
}

# ALB Target Group ์ถ”๊ฐ€
resource "aws_lb_target_group_attachment" "ec2" {
target_group_arn = module.alb.target_group_arn
target_id = module.ec2.instance_id
port = 80
}

3 changes: 0 additions & 3 deletions terraform/env/dev/example.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ availability_zone = "ap-northeast-2a"
# RDS Configuration
rds_username = "admin" # ์‹ค์ œ ํ™˜๊ฒฝ์—์„œ๋Š” ๋” ๋ณต์žกํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ ์‚ฌ์šฉ

# Route53 Configuration
# hosted_zone_id = "YOUR_HOSTED_ZONE_ID" # ๋„๋ฉ”์ธ์˜ hosted zone ID
# domain_name = "yourdomain.com" # ์‹ค์ œ ๋„๋ฉ”์ธ์œผ๋กœ ๋ณ€๊ฒฝ
124 changes: 14 additions & 110 deletions terraform/env/dev/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,20 @@ module "sg_ec2" {

ingress_rules = [
{
from_port = 80
to_port = 80
protocol = "tcp"
use_cidr = false
use_sg = true
source_security_group_id = module.sg_alb.security_group_id
from_port = 80
to_port = 80
protocol = "tcp"
use_cidr = true
use_sg = false
cidr_blocks = ["0.0.0.0/0"]
},
{
from_port = 443
to_port = 443
protocol = "tcp"
use_cidr = true
use_sg = false
cidr_blocks = ["0.0.0.0/0"]
},
{
from_port = 22
Expand Down Expand Up @@ -159,107 +167,3 @@ module "sg_rds" {
]
}

# ALB Security Group
module "sg_alb" {
source = "../../modules/security/security_group"
vpc_id = module.vpc.vpc_id

environment = local.environment
purpose = "alb"
security_group_name = "${local.name_prefix}-sg-alb"

ingress_rules = [
{
from_port = 80
to_port = 80
protocol = "tcp"
use_cidr = true
use_sg = false
cidr_blocks = ["0.0.0.0/0"]
},
{
from_port = 443
to_port = 443
protocol = "tcp"
use_cidr = true
use_sg = false
cidr_blocks = ["0.0.0.0/0"]
}
]

egress_rules = [
{
from_port = 0
to_port = 0
protocol = "-1"
use_cidr = true
use_sg = false
cidr_blocks = ["0.0.0.0/0"]
}
]
}

# ACM Certificate (1๋‹จ๊ณ„: ์ธ์ฆ์„œ๋งŒ ์ƒ์„ฑ, ๊ฒ€์ฆ์€ ๋‚˜์ค‘์—)
module "acm" {
source = "../../modules/network/acm"

name_prefix = local.name_prefix
domain_name = var.domain_name
hosted_zone_id = module.route53_zone.hosted_zone_id
create_validation = false # 1๋‹จ๊ณ„์—์„œ๋Š” ๊ฒ€์ฆ ๋น„ํ™œ์„ฑํ™”

tags = local.common_tags
}

# Application Load Balancer
module "alb" {
source = "../../modules/network/alb"

name_prefix = local.name_prefix
internal = false
security_groups = [module.sg_alb.security_group_id]
subnet_ids = [module.subnet_public_a.subnet_id, module.subnet_public_c.subnet_id]
vpc_id = module.vpc.vpc_id

target_group_port = 80
target_group_protocol = "HTTP"

health_check_path = "/health"
health_check_matcher = "200"

# HTTPS ๋ฆฌ์Šค๋„ˆ ๋น„ํ™œ์„ฑํ™” (์ธ์ฆ์„œ ๊ฒ€์ฆ ์™„๋ฃŒ ํ›„ ํ™œ์„ฑํ™”)
create_https_listener = false
certificate_arn = null

tags = local.common_tags
}

# Route53 - Hosted Zone ์ƒ์„ฑ
module "route53_zone" {
source = "../../modules/network/route53"

# ์ƒˆ๋กœ์šด hosted zone ์ƒ์„ฑ
create_hosted_zone = true
domain_name = var.domain_name
create_a_record = false

tags = local.common_tags
}

# Route53 - ALB๋ฅผ A ๋ ˆ์ฝ”๋“œ๋กœ ์„ค์ • (ALB ์ƒ์„ฑ ํ›„)
module "route53_record" {
source = "../../modules/network/route53"

# ๊ธฐ์กด hosted zone ์‚ฌ์šฉ
create_hosted_zone = false
hosted_zone_id = module.route53_zone.hosted_zone_id

# A ๋ ˆ์ฝ”๋“œ ์ƒ์„ฑ (ALB๋กœ ๋ณ€๊ฒฝ)
create_a_record = true
record_name = "${local.environment}.${var.domain_name}"
target_alias = module.alb.load_balancer_dns_name
target_zone_id = module.alb.load_balancer_zone_id
ttl = 300

depends_on = [module.alb]
}
3 changes: 0 additions & 3 deletions terraform/env/dev/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ availability_zone = "ap-northeast-2a"
# RDS ์„ค์ • (๊ธฐ๋ณธ๊ฐ’ - ๋ฏผ๊ฐํ•œ ์ •๋ณด๋Š” secret.tfvars์—์„œ ๊ด€๋ฆฌ)
# rds_username์€ secret.tfvars์—์„œ ๊ด€๋ฆฌ

# Route53 ์„ค์ • (๊ธฐ๋ณธ๊ฐ’ - ๋ฏผ๊ฐํ•œ ์ •๋ณด๋Š” secret.tfvars์—์„œ ๊ด€๋ฆฌ)
# domain_name์€ secret.tfvars์—์„œ ๊ด€๋ฆฌ

# User Data (๊ธฐ๋ณธ๊ฐ’ - ๋ฏผ๊ฐํ•œ ์ •๋ณด๋Š” secret.tfvars์—์„œ ๊ด€๋ฆฌ)
# userdata๋Š” locals.tf์—์„œ filebase64() ํ•จ์ˆ˜๋กœ ๋กœ๋“œ๋จ
7 changes: 0 additions & 7 deletions terraform/env/dev/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,3 @@ variable "rds_password" {
sensitive = true
}

# Route53 ์„ค์ • (๋„๋ฉ”์ธ ๊ด€๋ จ)
variable "domain_name" {
description = "Base domain name for Route53 records"
type = string
default = "example.com"
sensitive = true
}
10 changes: 0 additions & 10 deletions terraform/env/prod/compute.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,10 @@ module "ec2" {
root_volume_type = "gp3"
root_volume_encrypted = true

# ์ข…๋ฃŒ ๋ณดํ˜ธ ํ™œ์„ฑํ™” (ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ)
disable_api_termination = true

# ์ข…๋ฃŒ ์‹œ ์ค‘์ง€ (์‚ญ์ œํ•˜์ง€ ์•Š์Œ)
instance_initiated_shutdown_behavior = "stop"

# ์‚ฌ์šฉ์ž ๋ฐ์ดํ„ฐ (locals์—์„œ ๋กœ๋“œ๋œ base64 ์ธ์ฝ”๋”ฉ๋œ ์Šคํฌ๋ฆฝํŠธ)
user_data = local.user_data_base64
}

# ALB Target Group ์ถ”๊ฐ€
resource "aws_lb_target_group_attachment" "ec2" {
target_group_arn = module.alb.target_group_arn
target_id = module.ec2.instance_id
port = 80
}

18 changes: 9 additions & 9 deletions terraform/env/prod/database.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ module "rds" {
module.subnet_private_a.subnet_id,
module.subnet_private_c.subnet_id
]
storage = 50
storage = 30
engine = "mysql"
engine_version = "8.0.42"
instance_class = "db.t3.small"
instance_class = "db.t3.micro"
db_name = "clokey_db"
username = var.rds_username
password = var.rds_password
Expand All @@ -21,24 +21,24 @@ module "rds" {
publicly_accessible = false # ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท์— ์œ„์น˜ํ•˜๋ฏ€๋กœ false

# ๋ฐฑ์—… ์„ค์ •
backup_retention_period = 30 # ํ”„๋กœ๋•์…˜์—์„œ๋Š” 30์ผ ๋ณด๊ด€
backup_window = "02:00-03:00"
maintenance_window = "sun:02:00-sun:03:00"
backup_retention_period = 7
backup_window = "03:00-04:00"
maintenance_window = "sun:04:00-sun:05:00"

# ์„ฑ๋Šฅ ์„ค์ •
multi_az = true # ํ”„๋กœ๋•์…˜์—์„œ๋Š” Multi-AZ ํ™œ์„ฑํ™”
multi_az = false
storage_type = "gp3"
storage_encrypted = true

# ๋ณด์•ˆ ์„ค์ •
deletion_protection = true # ํ”„๋กœ๋•์…˜์—์„œ๋Š” ์‚ญ์ œ ๋ณดํ˜ธ ํ™œ์„ฑํ™”
deletion_protection = false

# ํŒŒ๋ผ๋ฏธํ„ฐ ๊ทธ๋ฃน ์„ค์ • (์„ ํƒ์ )
# ํŒŒ๋ผ๋ฏธํ„ฐ ๊ทธ๋ฃน ์„ค์ •
parameter_group_family = "mysql8.0"
parameter_group_parameters = [
{
name = "max_connections"
value = "200"
value = "100"
},
{
name = "innodb_buffer_pool_size"
Expand Down
4 changes: 0 additions & 4 deletions terraform/env/prod/example.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ availability_zone = "ap-northeast-2a"
# RDS Configuration
rds_username = "admin" # ์‹ค์ œ ํ™˜๊ฒฝ์—์„œ๋Š” ๋” ๋ณต์žกํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ ์‚ฌ์šฉ

# Route53 Configuration
# hosted_zone_id = "YOUR_HOSTED_ZONE_ID" # ๋„๋ฉ”์ธ์˜ hosted zone ID
# domain_name = "yourdomain.com" # ์‹ค์ œ ๋„๋ฉ”์ธ์œผ๋กœ ๋ณ€๊ฒฝ

Loading
Loading