Skip to content

Commit

Permalink
Prod Release 2023-09-29 - Take 2 (#2004)
Browse files Browse the repository at this point in the history
  • Loading branch information
as1729 authored Sep 30, 2023
1 parent 92bbfc6 commit e43deb9
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 49 deletions.
50 changes: 23 additions & 27 deletions packages/client/src/helpers/constants.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
const billOptions = [
'All Bills',
'Department of Justice',
'Bipartisan Safer Communities Act',
'Consumer Product Safety Commission',
'Coronavirus',
'Corporation for National and Community Service',
'Denali Commission',
'Department of Agriculture',
'Department of Commerce',
'Department of Defense',
'Department of Education',
'Department of Energy',
'Department of the Treasury',
'12.005',
'Department of Health and Human Services',
'Department of Defense',
'Denali Commission',
'Bipartisan Safer Communities Act',
'National Aeronautics & Space Administration',
'Department of Labor',
'Department of Homeland Security',
'Department of Housing and Urban Development',
'Department of Transportation',
'Infrastructure Investment and jobs Act',
'Corporation for National and Community Service',
'Department of Justice',
'Department of Labor',
'Department of the Interior',
'National Foundation on the Arts and the Humanities',
'Department of Homeland Security',
'National Archives & Records Administration',
'Department of the Treasury',
'Department of Transportation',
'Department of Veterans Affairs',
'Environmental Protection Agency',
'Inflation Reduction Act',
'Infrastructure Investment and Jobs Act',
'Coronavirus',
'Department of Agriculture',
'Consumer Product Safety Commission',
'Infrastructure Investment and Jobs Act (IIJA)',
'Small Business Administration',
'Office of National Drug Control Policy',
'Department of Education',
'Library of Congress',
'National Aeronautics & Space Administration',
'National Archives & Records Administration',
'National Council on Disability',
'Nuclear Regulatory Commission',
'Social Security Administration',
'Department of Veterans Affairs',
'National Foundation on the Arts and the Humanities',
'National Science Foundation',
'Library of Congress',
'Nuclear Regulatory Commission',
'Office of National Drug Control Policy',
'Department of Commerce',
'Inflation Reduction Act',
'Small Business Administration',
'Social Security Administration',
];

module.exports = {
Expand Down
24 changes: 14 additions & 10 deletions packages/server/src/arpa_reporter/lib/audit-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ async function createObligationSheet(periodId, domain, tenantId) {
// select active reporting periods and sort by date
const reportingPeriods = await getPreviousReportingPeriods(periodId, undefined, tenantId);
log('retrieved previous reporting periods', {
periodId, domain, reportingPeriods, fn: 'createObligationSheet',
periodId, domain, fn: 'createObligationSheet', count: reportingPeriods.length,
});

const rows = await Promise.all(
reportingPeriods.map(async (period) => {
log('creating row for reporting period', { period, fn: 'createObligationSheet' });
log('creating row for reporting period', { period: { id: period.id }, periodId, fn: 'createObligationSheet' });
const uploads = await usedForTreasuryExport(period.id, tenantId);
log('retrived uploads for period', { period, fn: 'createObligationSheet' });
log('retrived uploads for period', { period: { id: period.id }, periodId, fn: 'createObligationSheet' });
const records = await recordsForReportingPeriod(period.id, tenantId);
log('retrieved records', { period, fn: 'createObligationSheet' });
log('retrieved records', { period: { id: period.id }, periodId, fn: 'createObligationSheet' });

log('mapping uploads', { period, fn: 'createObligationSheet' });
log('mapping uploads', { period: { id: period.id }, periodId, fn: 'createObligationSheet' });
return Promise.all(uploads.map((upload) => {
log('initializing empty row', {
period: {
Expand Down Expand Up @@ -162,7 +162,7 @@ async function createObligationSheet(periodId, domain, tenantId) {
}

async function createProjectSummaries(periodId, domain, tenantId) {
log('called createProjectSummaries()', { periodId, domain });
log('called createProjectSummaries()', { periodId, domain, fn: 'createProjectSummaries' });
const records = await mostRecentProjectRecords(periodId, tenantId);
log('retrieved most recent project records', {
fn: 'createProjectSummaries', periodId, domain, record_count: records.length,
Expand Down Expand Up @@ -237,7 +237,7 @@ function getRecordsByProject(records) {
}

async function createReportsGroupedByProject(periodId, tenantId) {
log('called createProjectSummaries()', { periodId });
log('called createReportsGroupedByProject()', { periodId, fn: 'createReportsGroupedByProject' });
const records = await recordsForProject(periodId, tenantId);
log('retrieved records for project', { fn: 'createReportsGroupedByProject', count: records.length });
const recordsByProject = getRecordsByProject(records);
Expand Down Expand Up @@ -307,7 +307,7 @@ async function createReportsGroupedByProject(periodId, tenantId) {
}

async function createKpiDataGroupedByProject(periodId, tenantId) {
log('called createKpiDataGroupedByProject()', { periodId });
log('called createKpiDataGroupedByProject()', { periodId, fn: 'createKpiDataGroupedByProject' });
const records = await recordsForProject(periodId, tenantId);
log('retrieved records for project', { fn: 'createKpiDataGroupedByProject', count: records.length });
const recordsByProject = getRecordsByProject(records);
Expand Down Expand Up @@ -436,7 +436,8 @@ async function generateAndSendEmail(requestHost, recipientEmail, tenantId = useT
};
try {
console.log(uploadParams);
log('uploading report', { uploadParams });
console.log(uploadParams);
log('uploading report', { bucket: uploadParams.Bucket, key: uploadParams.Key });
await s3.send(new PutObjectCommand(uploadParams));
await module.exports.sendEmailWithLink(reportKey, recipientEmail);
} catch (err) {
Expand All @@ -448,14 +449,17 @@ async function generateAndSendEmail(requestHost, recipientEmail, tenantId = useT
async function processSQSMessageRequest(message) {
let requestData;
try {
requestData = JSON.parse(message.Body).detail;
requestData = JSON.parse(message.Body);
} catch (e) {
console.error('Error parsing request data from SQS message:', e);
return false;
}

try {
const user = await getUser(requestData.userId);
if (!user) {
throw new Error(`user not found: ${requestData.userId}`);
}
generateAndSendEmail(ARPA_REPORTER_BASE_URL, user.email, user.tenant_id);
} catch (e) {
console.error('Failed to generate and send audit report', e);
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/arpa_reporter/services/records.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ async function recordsForProject(periodId, tenantId) {
const reportingPeriods = await getPreviousReportingPeriods(periodId, undefined, tenantId);

const allRecords = await Promise.all(
reportingPeriods.map(({ id }) => recordsForReportingPeriod(id)),
reportingPeriods.map(({ id }) => recordsForReportingPeriod(id, tenantId)),
);

const projectRecords = allRecords
Expand Down
10 changes: 5 additions & 5 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ module "consume_grants_to_postgres_security_group" {
allow_all_egress = true
}

module "arpa_audit_report_to_postgres_security_group" {
module "arpa_audit_report_security_group" {
source = "cloudposse/security-group/aws"
version = "2.2.0"

namespace = var.namespace
vpc_id = data.aws_ssm_parameter.vpc_id.value
attributes = ["arpa_audit_report", "postgres"]
attributes = ["arpa_audit_report"]
allow_all_egress = true
}

Expand Down Expand Up @@ -135,7 +135,7 @@ module "api" {
subnet_ids = local.private_subnet_ids
security_group_ids = [
module.consume_grants_to_postgres_security_group.id,
module.arpa_audit_report_to_postgres_security_group.id,
module.arpa_audit_report_security_group.id,
]

# Cluster
Expand Down Expand Up @@ -227,7 +227,7 @@ module "arpa_audit_report" {

# Networking
subnet_ids = local.private_subnet_ids
security_group_ids = [module.api_to_postgres_security_group.id]
security_group_ids = [module.arpa_audit_report_security_group.id]

# Task configuration
ecs_cluster_name = join("", aws_ecs_cluster.default.*.name)
Expand Down Expand Up @@ -310,7 +310,7 @@ module "postgres" {
ingress_security_groups = {
from_api = module.api_to_postgres_security_group.id
from_consume_grants = module.consume_grants_to_postgres_security_group.id
from_arpa_audit_report = module.arpa_audit_report_to_postgres_security_group.id
from_arpa_audit_report = module.arpa_audit_report_security_group.id
}

prevent_destroy = var.postgres_prevent_destroy
Expand Down
4 changes: 2 additions & 2 deletions terraform/modules/gost_api/task.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ locals {

module "api_container_definition" {
source = "cloudposse/ecs-container-definition/aws"
version = "0.60.1"
version = "0.61.0"

container_name = "api"
container_image = local.api_container_image
Expand Down Expand Up @@ -95,7 +95,7 @@ module "api_container_definition" {

module "datadog_container_definition" {
source = "cloudposse/ecs-container-definition/aws"
version = "0.60.1"
version = "0.61.0"

container_name = "datadog"
container_image = "public.ecr.aws/datadog/agent:latest"
Expand Down
8 changes: 4 additions & 4 deletions terraform/prod.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ website_managed_waf_rules = {
}
}
website_feature_flags = {
useNewTable = false,
useNewTable = true,
}

// ECS Cluster
Expand All @@ -51,9 +51,9 @@ api_container_image_tag = "stable"
api_default_desired_task_count = 3
api_minumum_task_count = 2
api_maximum_task_count = 5
api_enable_grants_scraper = true
api_enable_grants_digest = true
api_enable_saved_search_grants_digest = false
api_enable_grants_scraper = false
api_enable_grants_digest = false
api_enable_saved_search_grants_digest = true
api_log_retention_in_days = 30
api_datadog_environment_variables = {
DD_PROFILING_ENABLED = true,
Expand Down

0 comments on commit e43deb9

Please sign in to comment.