-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature : terraform modules support (#1006)
* update cloudwatch * update drafter * feature : terraform support
- Loading branch information
1 parent
ba0623b
commit dad087c
Showing
26 changed files
with
396 additions
and
190 deletions.
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
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,47 @@ | ||
module "cluster" { | ||
source = "../../modules/ecs/cluster" | ||
cluster_name = "fullstackhero" | ||
} | ||
|
||
module "webapi" { | ||
source = "../../modules/ecs" | ||
vpc_id = module.vpc.vpc_id | ||
environment = var.environment | ||
cluster_id = module.cluster.id | ||
service_name = "webapi" | ||
container_name = "fsh-webapi" | ||
container_image = "ghcr.io/fullstackhero/webapi:latest" | ||
subnet_ids = [module.vpc.private_a_id, module.vpc.private_b_id] | ||
environment_variables = { | ||
DatabaseOptions__ConnectionString = module.rds.connection_string | ||
DatabaseOptions__Provider = "postgresql" | ||
Serilog__MinimumLevel__Default = "Error" | ||
CorsOptions__AllowedOrigins__0 = "http://${module.blazor.endpoint}" | ||
} | ||
} | ||
|
||
module "blazor" { | ||
source = "../../modules/ecs" | ||
vpc_id = module.vpc.vpc_id | ||
cluster_id = module.cluster.id | ||
environment = var.environment | ||
container_port = 80 | ||
service_name = "blazor" | ||
container_name = "fsh-blazor" | ||
container_image = "ghcr.io/fullstackhero/blazor:latest" | ||
subnet_ids = [module.vpc.private_a_id, module.vpc.private_b_id] | ||
environment_variables = { | ||
Frontend_FSHStarterBlazorClient_Settings__AppSettingsTemplate = "/usr/share/nginx/html/appsettings.json.TEMPLATE" | ||
Frontend_FSHStarterBlazorClient_Settings__AppSettingsJson = "/usr/share/nginx/html/appsettings.json" | ||
FSHStarterBlazorClient_ApiBaseUrl = "http://${module.webapi.endpoint}:8080" | ||
ApiBaseUrl = "http://${module.webapi.endpoint}:8080" | ||
} | ||
entry_point = [ | ||
"/bin/sh", | ||
"-c", | ||
"envsubst < $${Frontend_FSHStarterBlazorClient_Settings__AppSettingsTemplate} > $${Frontend_FSHStarterBlazorClient_Settings__AppSettingsJson} || echo 'envsubst failed' && find /usr/share/nginx/html -type f | xargs chmod +r || echo 'chmod failed' && echo 'Entry point execution completed' && cat /usr/share/nginx/html/appsettings.json && exec nginx -g 'daemon off;'" | ||
] | ||
|
||
|
||
|
||
} |
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 @@ | ||
module "rds" { | ||
environment = var.environment | ||
source = "../../modules/rds" | ||
vpc_id = module.vpc.vpc_id | ||
subnet_ids = [module.vpc.private_a_id, module.vpc.private_b_id] | ||
multi_az = false | ||
database_name = "fsh" | ||
cidr_block = module.vpc.cidr_block | ||
} |
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
module "vpc" { | ||
source = "../../modules/vpc" | ||
} |
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,3 @@ | ||
output "vpc_id" { | ||
value = module.vpc.vpc_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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
resource "aws_cloudwatch_log_group" "log_group" { | ||
resource "aws_cloudwatch_log_group" "this" { | ||
name = var.log_group_name | ||
retention_in_days = 60 | ||
retention_in_days = var.retention_period | ||
} |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
variable "log_group_name" { | ||
type = string | ||
type = string | ||
} | ||
|
||
variable "retention_period" { | ||
type = number | ||
default = 60 | ||
} |
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
resource "aws_ecs_cluster" "this" { | ||
name = var.cluster_name | ||
} | ||
|
||
resource "aws_ecs_cluster_capacity_providers" "this" { | ||
cluster_name = aws_ecs_cluster.this.name | ||
capacity_providers = ["FARGATE"] | ||
default_capacity_provider_strategy { | ||
base = 1 | ||
weight = 100 | ||
capacity_provider = "FARGATE" | ||
} | ||
} |
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,3 @@ | ||
output "id" { | ||
value = aws_ecs_cluster.this.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,3 @@ | ||
variable "cluster_name" { | ||
type = string | ||
} |
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,41 @@ | ||
resource "aws_iam_role" "ecs_task_execution_role" { | ||
name = "${var.service_name}-ecs-ter" | ||
assume_role_policy = <<EOF | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Principal": { | ||
"Service": "ecs-tasks.amazonaws.com" | ||
}, | ||
"Effect": "Allow", | ||
"Sid": "" | ||
} | ||
] | ||
} | ||
EOF | ||
} | ||
resource "aws_iam_role" "ecs_task_role" { | ||
name = "${var.service_name}-ecs-tr" | ||
assume_role_policy = <<EOF | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Principal": { | ||
"Service": "ecs-tasks.amazonaws.com" | ||
}, | ||
"Effect": "Allow", | ||
"Sid": "" | ||
} | ||
] | ||
} | ||
EOF | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "ecs-task-execution-role-policy-attachment" { | ||
role = aws_iam_role.ecs_task_execution_role.name | ||
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy" | ||
} |
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,3 @@ | ||
output "endpoint" { | ||
value = aws_lb.this.dns_name | ||
} |
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
Oops, something went wrong.