-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
프로덕션 terraform 추가 #1638
Open
jaeyeonling
wants to merge
7
commits into
main
Choose a base branch
from
feature/deploy-prod
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
프로덕션 terraform 추가 #1638
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cc924ee
fix: add aws key
woowahan-neo 9ff12ca
refactor: separate files
woowahan-neo 8487f4b
fix: add terraform login
woowahan-neo eb64595
fix: add yes command
woowahan-neo af2813f
fix: add terraform credential file
woowahan-neo 2944331
fix: replace working-directory to cd command
woowahan-neo 16e7a29
feat: add production environment terraform scripts
woowahan-neo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
cloud { | ||
organization = "cholog" | ||
|
||
workspaces { | ||
name = "cholog-dev" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "5.54.1" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = var.region | ||
|
||
/** Note: | ||
AWS_ACCESS_KEY_ID와 AWS_SECRET_ACCESS_KEY는 환경변수를 통해 설정해야 합니다. | ||
아래와 같이 환경 변수를 설정하세요: | ||
|
||
export AWS_ACCESS_KEY_ID="your-access-key" | ||
export AWS_SECRET_ACCESS_KEY="your-secret-key" | ||
|
||
GitHub Actions에서는 환경 변수를 Secrets에 저장하여 사용해야 합니다. | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
cloud { | ||
organization = "cholog" | ||
|
||
workspaces { | ||
name = "cholog-prod" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
module "tags" { | ||
source = "../../modules/tags" | ||
|
||
project_name = var.project_name | ||
environment = var.environment | ||
} | ||
|
||
module "compute" { | ||
source = "../../modules/compute" | ||
|
||
project_name = var.project_name | ||
} | ||
|
||
|
||
module "network" { | ||
source = "../../modules/network" | ||
|
||
region = var.region | ||
project_name = var.project_name | ||
server_tags = module.tags.server_tags | ||
gateway_tags = module.tags.gateway_tags | ||
} | ||
|
||
module "storage" { | ||
source = "../../modules/storage" | ||
|
||
bucket_name = var.bucket_name | ||
project_name = var.project_name | ||
storage_tags = module.tags.storage_tags | ||
} | ||
|
||
module "iam" { | ||
source = "../../modules/iam" | ||
|
||
project_name = var.project_name | ||
bucket_arns = [ | ||
module.storage.bucket_arn, | ||
"${module.storage.bucket_arn}/*" | ||
] | ||
} | ||
|
||
module "bastion" { | ||
source = "../../modules/bastion" | ||
|
||
vpc_id = module.network.vpc_id | ||
project_name = var.project_name | ||
ami_id = module.compute.ami_id | ||
key_pair_name = module.compute.key_pair_name | ||
public_subnet_ids = module.network.public_subnet_ids | ||
server_tags = module.tags.server_tags | ||
|
||
} | ||
|
||
module "application" { | ||
source = "../../modules/application" | ||
|
||
vpc_id = module.network.vpc_id | ||
project_name = var.project_name | ||
environment = var.environment | ||
ec2_role_name = module.iam.ec2_role_name | ||
bucket_name = module.storage.bucket_name | ||
region = var.region | ||
code_deploy_role_arn = module.iam.code_deploy_role_arn | ||
ami_id = module.compute.ami_id | ||
key_pair_name = module.compute.key_pair_name | ||
bastion_sg_id = module.bastion.bastion_sg_id | ||
private_subnet_ids = module.network.private_subnet_ids | ||
public_subnet_ids = module.network.public_subnet_ids | ||
service_worker_tags = module.tags.service_worker_tags | ||
server_tags = module.tags.server_tags | ||
} | ||
|
||
module "database" { | ||
source = "../../modules/database" | ||
|
||
vpc_id = module.network.vpc_id | ||
project_name = var.project_name | ||
db_name = var.db_name | ||
secret_name = var.db_secret_name | ||
ingress_security_group_ids = [module.application.application_sg_id, module.bastion.bastion_sg_id] | ||
|
||
private_subnet_ids = module.network.private_subnet_ids | ||
server_tags = module.tags.server_tags | ||
database_tags = module.tags.database_tags | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Network | ||
output "vpc_id" { | ||
description = "VPC ID created by the network module" | ||
value = module.network.vpc_id | ||
} | ||
|
||
output "public_subnet_ids" { | ||
description = "Public subnet IDs created by the network module" | ||
value = module.network.public_subnet_ids | ||
} | ||
|
||
output "private_subnet_ids" { | ||
description = "Private subnet IDs created by the network module" | ||
value = module.network.private_subnet_ids | ||
} | ||
|
||
# Storage | ||
output "bucket_arn" { | ||
description = "Bucket ARN created by the storage module" | ||
value = module.storage.bucket_arn | ||
} | ||
|
||
output "bucket_name" { | ||
description = "Bucket name created by the storage module" | ||
value = module.storage.bucket_name | ||
} | ||
|
||
# IAM | ||
output "ec2_role_name" { | ||
description = "EC2 IAM role name created by the IAM module" | ||
value = module.iam.ec2_role_name | ||
} | ||
|
||
output "s3_policy_arn" { | ||
description = "S3 access policy ARN created by the IAM module" | ||
value = module.iam.s3_access_policy_arn | ||
} | ||
|
||
# Bastion | ||
output "bastion_sg_id" { | ||
description = "Security Group ID for the Bastion host" | ||
value = module.bastion.bastion_sg_id | ||
} | ||
|
||
output "bastion_eip" { | ||
description = "Elastic IP address for the Bastion host" | ||
value = module.bastion.bastion_eip_allocation_id | ||
} | ||
|
||
# Application | ||
output "application_sg_id" { | ||
description = "Security Group ID for the application instances" | ||
value = module.application.application_sg_id | ||
} | ||
|
||
output "application_asg_name" { | ||
description = "Name of the Auto Scaling Group for application instances" | ||
value = module.application.asg_name | ||
} | ||
|
||
output "application_launch_template_id" { | ||
description = "Launch Template ID for application instances" | ||
value = module.application.launch_template_id | ||
} | ||
|
||
# Database | ||
output "database_endpoint" { | ||
description = "Endpoint of the RDS database" | ||
value = module.database.db_instance_endpoint | ||
} | ||
|
||
output "database_id" { | ||
description = "ID of the RDS database instance" | ||
value = module.database.db_instance_id | ||
} | ||
|
||
output "database_sg_id" { | ||
description = "Security Group ID for the database" | ||
value = module.database.database_sg_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "5.54.1" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = var.region | ||
|
||
/** Note: | ||
AWS_ACCESS_KEY_ID와 AWS_SECRET_ACCESS_KEY는 환경변수를 통해 설정해야 합니다. | ||
아래와 같이 환경 변수를 설정하세요: | ||
|
||
export AWS_ACCESS_KEY_ID="your-access-key" | ||
export AWS_SECRET_ACCESS_KEY="your-secret-key" | ||
|
||
GitHub Actions에서는 환경 변수를 Secrets에 저장하여 사용해야 합니다. | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
variable "region" { | ||
default = "ap-northeast-2" | ||
} | ||
variable "project_name" { | ||
default = "prolog-prod" | ||
} | ||
variable "environment" { | ||
default = "prod" | ||
} | ||
variable "bucket_name" { | ||
default = "prolog-prod-bucket" | ||
} | ||
variable "key_pair_name" { | ||
default = "prolog-prod" | ||
} | ||
variable "db_name" { | ||
default = "prolog" | ||
} | ||
variable "db_secret_name" { | ||
default = "secrets/prolog_prod" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이상하게 계속 terrafrom 스크립트가 실패해서 봤더니 Cloud에서 local로 변경해줘야 했습니다~