Skip to content

Add the Food Oasis staging service - #299

Merged
ale210 merged 2 commits into
mainfrom
281-food-oasis-stage-service
Nov 20, 2026
Merged

ale210 merged 2 commits into
mainfrom
281-food-oasis-stage-service

Conversation

@ale210

@ale210 ale210 commented Nov 20, 2026

Copy link
Copy Markdown
Member

Closes #281.

Adds the Food Oasis staging service on the shared cluster, in terraform/projects/food-oasis/environment-stage.tf:

The staging data was copied into food-oasis_fullstack_stage before this PR (see the comments on #281), so the plan should also show in-place updates to the stage database's postgresql_grant.user and .viewer: the apply grants them on the restored tables.

Expected plan: new resources only, plus those two grant updates. Nothing destroyed.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Terraform plan in terraform
With backend config files: terraform/prod.backend.tfvars

Plan: 16 to add, 2 to change, 0 to destroy.
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+   create
!~  update in-place

Terraform will perform the following actions:

  # module.food-oasis.aws_iam_role_policy_attachment.food_oasis_stage_location will be created
+   resource "aws_iam_role_policy_attachment" "food_oasis_stage_location" {
+       id         = (known after apply)
+       policy_arn = "arn:aws:iam::035866691871:policy/food-oasis-stage-location-search"
+       role       = "ecs-container-food-oasis-fullstack-stage"
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_cloudwatch_log_group.this will be created
+   resource "aws_cloudwatch_log_group" "this" {
+       arn                         = (known after apply)
+       deletion_protection_enabled = (known after apply)
+       id                          = (known after apply)
+       log_group_class             = (known after apply)
+       name                        = "/ecs/food-oasis-fullstack-stage"
+       name_prefix                 = (known after apply)
+       region                      = "us-west-2"
+       retention_in_days           = 0
+       skip_destroy                = false
+       tags                        = {
+           "project" = "food-oasis"
        }
+       tags_all                    = {
+           "managed-by" = "terraform-incubator"
+           "project"    = "food-oasis"
        }
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_ecs_service.fargate[0] will be created
+   resource "aws_ecs_service" "fargate" {
+       arn                                = (known after apply)
+       availability_zone_rebalancing      = "DISABLED"
+       cluster                            = "incubator-prod"
+       deployment_maximum_percent         = 200
+       deployment_minimum_healthy_percent = 0
+       desired_count                      = 1
+       enable_ecs_managed_tags            = false
+       enable_execute_command             = true
+       iam_role                           = (known after apply)
+       id                                 = (known after apply)
+       launch_type                        = "EC2"
+       name                               = "food-oasis-fullstack-stage"
+       platform_version                   = (known after apply)
+       propagate_tags                     = "SERVICE"
+       region                             = "us-west-2"
+       scheduling_strategy                = "REPLICA"
+       tags                               = {
+           "project" = "food-oasis"
        }
+       tags_all                           = {
+           "managed-by" = "terraform-incubator"
+           "project"    = "food-oasis"
        }
+       task_definition                    = (known after apply)
+       triggers                           = (known after apply)
+       wait_for_steady_state              = false

+       deployment_configuration (known after apply)

+       load_balancer {
+           container_name   = "food-oasis-fullstack-stage"
+           container_port   = 5001
+           target_group_arn = (known after apply)
#            (1 unchanged attribute hidden)
        }

+       ordered_placement_strategy {
+           field = "memory"
+           type  = "binpack"
        }
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_ecs_task_definition.task will be created
+   resource "aws_ecs_task_definition" "task" {
+       arn                      = (known after apply)
+       arn_without_revision     = (known after apply)
+       container_definitions    = (known after apply)
+       enable_fault_injection   = (known after apply)
+       execution_role_arn       = (known after apply)
+       family                   = "food-oasis-fullstack-stage"
+       id                       = (known after apply)
+       network_mode             = "bridge"
+       region                   = "us-west-2"
+       requires_compatibilities = [
+           "EC2",
        ]
+       revision                 = (known after apply)
+       skip_destroy             = false
+       tags                     = {
+           "project" = "food-oasis"
        }
+       tags_all                 = {
+           "managed-by" = "terraform-incubator"
+           "project"    = "food-oasis"
        }
+       task_role_arn            = (known after apply)
+       track_latest             = false
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_iam_policy.container_policy will be created
+   resource "aws_iam_policy" "container_policy" {
+       arn              = (known after apply)
+       attachment_count = (known after apply)
+       id               = (known after apply)
+       name             = "food-oasis-fullstack-stage-task-policy"
+       name_prefix      = (known after apply)
+       path             = "/"
+       policy           = jsonencode(
            {
+               Statement = [
+                   {
+                       Action   = [
+                           "ssmmessages:CreateControlChannel",
+                           "ssmmessages:CreateDataChannel",
+                           "ssmmessages:OpenControlChannel",
+                           "ssmmessages:OpenDataChannel",
                        ]
+                       Effect   = "Allow"
+                       Resource = "*"
+                       Sid      = "EcsExecuteCommand"
                    },
+                   {
+                       Action    = [
+                           "s3:ListBucket",
+                           "s3:GetObject",
+                           "s3:PutObject",
+                           "s3:DeleteObject",
                        ]
+                       Condition = {
+                           Null         = {
+                               "aws:ResourceTag/project" = "false"
                            }
+                           StringEquals = {
+                               "aws:ResourceTag/project" = "food-oasis"
                            }
                        }
+                       Effect    = "Allow"
+                       Resource  = [
+                           "arn:aws:s3:::*",
+                           "arn:aws:s3:::*/*",
                        ]
+                       Sid       = "ProjectBucketAccess"
                    },
+                   {
+                       Action    = [
+                           "cognito-idp:AdminGetUser",
+                           "cognito-idp:AdminCreateUser",
+                           "cognito-idp:AdminAddUserToGroup",
+                           "cognito-idp:AdminDeleteUser",
                        ]
+                       Condition = {
+                           StringEquals = {
+                               "aws:ResourceTag/project" = "food-oasis"
                            }
                        }
+                       Effect    = "Allow"
+                       Resource  = "arn:aws:cognito-idp:us-west-2:035866691871:userpool/*"
+                       Sid       = "ProjectCognitoAdmin"
                    },
                ]
+               Version   = "2012-10-17"
            }
        )
+       policy_id        = (known after apply)
+       tags_all         = {
+           "managed-by" = "terraform-incubator"
        }
#        (1 unchanged attribute hidden)
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_iam_policy.execution_policy will be created
+   resource "aws_iam_policy" "execution_policy" {
+       arn              = (known after apply)
+       attachment_count = (known after apply)
+       description      = "ECS execution role for food-oasis-fullstack-stage: image pull, logs and secrets, scoped to project food-oasis"
+       id               = (known after apply)
+       name             = "food-oasis-fullstack-stage-execution-policy"
+       name_prefix      = (known after apply)
+       path             = "/"
+       policy           = (known after apply)
+       policy_id        = (known after apply)
+       tags             = {
+           "project" = "food-oasis"
        }
+       tags_all         = {
+           "managed-by" = "terraform-incubator"
+           "project"    = "food-oasis"
        }
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_iam_role.execution will be created
+   resource "aws_iam_role" "execution" {
+       arn                   = (known after apply)
+       assume_role_policy    = jsonencode(
            {
+               Statement = [
+                   {
+                       Action    = "sts:AssumeRole"
+                       Effect    = "Allow"
+                       Principal = {
+                           Service = "ecs-tasks.amazonaws.com"
                        }
+                       Sid       = ""
                    },
                ]
+               Version   = "2012-10-17"
            }
        )
+       create_date           = (known after apply)
+       force_detach_policies = false
+       id                    = (known after apply)
+       managed_policy_arns   = (known after apply)
+       max_session_duration  = 3600
+       name                  = "ecs-execution-food-oasis-fullstack-stage"
+       name_prefix           = (known after apply)
+       path                  = "/"
+       tags                  = {
+           "project" = "food-oasis"
        }
+       tags_all              = {
+           "managed-by" = "terraform-incubator"
+           "project"    = "food-oasis"
        }
+       unique_id             = (known after apply)

+       inline_policy (known after apply)
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_iam_role.instance will be created
+   resource "aws_iam_role" "instance" {
+       arn                   = (known after apply)
+       assume_role_policy    = jsonencode(
            {
+               Statement = [
+                   {
+                       Action    = "sts:AssumeRole"
+                       Effect    = "Allow"
+                       Principal = {
+                           Service = "ecs-tasks.amazonaws.com"
                        }
+                       Sid       = ""
                    },
                ]
+               Version   = "2012-10-17"
            }
        )
+       create_date           = (known after apply)
+       force_detach_policies = false
+       id                    = (known after apply)
+       managed_policy_arns   = (known after apply)
+       max_session_duration  = 3600
+       name                  = "ecs-container-food-oasis-fullstack-stage"
+       name_prefix           = (known after apply)
+       path                  = "/"
+       tags                  = {
+           "project" = "food-oasis"
        }
+       tags_all              = {
+           "managed-by" = "terraform-incubator"
+           "project"    = "food-oasis"
        }
+       unique_id             = (known after apply)

+       inline_policy (known after apply)
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_iam_role_policy_attachment.execution_policy will be created
+   resource "aws_iam_role_policy_attachment" "execution_policy" {
+       id         = (known after apply)
+       policy_arn = (known after apply)
+       role       = "ecs-execution-food-oasis-fullstack-stage"
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_iam_role_policy_attachment.task_policy will be created
+   resource "aws_iam_role_policy_attachment" "task_policy" {
+       id         = (known after apply)
+       policy_arn = (known after apply)
+       role       = "ecs-container-food-oasis-fullstack-stage"
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_lb_listener_rule.static will be created
+   resource "aws_lb_listener_rule" "static" {
+       arn          = (known after apply)
+       id           = (known after apply)
+       listener_arn = "arn:aws:elasticloadbalancing:us-west-2:035866691871:listener/app/incubator-prod-lb/7451adf77133ef36/390a225766a4daf3"
+       priority     = 600
+       region       = "us-west-2"
+       tags_all     = {
+           "managed-by" = "terraform-incubator"
        }

+       action {
+           order            = (known after apply)
+           target_group_arn = (known after apply)
+           type             = "forward"
        }

+       condition {
+           host_header {
+               regex_values = []
+               values       = [
+                   "dev*.foodoasis.la",
+                   "dev*.foodoasis.net",
                ]
            }
        }
+       condition {
+           path_pattern {
+               regex_values = []
+               values       = [
+                   "/*",
                ]
            }
        }
    }

  # module.food-oasis.module.food_oasis_fullstack_stage_service.aws_lb_target_group.this will be created
+   resource "aws_lb_target_group" "this" {
+       arn                                = (known after apply)
+       arn_suffix                         = (known after apply)
+       connection_termination             = (known after apply)
+       deregistration_delay               = "10"
+       id                                 = (known after apply)
+       ip_address_type                    = (known after apply)
+       lambda_multi_value_headers_enabled = false
+       load_balancer_arns                 = (known after apply)
+       load_balancing_algorithm_type      = (known after apply)
+       load_balancing_anomaly_mitigation  = (known after apply)
+       load_balancing_cross_zone_enabled  = (known after apply)
+       name                               = "food-oasis-fullstack-stage-d7f"
+       name_prefix                        = (known after apply)
+       port                               = 5001
+       preserve_client_ip                 = (known after apply)
+       protocol                           = "HTTP"
+       protocol_version                   = (known after apply)
+       proxy_protocol_v2                  = false
+       region                             = "us-west-2"
+       slow_start                         = 0
+       tags_all                           = {
+           "managed-by" = "terraform-incubator"
        }
+       target_type                        = "instance"
+       vpc_id                             = "*********************"

+       health_check {
+           enabled             = true
+           healthy_threshold   = 3
+           interval            = 30
+           matcher             = "200,400,404"
+           path                = "/health"
+           port                = "traffic-port"
+           protocol            = "HTTP"
+           timeout             = (known after apply)
+           unhealthy_threshold = 3
        }

+       stickiness (known after apply)

+       target_failover (known after apply)

+       target_group_health (known after apply)

+       target_health_state {
+           enable_unhealthy_connection_termination = false
+           unhealthy_draining_interval             = 0
        }
    }

  # module.food-oasis.module.food_oasis_stage_database.postgresql_grant.user will be updated in-place
!~  resource "postgresql_grant" "user" {
        id                = "food-oasis_fullstack_stage_user_food-oasis_fullstack_stage_public_table"
!~      privileges        = [
+           "DELETE",
+           "INSERT",
+           "SELECT",
+           "UPDATE",
        ]
#        (5 unchanged attributes hidden)
    }

  # module.food-oasis.module.food_oasis_stage_database.postgresql_grant.viewer will be updated in-place
!~  resource "postgresql_grant" "viewer" {
        id                = "food-oasis_fullstack_stage_viewer_food-oasis_fullstack_stage_public_table"
!~      privileges        = [
+           "SELECT",
        ]
#        (5 unchanged attributes hidden)
    }

  # module.food-oasis.module.food_oasis_stage_jwt_secret.aws_ssm_parameter.this will be created
+   resource "aws_ssm_parameter" "this" {
+       arn            = (known after apply)
+       data_type      = (known after apply)
+       has_value_wo   = (known after apply)
+       id             = (known after apply)
+       insecure_value = (known after apply)
+       key_id         = (known after apply)
+       name           = "/food-oasis/fullstack-stage-jwt-secret"
+       region         = "us-west-2"
+       tags           = {
+           "project" = "food-oasis"
        }
+       tags_all       = {
+           "managed-by" = "terraform-incubator"
+           "project"    = "food-oasis"
        }
+       tier           = (known after apply)
+       type           = "SecureString"
+       value          = (sensitive value)
+       value_wo       = (write-only attribute)
+       version        = (known after apply)
    }

  # module.food-oasis.module.food_oasis_stage_jwt_secret.random_password.password will be created
+   resource "random_password" "password" {
+       bcrypt_hash      = (sensitive value)
+       id               = (known after apply)
+       length           = 48
+       lower            = true
+       min_lower        = 0
+       min_numeric      = 0
+       min_special      = 0
+       min_upper        = 0
+       number           = true
+       numeric          = true
+       override_special = "!#$-"
+       result           = (sensitive value)
+       special          = true
+       upper            = true
    }

  # module.food-oasis.module.food_oasis_stage_ses.aws_iam_policy.this will be created
+   resource "aws_iam_policy" "this" {
+       arn              = (known after apply)
+       attachment_count = (known after apply)
+       description      = "Send email through specific SES identities"
+       id               = (known after apply)
+       name             = "food-oasis-stage-ses-send"
+       name_prefix      = (known after apply)
+       path             = "/"
+       policy           = jsonencode(
            {
+               Statement = [
+                   {
+                       Action   = [
+                           "ses:SendEmail",
+                           "ses:SendRawEmail",
                        ]
+                       Effect   = "Allow"
+                       Resource = [
+                           "arn:aws:ses:us-west-2:035866691871:identity/foodoasis.net",
                        ]
+                       Sid      = "SendFromIdentities"
                    },
                ]
+               Version   = "2012-10-17"
            }
        )
+       policy_id        = (known after apply)
+       tags             = {
+           "project" = "food-oasis"
        }
+       tags_all         = {
+           "managed-by" = "terraform-incubator"
+           "project"    = "food-oasis"
        }
    }

  # module.food-oasis.module.food_oasis_stage_ses.aws_iam_role_policy_attachment.this will be created
+   resource "aws_iam_role_policy_attachment" "this" {
+       id         = (known after apply)
+       policy_arn = (known after apply)
+       role       = "ecs-container-food-oasis-fullstack-stage"
    }

Plan: 16 to add, 2 to change, 0 to destroy.

✅ Plan applied in Terraform apply (OIDC) #124

@ale210
ale210 merged commit d6f464a into main Nov 20, 2026
1 check passed
ale210 added a commit that referenced this pull request Nov 20, 2026
Part of #281.

The Food Oasis staging service from #299 keeps being replaced by ECS:
its load balancer health check gets a 302. With `NODE_ENV=production`
the app redirects every request without `X-Forwarded-Proto: https` to
HTTPS, `/health` included, and the health check sends plain HTTP without
that header.

- `modules/container`: new `health_check_matcher` variable. Its default
is the old hardcoded `200,400,404`, so no other service changes.
- Food Oasis staging sets it to `200,302`. That only proves the process
answers; moving `/health` above the redirect in hackforla/food-oasis
`server/server.ts` would let it go back to the default.

Expected plan: one in-place update, the staging target group's matcher.
Nothing else.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deploy the Food Oasis staging service

1 participant