Skip to content

Commit

Permalink
update our consumption of our service data object, remove some redund…
Browse files Browse the repository at this point in the history
…ant variables
  • Loading branch information
alismx committed Jun 18, 2024
1 parent 6b29ffc commit 316fdf5
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 17 deletions.
75 changes: 67 additions & 8 deletions terraform/implementation/ecs/_local.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,71 @@
locals {
ecs_container_port = 8080
ecr_repo_names = [
"ecr-viewer",
"fhir-converter",
"ingestion",
"orchestration",
"validation"
]
service_data = {
ecr-viewer = {
fargate_cpu = 1024,
fargate_memory = 2048,
app_image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com/ecr-viewer:${var.phdi_version}",
container_port = 8080,
host_port = 8080,
env_vars = []
},
fhir-converter = {
fargate_cpu = 1024,
fargate_memory = 2048,
app_image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com/fhir-converter:${var.phdi_version}",
container_port = 8080,
host_port = 8080,
env_vars = []
},
ingestion = {
fargate_cpu = 1024,
fargate_memory = 2048,
app_image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com/ingestion:${var.phdi_version}",
container_port = 8080,
host_port = 8080,
env_vars = []
},
validation = {
fargate_cpu = 1024,
fargate_memory = 2048,
app_image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com/validation:${var.phdi_version}",
container_port = 8080,
host_port = 8080,
env_vars = []
},
orchestration = {
fargate_cpu = 1024,
fargate_memory = 2048,
app_image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com/orchestration:${var.phdi_version}",
container_port = 8080,
host_port = 8080,
env_vars = [
{
name = "APPMESH_VIRTUAL_NODE_NAME",
value = "orchestration"
},
{
name = "INGESTION_URL",
value = "http://ingestion:8080"
},
{
name = "VALIDATION_URL",
value = "http://validation:8080"
},
{
name = "FHIR_CONVERTER_URL",
value = "http://fhir-converter:8080"
},
{
name = "ECR_VIEWER_URL",
value = "http://ecr-viewer:3000"
},
{
name = "MESSAGE_PARSER_URL",
value = "http://message-parser-not-implemented:8080"
}
]
}
}

ecs_alb_sg = "${var.ecs_alb_sg}-${var.owner}-${terraform.workspace}"
ecs_alb_name = "${var.ecs_alb_name}-${var.owner}-${terraform.workspace}"
Expand Down
7 changes: 7 additions & 0 deletions terraform/implementation/ecs/_variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,11 @@ variable "tags" {
description = "Tags to apply to resources"
type = map(string)
default = {}
}

# Manually update to set the version you want to run
variable "phdi_version" {
type = string
description = "PHDI container image version"
default = "v1.4.4"
}
2 changes: 1 addition & 1 deletion terraform/implementation/ecs/ecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ elif [ "$ENVIRONMENT" != "$PRODUCTION" ] && [ "$ENVIRONMENT" != "" ]; then
# -target=module.vpc -target=module.iam -target=module.ecr -target=module.s3 -target=module.ecs
terraform apply \
-var-file="$ENVIRONMENT.tfvars" \
-target=module.vpc -target=module.iam -target=module.ecr -target=module.s3 -target=module.ecs -target=module.ecs
-target=module.vpc -target=module.iam -target=module.ecr -target=module.s3 -target=module.ecs
else
echo "Please provide a valid environment: $PRODUCTION or another string"
exit 1
Expand Down
16 changes: 8 additions & 8 deletions terraform/implementation/ecs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ module "ecr" {
source = "../../modules/ecr"
aws_caller_identity = data.aws_caller_identity.current.account_id
ecs_task_execution_role = module.iam.ecs_task_execution_role.arn
ecr_repo_names = local.ecr_repo_names
service_data = local.service_data
phdi_version = var.phdi_version
ecs_cluster_name = local.ecs_cluster_name
tags = {}
lifecycle_policy = ""
region = var.region
}

module "s3" {
source = "../../modules/s3"
ecs_assume_role_policy = module.iam.ecr_viewer_and_s3_assume_role_policy
region = var.region
s3_viewer_bucket_name = local.s3_viewer_bucket_name
s3_viewer_bucket_role_name = local.s3_viewer_bucket_role_name
source = "../../modules/s3"
ecs_assume_role_policy = module.iam.ecr_viewer_and_s3_assume_role_policy
region = var.region
s3_viewer_bucket_name = local.s3_viewer_bucket_name
s3_viewer_bucket_role_name = local.s3_viewer_bucket_role_name
s3_viewer_bucket_policy_name = local.s3_viewer_bucket_policy_name
}

Expand All @@ -53,8 +54,7 @@ module "ecs" {
app_task_name = local.ecs_app_task_name
alb_name = local.ecs_alb_name
ecs_cloudwatch_log_group = local.ecs_cloudwatch_log_group
container_port = local.ecs_container_port
ecr_repo_names = local.ecr_repo_names
service_data = local.service_data
ecs_app_task_family = local.ecs_app_task_family
target_group_name = local.ecs_target_group_name
retention_in_days = var.cw_retention_in_days
Expand Down

0 comments on commit 316fdf5

Please sign in to comment.