Skip to content

Commit

Permalink
Add environment variables to serverless and terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
aloftus23 committed Nov 6, 2023
1 parent 3b05728 commit 5f80360
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions backend/env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ staging:
CLOUDWATCH_BUCKET_NAME: cisa-crossfeed-staging-cloudwatch
SQS_QUEUE_URL: { Ref: WorkerQueue }
STAGE: staging
PE_CLUSTER_NAME: pe-staging-worker
SHODAN_QUEUE_URL: ${ssm:/crossfeed/staging/SHODAN_QUEUE_URL}
SHODAN_SERVICE_NAME: pe-staging-shodan

prod:
DB_DIALECT: 'postgres'
Expand Down Expand Up @@ -82,6 +85,9 @@ prod:
CLOUDWATCH_BUCKET_NAME: cisa-crossfeed-prod-cloudwatch
SQS_QUEUE_URL: { Ref: WorkerQueue }
STAGE: prod
PE_CLUSTER_NAME: pe-prod-worker
SHODAN_QUEUE_URL: ${ssm:/crossfeed/prod/SHODAN_QUEUE_URL}
SHODAN_SERVICE_NAME: pe-prod-shodan

dev-vpc:
securityGroupIds:
Expand Down
2 changes: 1 addition & 1 deletion backend/src/tasks/scanExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const sqs = new AWS.SQS();
export const handler: Handler = async (event) => {
try {
let desiredCount;
const clusterName = process.env.FARGATE_CLUSTER_NAME!;
const clusterName = process.env.PE_CLUSTER_NAME!;

// Get the Control SQS record and message body
const sqsRecord: SQSRecord = event.Records[0];
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/pe_worker.tf
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ resource "aws_ecs_task_definition" "pe_worker" {
},
{
"name": "SHODAN_QUEUE_URL",
"valueFrom": "${aws_ssm_parameter.shodan_queue_url.arn}"
"valueFrom": "${data.aws_ssm_parameter.shodan_queue_url.arn}"
}
]
}
Expand Down
1 change: 1 addition & 0 deletions infrastructure/prod.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ssm_sixgill_client_id = "/crossfeed/prod/SIXGILL_CLIENT_ID"
ssm_sixgill_client_secret = "/crossfeed/prod/SIXGILL_CLIENT_SECRET"
ssm_lg_api_key = "/crossfeed/prod/LG_API_KEY"
ssm_lg_workspace_name = "/crossfeed/prod/LG_WORKSPACE_NAME"
ssm_shodan_queue_url = "/crossfeed/prod/SHODAN_QUEUE_URL"
cloudfront_name = "Crossfeed Prod Frontend"
db_group_name = "crossfeed-prod-db-group"
worker_ecs_repository_name = "crossfeed-prod-worker"
Expand Down
1 change: 1 addition & 0 deletions infrastructure/stage.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ssm_sixgill_client_id = "/crossfeed/staging/SIXGILL_CLIENT_ID"
ssm_sixgill_client_secret = "/crossfeed/staging/SIXGILL_CLIENT_SECRET"
ssm_lg_api_key = "/crossfeed/staging/LG_API_KEY"
ssm_lg_workspace_name = "/crossfeed/staging/LG_WORKSPACE_NAME"
ssm_shodan_queue_url = "/crossfeed/staging/SHODAN_QUEUE_URL"
cloudfront_name = "Crossfeed Staging Frontend"
db_group_name = "crossfeed-staging-db-group"
worker_ecs_repository_name = "crossfeed-staging-worker"
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ variable "ssm_lg_workspace_name" {
default = "/crossfeed/staging/LG_WORKSPACE_NAME"
}

variable "ssm_shodan_queue_url" {
description = "ssm_shodan_queue_url"
type = string
default = "/crossfeed/staging/SHODAN_QUEUE_URL"
}

variable "cloudfront_name" {
description = "cloudfront_name"
type = string
Expand Down
1 change: 1 addition & 0 deletions infrastructure/worker.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ resource "aws_iam_role_policy" "worker_task_execution_role_policy" {
"${data.aws_ssm_parameter.sixgill_client_secret.arn}",
"${data.aws_ssm_parameter.lg_api_key.arn}",
"${data.aws_ssm_parameter.lg_workspace_name.arn}",
"${data.aws_ssm_parameter.shodan_queue_url.arn}",
"${aws_ssm_parameter.es_endpoint.arn}"
]
}
Expand Down

0 comments on commit 5f80360

Please sign in to comment.