Skip to content

Add the Food Oasis production service - #302

Merged
ale210 merged 2 commits into
mainfrom
282-food-oasis-prod-service
Nov 21, 2026
Merged

ale210 merged 2 commits into
mainfrom
282-food-oasis-prod-service

Conversation

@ale210

@ale210 ale210 commented Nov 21, 2026

Copy link
Copy Markdown
Member

Part of #282.

Adds the Food Oasis production service in terraform/projects/food-oasis/environment-prod.tf, configured as staging except:

Plus SES send permissions and the prod Location policy on the task role.

Draft: do not merge until the production data is copied into food-oasis_fullstack_prod (#282's first action item), so the service starts against it.

Expected plan: the service and its supporting resources created, no destroys, and in-place updates to module.food_oasis_prod_database.postgresql_grant.user and .viewer (granting on the restored tables).

@github-actions

github-actions Bot commented Nov 21, 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_prod_location will be created
+   resource "aws_iam_role_policy_attachment" "food_oasis_prod_location" {
+       id         = (known after apply)
+       policy_arn = "arn:aws:iam::035866691871:policy/food-oasis-prod-location-search"
+       role       = "ecs-container-food-oasis-fullstack-prod"
    }

  # module.food-oasis.module.food_oasis_fullstack_prod_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-prod"
+       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_prod_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 = 100
+       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-prod"
+       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-prod"
+           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_prod_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-prod"
+       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_prod_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-prod-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_prod_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-prod: image pull, logs and secrets, scoped to project food-oasis"
+       id               = (known after apply)
+       name             = "food-oasis-fullstack-prod-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_prod_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-prod"
+       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_prod_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-prod"
+       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_prod_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-prod"
    }

  # module.food-oasis.module.food_oasis_fullstack_prod_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-prod"
    }

  # module.food-oasis.module.food_oasis_fullstack_prod_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     = 601
+       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       = [
+                   "*.foodoasis.la",
+                   "*.foodoasis.net",
+                   "foodoasis.la",
+                   "foodoasis.net",
                ]
            }
        }
+       condition {
+           path_pattern {
+               regex_values = []
+               values       = [
+                   "/*",
                ]
            }
        }
    }

  # module.food-oasis.module.food_oasis_fullstack_prod_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-prod-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,302"
+           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_prod_database.postgresql_grant.user will be updated in-place
!~  resource "postgresql_grant" "user" {
        id                = "food-oasis_fullstack_prod_user_food-oasis_fullstack_prod_public_table"
!~      privileges        = [
+           "DELETE",
+           "INSERT",
+           "SELECT",
+           "UPDATE",
        ]
#        (5 unchanged attributes hidden)
    }

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

  # module.food-oasis.module.food_oasis_prod_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-prod-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_prod_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_prod_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-prod-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_prod_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-prod"
    }

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

✅ Plan applied in Terraform apply (OIDC) #127

@ale210 ale210 mentioned this pull request Nov 21, 2026
5 tasks done
@ale210
ale210 marked this pull request as ready for review November 21, 2026 04:06
@ale210
ale210 merged commit 5b970e1 into main Nov 21, 2026
1 check passed
ale210 added a commit that referenced this pull request Nov 21, 2026
Part of hackforla/devops#238.

Points the Food Oasis production hostnames at the load balancer, which
sends them to the production service from #302:

- `www`, `la`, `losangeles`, `hi`, `hawaii`, `mck`, `mckinney` and `sb`
under both `foodoasis.net` and `foodoasis.la`, through
`modules/dns-entry`. Under `.net` they replace Heroku CNAMEs. Under
`.la`, `www` replaces a Heroku CNAME and the seven region names are new.
- The bare `foodoasis.net` becomes an alias to the load balancer,
replacing the alias to Amplify.
- Removes rule 599, the temporary redirect for the bare `foodoasis.la`,
so the production service's rule 601 serves it.

Nothing else changes: the Zoho mail records, the Food Oasis account's
SES DKIM records, `devmckinney`, `vitela` and the Amplify certificate
validation record stay. hackforla/devops#239 removes the leftovers.

Expected plan: 16 to add, 1 to change, 10 to destroy. The replacements
come from `modules/dns-entry` writing the record name without the
domain. The `moved` blocks make each old record get deleted before its
new one is created, so each name is briefly missing during the apply.

**Draft: merge only during the cutover window, with Heroku in
maintenance mode.** Until #294, the `.net` records
take effect only when copied by hand into the Food Oasis account's zone.
That copy is part of the window.

---------

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.

1 participant