Skip to content

Commit

Permalink
[FIX] fix tf file for aws
Browse files Browse the repository at this point in the history
  • Loading branch information
ohksj77 committed Mar 16, 2024
1 parent 75f24c2 commit 22f19e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ jobs:
cd /var/www/TWTW
sudo docker-compose -f docker-compose.prod.yml down
sudo docker-compose -f docker-compose.prod.yml pull
sudo docker-compose -f docker-compose.prod.yml up -d
sudo docker-compose -f docker-compose.prod.yml up --build -d
40 changes: 15 additions & 25 deletions terraform/terraform.tf
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
resource "aws_default_vpc" "vpc_network" {
resource "aws_vpc" "vpc_network" {
tags = merge(var.tags, {})
enable_dns_support = true
enable_dns_hostnames = true
}

resource "aws_internet_gateway" "internet_gw" {
vpc_id = aws_default_vpc.vpc_network.id
tags = merge(var.tags, {})
cidr_block = "10.0.0.0/16"
}

resource "aws_subnet" "private-subnet-a" {
vpc_id = aws_default_vpc.vpc_network.id
vpc_id = aws_vpc.vpc_network.id
tags = merge(var.tags, {})
cidr_block = "10.0.2.0/24"
cidr_block = cidrsubnet(aws_vpc.vpc_network.cidr_block, 8, 1)
availability_zone = "ap-northeast-2a"
}

resource "aws_subnet" "private-subnet-c" {
vpc_id = aws_default_vpc.vpc_network.id
vpc_id = aws_vpc.vpc_network.id
tags = merge(var.tags, {})
cidr_block = "10.0.3.0/24"
cidr_block = cidrsubnet(aws_vpc.vpc_network.cidr_block, 8, 2)
availability_zone = "ap-northeast-2c"
}

resource "aws_subnet" "public-subnet-c" {
vpc_id = aws_default_vpc.vpc_network.id
vpc_id = aws_vpc.vpc_network.id
tags = merge(var.tags, {})
cidr_block = "10.0.1.0/24"
cidr_block = cidrsubnet(aws_vpc.vpc_network.cidr_block, 8, 3)
availability_zone = "ap-northeast-2b"
}

Expand Down Expand Up @@ -92,7 +88,7 @@ resource "aws_instance" "instance-c" {
}

resource "aws_security_group" "security-group-a" {
vpc_id = aws_default_vpc.vpc_network.id
vpc_id = aws_vpc.vpc_network.id
tags = merge(var.tags, {})

egress {
Expand All @@ -109,29 +105,21 @@ resource "aws_security_group" "security-group-a" {
protocol = "tcp"
from_port = 80
cidr_blocks = [
"10.0.1.0/24",
cidrsubnet(aws_vpc.vpc_network.cidr_block, 8, 3)
]
}
ingress {
to_port = 61613
protocol = "tcp"
from_port = 61613
cidr_blocks = [
"10.0.1.0/24",
]
}
ingress {
to_port = 5672
protocol = "tcp"
from_port = 5672
cidr_blocks = [
"10.0.1.0/24",
cidrsubnet(aws_vpc.vpc_network.cidr_block, 8, 3)
]
}
}

resource "aws_security_group" "security-group-c" {
vpc_id = aws_default_vpc.vpc_network.id
vpc_id = aws_vpc.vpc_network.id
tags = merge(var.tags, {})

egress {
Expand All @@ -148,7 +136,7 @@ resource "aws_security_group" "security-group-c" {
protocol = "tcp"
from_port = 80
cidr_blocks = [
"10.0.1.0/24",
cidrsubnet(aws_vpc.vpc_network.cidr_block, 8, 3),
]
}
}
Expand All @@ -163,6 +151,7 @@ resource "aws_db_instance" "db_instance" {
engine = "mysql"
db_name = "TWTW"
availability_zone = "ap-northeast-2b"
allocated_storage = 20
}

resource "aws_mq_broker" "mq_broker" {
Expand Down Expand Up @@ -190,6 +179,7 @@ resource "aws_elasticache_cluster" "elasticache_cluster" {
cluster_id = "twtw-redis-cluster"
availability_zone = "ap-northeast-2b"
node_type = "cache.t2.micro"
num_cache_nodes = 1
}

resource "aws_launch_template" "asg" {
Expand Down

0 comments on commit 22f19e5

Please sign in to comment.