Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue 1621] Adds Analytics secrets #1624

Merged
merged 3 commits into from
Apr 5, 2024
Merged

[Issue 1621] Adds Analytics secrets #1624

merged 3 commits into from
Apr 5, 2024

Conversation

coilysiren
Copy link
Collaborator

@coilysiren coilysiren commented Apr 5, 2024

Summary

Fixes #1621

Time to review: 2 mins

Changes proposed

  • Adds the dev / staging / prod configuration for the analytics service secrets
  • Adds the "ACTION" env var for dev / staging / prod, with inline explanations of what it does

Relevant Terraform diff

  # module.service.aws_ecs_task_definition.app must be replaced
-/+ resource "aws_ecs_task_definition" "app" {
      ~ arn                      = "arn:aws:ecs:us-east-1:315341936575:task-definition/analytics-dev:11" -> (known after apply)
      ~ arn_without_revision     = "arn:aws:ecs:us-east-1:315341936575:task-definition/analytics-dev" -> (known after apply)
      ~ container_definitions    = jsonencode(
          ~ [
              ~ {
                  ~ environment            = [
                      + {
                          + name  = "ACTION"
                          + value = "show-results"
                        },
                        {
                            name  = "AWS_REGION"
                            value = "us-east-1"
                        },
                        # (6 unchanged elements hidden)
                    ]
                  ~ linuxParameters        = {
                      ~ capabilities       = {
                          - add  = []
                            # (1 unchanged attribute hidden)
                        }
                        # (1 unchanged attribute hidden)
                    }
                  - mountPoints            = []
                    name                   = "analytics-dev"
                  - portMappings           = []
                  ~ secrets                = [
                      + {
                          + name      = "ANALYTICS_REPORTING_CHANNEL_ID"
                          + valueFrom = "/analytics/dev/reporting-channel-id"
                        },
                      + {
                          + name      = "ANALYTICS_SLACK_BOT_TOKEN"
                          + valueFrom = "/analytics/dev/slack-bot-token"
                        },
                      + {
                          + name      = "GH_TOKEN"
                          + valueFrom = "/analytics/dev/github-token"
                        },
                    ]
                  - systemControls         = []
                  - volumesFrom            = []
                    # (6 unchanged attributes hidden)
                },
            ] # forces replacement
        )
      ~ id                       = "analytics-dev" -> (known after apply)
      ~ revision                 = 11 -> (known after apply)
      - tags                     = {} -> null
        # (9 unchanged attributes hidden)
    }

  # module.service.aws_iam_role_policy.task_executor will be updated in-place
  ~ resource "aws_iam_role_policy" "task_executor" {
        id     = "analytics-dev-task-executor:analytics-dev-task-executor-role-policy"
        name   = "analytics-dev-task-executor-role-policy"
      ~ policy = jsonencode(
          ~ {
              ~ Statement = [
                    # (8 unchanged elements hidden)
                    {
                        Action   = [
                            "ecr:GetDownloadUrlForLayer",
                            "ecr:BatchGetImage",
                            "ecr:BatchCheckLayerAvailability",
                        ]
                        Effect   = "Allow"
                        Resource = "arn:aws:ecr:us-east-1:315341936575:repository/simpler-grants-gov-analytics"
                        Sid      = "ECRPullAccess"
                    },
                  + {
                      + Action   = "ssm:GetParameters"
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:ssm:*:*:parameter/analytics/dev/slack-bot-token",
                          + "arn:aws:ssm:*:*:parameter/analytics/dev/reporting-channel-id",
                          + "arn:aws:ssm:*:*:parameter/analytics/dev/github-token",
                        ]
                      + Sid      = "SecretsAccess"
                    },
                ]
                # (1 unchanged attribute hidden)
            }
        )
        # (1 unchanged attribute hidden)
    }

Testing

https://us-east-1.console.aws.amazon.com/ecs/v2/clusters/analytics-dev/tasks/77e9ca77054345b1a8c97b9ba3601858/logs?region=us-east-1

image

It's working now 😎

Comment on lines +17 to +20
{
name = "GH_TOKEN"
ssm_param_name = "/${var.app_name}/${var.environment}/github-token"
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#837 isn't done yet, so I added my own personal token

Comment on lines +25 to +28
{
name = "ANALYTICS_REPORTING_CHANNEL_ID"
ssm_param_name = "/${var.app_name}/${var.environment}/reporting-channel-id"
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev / staging are #z_bot-analytics-ci-test, prod is #z_bot-sprint-reporting

@coilysiren coilysiren marked this pull request as ready for review April 5, 2024 20:06
@coilysiren coilysiren requested a review from widal001 April 5, 2024 20:06
Copy link
Collaborator

@widal001 widal001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Not super familiar with terraform code, but the comments are helpful and the screenshot shared in the PR looks right as well!

@coilysiren coilysiren merged commit f1503ae into main Apr 5, 2024
7 checks passed
@coilysiren coilysiren deleted the analytics-secrets branch April 5, 2024 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Delivery Dashboard - Configure Github and Slack secrets in AWS
3 participants