Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Terraform directory structure
| [aws_iam_group.project_leads](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_group) | resource |
| [aws_iam_group_policy_attachment.admin](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_group_policy_attachment) | resource |
| [aws_iam_group_policy_attachment.manageAccessKeys](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_group_policy_attachment) | resource |
| [aws_iam_policy.food_oasis_local_dev](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_policy.manage_access_keys](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_role.incubator_tf_apply](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role.incubator_tf_plan](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
Expand All @@ -83,7 +84,9 @@ Terraform directory structure
| [aws_iam_role_policy_attachment.incubator_tf_plan_readonly](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_iam_role_policy_attachment.incubator_tf_plan_secrets_read](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_iam_user.fangyiliu](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |
| [aws_iam_user.food_oasis_local_dev](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |
| [aws_iam_user.jack_pashayan](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |
| [aws_iam_user_policy_attachment.food_oasis_local_dev](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource |
| [aws_lambda_function.user_bot](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_lambda_permission.user_bot_eventbridge](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
| [aws_s3_bucket.management_events](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
Expand Down
68 changes: 66 additions & 2 deletions terraform/aws-users-legacy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
// 2. The module assumes a user the module itself created, with a uniform tag
// set and group membership. These accounts have neither.
//
// New users still go in aws-users.tf through the module. Nothing should be
// added here that is not already live in the account.
// New users still go in aws-users.tf through the module. The one exception is
// food-oasis-local-dev below, which carries a legacy arrangement forward and must
// not have a console login.

resource "aws_iam_user" "fangyiliu" {
name = "fangyiliu"
Expand All @@ -21,3 +22,66 @@ resource "aws_iam_user" "fangyiliu" {
resource "aws_iam_user" "jack_pashayan" {
name = "jack.pashayan"
}

// food-oasis-local-dev: a shared, program-only user for Food Oasis developers'
// local setups. Their .env files have always held an AWS access key, and the old
// one belongs to the Food Oasis account, which is being deleted
// (hackforla/incubator#284). The deployed services use their task roles instead.
//
// No login profile and no group, which is why it is a bare resource: the module
// would give it a console password and trigger the user-bot. The access key is
// created by hand and kept in the FOLA - DevOps vault, so it never enters the
// Terraform state.
//
// The policy covers exactly the two AWS calls the Food Oasis server makes, and
// no more: sending email as donotreply@foodoasis.net (the app's EMAIL_USER) and
// searching the staging place index. SES has production access in this account,
// so the From restriction is what stops a local run sending as any other address.
locals {
food_oasis_region = "us-west-2"
}

resource "aws_iam_user" "food_oasis_local_dev" {
name = "food-oasis-local-dev"

tags = {
"Project" = "food-oasis"
}
}

resource "aws_iam_policy" "food_oasis_local_dev" {
name = "food-oasis-local-dev"
description = "Food Oasis local development: send email as donotreply@foodoasis.net and search the staging place index"

policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "SendAsDoNotReply"
Effect = "Allow"
Action = ["ses:SendEmail", "ses:SendRawEmail"]
Resource = "arn:aws:ses:${local.food_oasis_region}:${data.aws_caller_identity.current.account_id}:identity/foodoasis.net"
Condition = {
StringEquals = {
"ses:FromAddress" = "donotreply@foodoasis.net"
}
}
},
{
Sid = "SearchStagingPlaceIndex"
Effect = "Allow"
Action = ["geo:SearchPlaceIndexForText"]
Resource = "arn:aws:geo:${local.food_oasis_region}:${data.aws_caller_identity.current.account_id}:place-index/food-oasis-stage"
},
]
})

tags = {
"Project" = "food-oasis"
}
}

resource "aws_iam_user_policy_attachment" "food_oasis_local_dev" {
user = aws_iam_user.food_oasis_local_dev.name
policy_arn = aws_iam_policy.food_oasis_local_dev.arn
}