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 #1546] Deploy Analytics folder to AWS ECR #1566

Merged
merged 29 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
33b490b
checkpoint-kai-1711402661
coilysiren Mar 25, 2024
b53a249
git restore
coilysiren Mar 25, 2024
a07bafd
add docker files
coilysiren Mar 25, 2024
5501a50
checkpoint-kai-1711405786
coilysiren Mar 25, 2024
86579db
PYTHONPATH
coilysiren Mar 25, 2024
3fafefe
ANALYTICS_SLACK_BOT_TOKEN
coilysiren Mar 25, 2024
c2e4ff3
ANALYTICS_REPORTING_CHANNEL_ID
coilysiren Mar 25, 2024
be474a1
local.env
coilysiren Mar 25, 2024
1e68afd
install gh CLI
coilysiren Mar 25, 2024
132a3d2
gh CLI login process working
coilysiren Mar 25, 2024
1ea2610
workon env vars
coilysiren Mar 26, 2024
dabd384
Merge branch 'main' into analytics-docker
coilysiren Mar 26, 2024
f062dfc
Merge branch 'main' into analytics-docker
coilysiren Mar 26, 2024
854a780
Merge branch 'main' into analytics-docker
coilysiren Mar 26, 2024
acaa594
Update Dockerfile
coilysiren Mar 26, 2024
2746bee
docs
coilysiren Mar 26, 2024
585c40e
remove copied code
coilysiren Mar 27, 2024
77139c1
add to development.md
coilysiren Mar 27, 2024
89ebb70
Merge branch 'main' into analytics-ecr
coilysiren Mar 27, 2024
51d8997
Merge branch 'main' into analytics-docker
coilysiren Mar 27, 2024
364d927
Merge branch 'analytics-docker' into analytics-ecr
coilysiren Mar 27, 2024
a44c1f7
Merge branch 'main' into analytics-ecr
coilysiren Mar 27, 2024
673af65
Add ECR repo
coilysiren Mar 27, 2024
de6f08f
test deploy
coilysiren Mar 27, 2024
ffe1730
testing
coilysiren Mar 27, 2024
8442c21
test secrets
coilysiren Mar 27, 2024
ee3e74b
has_database
coilysiren Mar 27, 2024
d3c2798
remove testing change
coilysiren Mar 27, 2024
5c33190
remove testing change
coilysiren Mar 27, 2024
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
41 changes: 41 additions & 0 deletions .github/workflows/cd-analytics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy Analytics
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copied from .github/workflows/cd-api.yml

# Need to set a default value for when the workflow is triggered from a git push
# which bypasses the default configuration for inputs
run-name: Deploy ${{ github.ref_name }} to Analytics ${{ inputs.environment || (github.event_name == 'release' && 'prod') || 'dev' }}

on:
push:
branches:
- "main"
paths:
- "analytics/**"
# TEMPORARY: for testing purposes!
pull_request:
paths:
- .github/workflows/cd-analytics.yml
release:
types: [published]
workflow_dispatch:
inputs:
environment:
description: "target environment"
required: true
default: "dev"
type: choice
options:
- dev
- staging
- prod

jobs:
analytics-checks:
name: Run Analyics Checks
uses: ./.github/workflows/ci-analytics.yml

deploy:
name: Deploy
needs: analytics-checks
uses: ./.github/workflows/deploy.yml
with:
app_name: "analytics"
environment: ${{ inputs.environment || (github.event_name == 'release' && 'prod') || 'dev' }}
44 changes: 44 additions & 0 deletions infra/analytics/build-repository/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions infra/analytics/build-repository/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
data "aws_iam_role" "github_actions" {
Copy link
Collaborator Author

@coilysiren coilysiren Mar 27, 2024

Choose a reason for hiding this comment

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

Copied from infra/api/build-repository/main.tf, verbatim with no changes.

name = module.project_config.github_actions_role_name
}

locals {
# Set project tags that will be used to tag all resources.
tags = merge(module.project_config.default_tags, {
application = module.app_config.app_name
application_role = "build-repository"
description = "Backend resources required for storing built release candidate artifacts to be used for deploying to environments."
})

# Get list of AWS account ids for the application environments that
# will need access to the build repository
app_account_names = values(module.app_config.account_names_by_environment)
account_ids_by_name = data.external.account_ids_by_name.result
app_account_ids = [for account_name in local.app_account_names : local.account_ids_by_name[account_name] if contains(keys(local.account_ids_by_name), account_name)]
}

terraform {
required_version = ">= 1.2.0, < 2.0.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.34.0"
}
}

backend "s3" {
encrypt = "true"
}
}

provider "aws" {
region = module.app_config.build_repository_config.region
default_tags {
tags = local.tags
}
}

module "project_config" {
source = "../../project-config"
}

module "app_config" {
source = "../app-config"
}

data "external" "account_ids_by_name" {
program = ["../../../bin/account-ids-by-name.sh"]
}

module "container_image_repository" {
source = "../../modules/container-image-repository"
name = module.app_config.image_repository_name
push_access_role_arn = data.aws_iam_role.github_actions.arn
app_account_ids = local.app_account_ids
}
4 changes: 4 additions & 0 deletions infra/analytics/build-repository/shared.s3.tfbackend
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bucket = "simpler-grants-gov-315341936575-us-east-1-tf"
key = "infra/analytics/build-repository/shared.tfstate"
dynamodb_table = "simpler-grants-gov-315341936575-us-east-1-tf-state-locks"
region = "us-east-1"
Loading