File tree Expand file tree Collapse file tree 13 files changed +135
-6
lines changed
Expand file tree Collapse file tree 13 files changed +135
-6
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,8 @@ jacoco {
2727
2828sonarqube {
2929 properties {
30- property " sonar.projectKey" , " baegam_eatda "
31- property " sonar.organization" , " baegam "
30+ property " sonar.projectKey" , " YAPP-Github_26th-Web-Team-1-BE "
31+ property " sonar.organization" , " yapp-github "
3232 property " sonar.host.url" , " https://sonarcloud.io"
3333 property ' sonar.sourceEncoding' , ' UTF-8'
3434 property ' sonar.java.coveragePlugin' , ' jacoco'
@@ -85,6 +85,7 @@ dependencies {
8585
8686 // aws
8787 implementation ' io.awspring.cloud:spring-cloud-aws-starter-parameter-store:3.2.1'
88+ implementation ' software.amazon.awssdk:s3:2.31.77'
8889}
8990
9091bootJar {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ resource "aws_instance" "dev" {
66 key_name = var. instance_definitions . key_name
77 user_data = var. instance_definitions . user_data
88 vpc_security_group_ids = [var . ec2_sg_id ]
9- user_data_replace_on_change = true
9+ user_data_replace_on_change = false
1010
1111 metadata_options {
1212 http_tokens = " required"
Original file line number Diff line number Diff line change @@ -23,8 +23,14 @@ locals {
2323 environment = " dev"
2424 name_prefix = " eatda"
2525
26+ bucket_name_prefix = " eatda-storage"
27+ allowed_origins = [
28+ " https://dev.eatda.net" ,
29+ " http://localhost:3000"
30+ ]
31+
2632 ec2_sg_id = data. terraform_remote_state . common . outputs . security_group_ids [" ec2" ]
27- instance_subnet_map = data. terraform_remote_state . common . outputs . public_subnet_ids # 에러가 났던 부분
33+ instance_subnet_map = data. terraform_remote_state . common . outputs . public_subnet_ids
2834 ecr_repo_urls = data. terraform_remote_state . bootstrap . outputs . ecr_repo_urls
2935 ecs_services = var. ecs_services
3036 alb_target_group_arns = data. terraform_remote_state . common . outputs . target_group_arns
Original file line number Diff line number Diff line change @@ -16,3 +16,10 @@ module "ecs" {
1616 environment = local. environment
1717 tags = local. common_tags
1818}
19+
20+ module "s3" {
21+ source = " ./s3"
22+ bucket_name_prefix = local. bucket_name_prefix
23+ environment = local. environment
24+ allowed_origins = local. allowed_origins
25+ }
Original file line number Diff line number Diff line change 1+ resource "aws_s3_bucket" "dev" {
2+ bucket = " ${ var . bucket_name_prefix } -${ var . environment } "
3+
4+ tags = {
5+ Name = " ${ var . bucket_name_prefix } -${ var . environment } "
6+ Environment = var.environment
7+ ManagedBy = " Terraform"
8+ }
9+ }
10+
11+ resource "aws_s3_bucket_public_access_block" "dev" {
12+ bucket = aws_s3_bucket. dev . id
13+
14+ block_public_acls = true
15+ block_public_policy = true
16+ ignore_public_acls = true
17+ restrict_public_buckets = true
18+ }
19+
20+ resource "aws_s3_bucket_server_side_encryption_configuration" "dev" {
21+ bucket = aws_s3_bucket. dev . id
22+
23+ rule {
24+ apply_server_side_encryption_by_default {
25+ sse_algorithm = " AES256"
26+ }
27+ }
28+ }
29+
30+ resource "aws_s3_bucket_cors_configuration" "dev" {
31+ bucket = aws_s3_bucket. dev . id
32+
33+ cors_rule {
34+ allowed_headers = [" *" ]
35+ allowed_methods = [" GET" ]
36+ allowed_origins = var. allowed_origins
37+ expose_headers = [" ETag" ]
38+ max_age_seconds = 3000
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ variable "bucket_name_prefix" {
2+ type = string
3+ }
4+
5+ variable "environment" {
6+ type = string
7+ }
8+
9+ variable "allowed_origins" {
10+ type = list (string )
11+ }
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ resource "aws_instance" "prod" {
66 key_name = var. instance_definitions . key_name
77 user_data = var. instance_definitions . user_data
88 vpc_security_group_ids = [var . ec2_sg_id ]
9- user_data_replace_on_change = true
9+ user_data_replace_on_change = false
1010
1111 metadata_options {
1212 http_tokens = " required"
@@ -25,4 +25,4 @@ resource "aws_eip" "prod" {
2525 tags = {
2626 Name = " ${ var . name_prefix } -${ var . instance_definitions . role } -eip"
2727 }
28- }
28+ }
Original file line number Diff line number Diff line change @@ -23,6 +23,12 @@ locals {
2323 environment = " prod"
2424 name_prefix = " eatda"
2525
26+ bucket_name_prefix = " eatda-storage"
27+ allowed_origins = [
28+ " https://eatda.net" ,
29+ " https://www.eatda.net"
30+ ]
31+
2632 ec2_sg_id = data. terraform_remote_state . common . outputs . security_group_ids [" ec2" ]
2733 instance_definitions = data. terraform_remote_state . common . outputs . instance_profile_name [" ec2-to-ecs" ]
2834 instance_subnet_map = data. terraform_remote_state . common . outputs . public_subnet_ids
Original file line number Diff line number Diff line change @@ -46,3 +46,10 @@ module "rds" {
4646 storage_encrypted = true
4747 tags = local. common_tags
4848}
49+
50+ module "s3" {
51+ source = " ./s3"
52+ bucket_name_prefix = local. bucket_name_prefix
53+ environment = local. environment
54+ allowed_origins = local. allowed_origins
55+ }
You can’t perform that action at this time.
0 commit comments