Skip to content

Commit

Permalink
Merge branch 'main' into adele-remove-one-more-feature-flag-instance
Browse files Browse the repository at this point in the history
  • Loading branch information
adele-usdr authored Dec 11, 2023
2 parents 75ecaf1 + 5b5f959 commit 048dda3
Show file tree
Hide file tree
Showing 10 changed files with 277 additions and 197 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/terraform-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
website-artifacts-path:
type: string
required: true
clear-web-cache:
description: Whether to invalidate the CloudFront distribution cache as a post-deployment step.
type: boolean
default: true
tf-plan-artifacts-key:
type: string
required: true
Expand Down Expand Up @@ -138,3 +142,12 @@ jobs:
AWS_ACCESS_KEY_ID: "${{ steps.decrypt-aws-access-key-id.outputs.out }}"
AWS_SECRET_ACCESS_KEY: "${{ steps.decrypt-aws-secret-access-key.outputs.out }}"
AWS_SESSION_TOKEN: "${{ steps.decrypt-aws-session-token.outputs.out }}"
- name: Invalidate CloudFront distribution cache
if: success() && inputs.clear-web-cache
run: |
DISTRIBUTION_ID=$(terraform output -json | jq --raw-output .website_cloudfront_distribution_id.value)
aws cloudfront create-invalidation --paths '/*' --distribution-id $DISTRIBUTION_ID
env:
AWS_ACCESS_KEY_ID: "${{ steps.decrypt-aws-access-key-id.outputs.out }}"
AWS_SECRET_ACCESS_KEY: "${{ steps.decrypt-aws-secret-access-key.outputs.out }}"
AWS_SESSION_TOKEN: "${{ steps.decrypt-aws-session-token.outputs.out }}"
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ services:
- POSTGRESQL_PASSWORD=password123
- POSTGRESQL_DATABASE=usdr_grants
- POSTGRESQL_USER=postgres
ports:
- 5432:5432
volumes:
- ./docker/postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- ./docker/postgres/docker-entrypoint-preinitdb.d:/docker-entrypoint-preinitdb.d
Expand Down
30 changes: 30 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,33 @@ any files within this directory will be ignored by git. Simply update the `postg
definition in the `docker-compose.yml` file to mount this volume – you can do so
by adding/uncommenting the corresponding `services.postgres.volumes` item in that file so that
the `./docker/postgres/persistence:/bitnami/postgresql` volume mount is enabled.


### Create SQS queues in localstack
SQS queues should automatically be setup from the `localstack/entrypoint/init-aws.sh` script.
This script gets run by localstack after the container is setup.

To confirm evreything is working well, run the following locally (you may need the `aws cli` locally)
```
aws --region us-west-2 --endpoint http://localhost:4566 sqs list-queues
```

If the queue is not setup, first check that you have an updated version of localstack.

If you have an updated version, but still need to setup the queuse, run the below commands.
```
docker ps
# assuming the localstack container name is gost-localstack_main
docker exec -it gost-localstack_main /bin/bash
bash-5.0# awslocal sqs --queue-name arpa-queue
bash-5.0# awslocal sqs list-queues
```
Now we can use that queue name and set it as the environment variable `ARPA_AUDIT_REPORT_SQS_QUEUE_URL`.

To confirm that you can access the queues locally, use the `aws cli` again
```
aws --region us-west-2 --endpoint http://localhost:4566 sqs list-queues
```
For this to work, you must have `AWS_ACCESS_KEY_ID=test` and `AWS_SECRET_ACCESS_KEY=test`.
This is part of the standard localstack setup.

5 changes: 4 additions & 1 deletion localstack/entrypoint/init-aws.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /bin/bash
#!/bin/bash

export LOCALSTACK_HOST=localhost
export HOSTNAME_EXTERNAL=localstack
export AWS_ACCESS_KEY_ID="test"
export AWS_SECRET_ACCESS_KEY="test"

Expand All @@ -15,3 +17,4 @@ done
awslocal s3api create-bucket --bucket arpa-audit-reports --region us-west-2 --create-bucket-configuration '{"LocationConstraint": "us-west-2"}'

awslocal sqs create-queue --queue-name grants-ingest-events
awslocal sqs create-queue --queue-name arpa-queue
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"start": "yarn serve",
"test:client": "yarn workspace client test",
"test:server": "yarn workspace server test",
"test": "yarn workspaces run test"
"test": "yarn workspaces run test",
"start:arpa-audit-worker": "yarn workspace server start:arpa-audit-worker",
"debug:arpa-audit-worker": "yarn workspace server debug:arpa-audit-worker"
},
"dependencies": {},
"devDependencies": {
Expand Down
80 changes: 48 additions & 32 deletions packages/client/src/views/MyProfile.vue
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
<template>
<main style="max-width: 516px;" class="mx-auto my-5 px-2">
<h2>My Profile</h2>
<section style="margin-top: 4rem;">
<b-row>
<b-col>
<UserAvatar />
</b-col>
<b-col cols="7">
<p class="mb-2 h6"><b>{{ name }}</b></p>
<p class="mb-2">{{ email }}</p>
<p class="mb-2">{{ agency }}</p>
</b-col>
<b-col class="text-end">
<b-button variant="primary" size="md" @click="$bvModal.show('edit-user-modal')">
<b-icon icon="pencil-fill" scale="0.8"></b-icon>
<span class="ml-1">Edit</span>
</b-button>
</b-col>
</b-row>
<main>
<b-breadcrumb :items="breadcrumb_items"></b-breadcrumb>
<section style="max-width: 516px;" class="mx-auto my-5 px-2">
<h2>My Profile</h2>
<section style="margin-top: 4rem;">
<b-row>
<b-col>
<UserAvatar />
</b-col>
<b-col cols="7">
<p class="mb-2 h6"><b>{{ name }}</b></p>
<p class="mb-2">{{ email }}</p>
<p class="mb-2">{{ agency }}</p>
</b-col>
<b-col class="text-end">
<b-button variant="primary" size="md" @click="$bvModal.show('edit-user-modal')">
<b-icon icon="pencil-fill" scale="0.8"></b-icon>
<span class="ml-1">Edit</span>
</b-button>
</b-col>
</b-row>
</section>
<section style="margin-top: 3.5rem;">
<h3 style="margin-bottom: 1.5rem;">Email Notifications</h3>
<b-row v-for="pref in prefs" :key="pref.key" >
<b-col cols="11">
<p class="mb-0">{{ pref.name }}</p>
<p class="pref-description">{{ pref.description }}</p>
</b-col>
<b-col cols="1">
<b-form-checkbox switch v-model="pref.checked" @change="onUpdateEmailPreference(pref)"></b-form-checkbox>
</b-col>
</b-row>
</section>
<EditUserModal/>
</section>
<section style="margin-top: 3.5rem;">
<h3 style="margin-bottom: 1.5rem;">Email Notifications</h3>
<b-row v-for="pref in prefs" :key="pref.key" >
<b-col cols="11">
<p class="mb-0">{{ pref.name }}</p>
<p class="pref-description">{{ pref.description }}</p>
</b-col>
<b-col cols="1">
<b-form-checkbox switch v-model="pref.checked" @change="onUpdateEmailPreference(pref)"></b-form-checkbox>
</b-col>
</b-row>
</section>
<EditUserModal/>
</main>
</template>

Expand Down Expand Up @@ -64,6 +67,16 @@ export default {
description: 'Send me occasional emails about feature releases, surveys, and other updates.',
},
],
breadcrumb_items: [
{
text: 'Home',
href: '/#/grants',
},
{
text: 'My Profile',
href: '#',
},
],
};
},
computed: {
Expand Down Expand Up @@ -111,4 +124,7 @@ export default {
font-size: 12px;
margin-bottom: 2rem;
}
.breadcrumb {
background-color: #ffffff;
}
</style>
18 changes: 13 additions & 5 deletions packages/server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ TEST_EMAIL_RECIPIENT=""
# You only need one of them configured at a time; in dev, you probably want to use Nodemailer, which uses a
# regular SMTP server (e.g. from Gmail). See README.md for more advice on how to configure this.

# AWS SES:
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION:-us-west-2}"
# AWS SDK configuration. test / test is used for localstack
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
AWS_DEFAULT_REGION="us-west-2"

# AWS SES
NOTIFICATIONS_EMAIL=[email protected]

# Email Server:
Expand All @@ -44,5 +46,11 @@ DATA_DIR="./data"
# S3 bucket for ARPA Audit reports
AUDIT_REPORT_BUCKET=arpa-audit-reports

# SQS queue for grants-ingest events
# SQS queue for grants-ingest events and arpa events
GRANTS_INGEST_EVENTS_QUEUE_URL="http://localhost:4566/000000000000/grants-ingest-events"
ARPA_AUDIT_REPORT_SQS_QUEUE_URL="http://sqs.us-west-2.localhost.localstack.cloud:4566/000000000000/arpa-queue"

# for setting up the worker processes to run locally over localstack
TASK_QUEUE_URL="http://sqs.us-west-2.localhost.localstack.cloud:4566/000000000000/arpa-queue"
# if running locally, this will need to be localhost
LOCALSTACK_HOSTNAME=localstack
4 changes: 3 additions & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"test:email": "NODE_ENV=test mocha __tests__/email/*.test.js",
"test:lib": "NODE_ENV=test mocha __tests__/lib/*.test.js",
"test:userimport": "NODE_ENV=test SUPPRESS_EMAIL=true mocha --exit --bail --require __tests__/api/fixtures.js __tests__/db/userImporter._test_.js",
"test": "yarn test:apis && yarn test:arpa && yarn test:db && yarn test:userimport && yarn test:agencyimport && yarn test:email && yarn test:lib"
"test": "yarn test:apis && yarn test:arpa && yarn test:db && yarn test:userimport && yarn test:agencyimport && yarn test:email && yarn test:lib",
"start:arpa-audit-worker": "node src/scripts/arpaAuditReport.js",
"debug:arpa-audit-worker": "nodemon --inspect=0.0.0.0:9229 src/scripts/arpaAuditReport.js"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.312.0",
Expand Down
4 changes: 4 additions & 0 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "website_cloudfront_distribution_id" {
description = "The ID of the CloudFront distribution serving the GOST website."
value = module.website.cloudfront_distribution_id
}
Loading

0 comments on commit 048dda3

Please sign in to comment.