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: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.tfstate.backup
*.tfvars
.terraform.lock.hcl
modules/shared_resources/dist/*.zip

# --- Secrets (보안상 절대 커밋 금지) ---
*.pem
Expand Down
36 changes: 25 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@ solid-connection-infra/
│ └── side-infra/ # [side infra 관련 설정]
│ └── config.alloy
├── modules/
│ └── app_stack/ # [Prod/Stage 환경의 공통 모듈]
│ ├── scripts
│ │ └── docker_setup.sh
│ │ └── nginx_setup.sh.tftpl
│ │ └── side_infra_setup.sh.tftpl
│ ├── security_groups.tf
│ ├── ec2.tf
│ ├── rds.tf
│ ├── app_stack/ # [Prod/Stage 환경의 공통 모듈]
│ │ ├── scripts
│ │ │ ├── docker_setup.sh
│ │ │ ├── nginx_setup.sh.tftpl
│ │ │ └── side_infra_setup.sh.tftpl
│ │ ├── security_groups.tf
│ │ ├── ec2.tf
│ │ ├── rds.tf
│ │ ├── variables.tf
│ │ └── outputs.tf
│ └── shared_resources/ # [global 환경의 공유 자원 모듈]
│ ├── src/
│ │ ├── img_resizing/
│ │ │ └── index.js
│ │ └── thumbnail/
│ │ └── index.js
│ ├── cloudfront.tf
│ ├── lambda.tf
│ ├── provider.tf
│ ├── s3.tf
│ ├── variables.tf
│ └── outputs.tf
│ └── variables.tf
└── environments/
├── prod/ # [Prod 환경]
│ ├── main.tf
Expand All @@ -35,7 +45,11 @@ solid-connection-infra/
│ ├── main.tf
│ ├── provider.tf
│ └── variables.tf
└── monitoring/ # [Monitoring 환경]
├── monitoring/ # [모니터링 환경]
│ ├── main.tf
│ ├── provider.tf
│ └── variables.tf
└── global/ # [global 공유 환경]
├── main.tf
├── provider.tf
└── variables.tf
Expand Down
2 changes: 1 addition & 1 deletion config/secrets
25 changes: 25 additions & 0 deletions environment/global/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module "shared_resources" {
source = "../../modules/shared_resources"

providers = {
aws = aws
}

s3_default_bucket_name = var.s3_default_bucket_name
s3_upload_bucket_name = var.s3_upload_bucket_name

resizing_img_func_name = var.resizing_img_func_name
resizing_img_func_role = var.resizing_img_func_role
resizing_img_func_handler = var.resizing_img_func_handler
resizing_img_func_runtime = var.resizing_img_func_runtime
resizing_img_func_layers = var.resizing_img_func_layers

thumbnail_generating_func_name = var.thumbnail_generating_func_name
thumbnail_generating_func_role = var.thumbnail_generating_func_role
thumbnail_generating_func_handler = var.thumbnail_generating_func_handler
thumbnail_generating_func_runtime = var.thumbnail_generating_func_runtime
thumbnail_generating_func_layers = var.thumbnail_generating_func_layers

default_cdn_web_acl_id = var.default_cdn_web_acl_id
upload_cdn_web_acl_id = var.upload_cdn_web_acl_id
}
21 changes: 21 additions & 0 deletions environment/global/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
terraform {
required_version = ">= 1.0.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}

provider "aws" {
region = "ap-northeast-2"

default_tags {
tags = {
Project = "solid-connection"
Environment = "global"
}
}
}
71 changes: 71 additions & 0 deletions environment/global/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# [S3 버킷 관련 변수]
variable "s3_default_bucket_name" {
description = "Name of the default S3 bucket"
type = string
}

variable "s3_upload_bucket_name" {
description = "Name of the upload S3 bucket"
type = string
}

# [Lambda 관련 변수]
variable "resizing_img_func_name" {
description = "Image Resizing function name for uploaded s3 file"
type = string
}

variable "resizing_img_func_role" {
description = "Image Resizing function role for uploaded s3 file"
type = string
}

variable "resizing_img_func_handler" {
description = "Image Resizing function handler for uploaded s3 file"
type = string
}

variable "resizing_img_func_runtime" {
description = "Image Resizing function runtime for uploaded s3 file"
type = string
}

variable "thumbnail_generating_func_name" {
description = "Thumbnail generating function name for uploaded s3 file"
type = string
}

variable "thumbnail_generating_func_role" {
description = "Thumbnail generating function role for uploaded s3 file"
type = string
}

variable "thumbnail_generating_func_handler" {
description = "Thumbnail generating function handler for uploaded s3 file"
type = string
}

variable "thumbnail_generating_func_runtime" {
description = "Thumbnail generating function runtime for uploaded s3 file"
type = string
}

variable "resizing_img_func_layers" {
description = "Layers For Image Resizing func"
type = list(string)
}

variable "thumbnail_generating_func_layers" {
description = "Layers For Image Resizing func"
type = list(string)
}

variable "default_cdn_web_acl_id" {
description = "WAF Web ACL Id for Default Cloudfront CDN"
type = string
}

variable "upload_cdn_web_acl_id" {
description = "WAF Web ACL Id for Upload Cloudfront CDN"
type = string
}
8 changes: 2 additions & 6 deletions environment/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module "prod_stack" {

# 키페어 및 접속 허용
key_name = var.key_name

# 인스턴스 스펙
instance_type = var.server_instance_type
db_instance_class = var.db_instance_class
Expand All @@ -24,7 +24,7 @@ module "prod_stack" {

# RDS 식별자 설정
rds_identifier = var.rds_identifier

# DB 계정 정보
db_username = var.db_root_username
db_password = var.db_root_password
Expand All @@ -42,10 +42,6 @@ module "prod_stack" {
cert_email = var.cert_email
nginx_conf_name = var.nginx_conf_name

# S3 버킷 이름 전달
s3_default_bucket_name = var.s3_default_bucket_name
s3_upload_bucket_name = var.s3_upload_bucket_name

# ssh key 경로 전달
ssh_key_path = var.ssh_key_path

Expand Down
10 changes: 0 additions & 10 deletions environment/prod/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,6 @@ variable "nginx_conf_name" {
type = string
}

variable "s3_default_bucket_name" {
description = "Name of the default S3 bucket"
type = string
}

variable "s3_upload_bucket_name" {
description = "Name of the upload S3 bucket"
type = string
}

variable "ssh_key_path" {
description = "Path to the SSH private key file for remote-exec"
type = string
Expand Down
10 changes: 3 additions & 7 deletions environment/stage/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ module "stage_stack" {

# 키페어 및 접속 허용
key_name = var.key_name

# 인스턴스 스펙
instance_type = var.server_instance_type
instance_type = var.server_instance_type
db_instance_class = var.db_instance_class

# 보안 그룹 규칙
Expand All @@ -24,7 +24,7 @@ module "stage_stack" {

# RDS 식별자 설정
rds_identifier = var.rds_identifier

# DB 계정 정보
db_username = var.db_root_username
db_password = var.db_root_password
Expand All @@ -42,10 +42,6 @@ module "stage_stack" {
cert_email = var.cert_email
nginx_conf_name = var.nginx_conf_name

# S3 버킷 이름 전달
s3_default_bucket_name = var.s3_default_bucket_name
s3_upload_bucket_name = var.s3_upload_bucket_name

# ssh key 경로 전달
ssh_key_path = var.ssh_key_path

Expand Down
10 changes: 0 additions & 10 deletions environment/stage/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,6 @@ variable "nginx_conf_name" {
type = string
}

variable "s3_default_bucket_name" {
description = "Name of the default S3 bucket"
type = string
}

variable "s3_upload_bucket_name" {
description = "Name of the upload S3 bucket"
type = string
}

variable "ssh_key_path" {
description = "Path to the SSH private key file for remote-exec"
type = string
Expand Down
11 changes: 0 additions & 11 deletions modules/app_stack/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,6 @@ variable "nginx_conf_name" {
type = string
}

# [S3 버킷 관련 변수]
variable "s3_default_bucket_name" {
description = "Name of the default S3 bucket"
type = string
}

variable "s3_upload_bucket_name" {
description = "Name of the upload S3 bucket"
type = string
}

# [Remote SSH용 변수]
variable "ssh_key_path" {
description = "Path to the SSH private key file for remote-exec"
Expand Down
27 changes: 27 additions & 0 deletions modules/shared_resources/acm.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
resource "aws_acm_certificate" "default_cdn_cert" {
provider = aws.virginia
domain_name = "cdn.default.solid-connection.com"
validation_method = "DNS"

tags = {
Name = "cdn-default-solid-connection-cert"
}

lifecycle {
create_before_destroy = true
}
}

resource "aws_acm_certificate" "upload_cdn_cert" {
provider = aws.virginia
domain_name = "cdn.upload.solid-connection.com"
validation_method = "DNS"

tags = {
Name = "cdn-upload-solid-connection-cert"
}

lifecycle {
create_before_destroy = true
}
}
Loading