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

Release/0.1.0 #8

Merged
merged 67 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
4a97f1f
Initial GitHub Actions workflow
nikki-t Apr 24, 2023
13597e4
Merge branch 'github_workflow' into development
nikki-t Apr 24, 2023
279ac25
Check out github repo
nikki-t Apr 24, 2023
6605c29
Merge branch 'github_workflow' into development
nikki-t Apr 24, 2023
36bd77b
Fix too many arguments
nikki-t Apr 24, 2023
3a6eb0c
Fix too many arguments with pipe on run attribute
nikki-t Apr 24, 2023
10b1492
Test use of environment variables in init command
nikki-t Apr 24, 2023
b34a732
Update deploy step use of prefix env var
nikki-t Apr 24, 2023
f028c96
Remove use of named profile
nikki-t Apr 24, 2023
2855aaf
Export TF_VAR to GitHub ENV
nikki-t Apr 24, 2023
d38c8cd
rovide consistent use of TF_VAR
nikki-t Apr 24, 2023
9cccf36
Test environment variables
nikki-t Apr 24, 2023
f39e77d
Test environment variables
nikki-t Apr 24, 2023
8c39d91
Test environment variables
nikki-t Apr 24, 2023
b03e6b4
Test environment variables definition to Github ENV
nikki-t Apr 24, 2023
a20e039
Test environment variables definition to Github ENV
nikki-t Apr 24, 2023
a3dbada
Implement terraform deployment
nikki-t Apr 24, 2023
f93c335
Add creation of S3 bucket for IDL client files
nikki-t Apr 27, 2023
5cd98b3
Test for deploying to different environments
nikki-t Apr 27, 2023
753eacf
Test for deploying to different environments 1
nikki-t Apr 27, 2023
2f5b7ac
Test for deploying to different environments 2
nikki-t Apr 27, 2023
5239980
Test for deploying to different environments 3
nikki-t Apr 27, 2023
7677c3f
Test for deploying to different environments 4
nikki-t Apr 27, 2023
744cebb
Test for deploying to different environments 5
nikki-t Apr 27, 2023
4309d7b
Test for deploying to different environments 6
nikki-t Apr 27, 2023
babb29a
Test for deploying to different environments 7
nikki-t Apr 27, 2023
93622f4
Test for deploying to different environments 8
nikki-t Apr 27, 2023
1c27093
Test for deploying to different environments 9
nikki-t Apr 27, 2023
91a5eca
Use one deploy file for all deployment environments
nikki-t Apr 27, 2023
8dd68b3
Use one deploy file for all deployment environments
nikki-t Apr 27, 2023
b808323
Remove yml file
nikki-t Apr 27, 2023
0ad84d3
Re-add deploy.yml file to trigger action
nikki-t Apr 27, 2023
bf0ae7f
Test workflow 1
nikki-t Apr 27, 2023
a8d2d53
Rename deployment file
nikki-t Apr 27, 2023
9798f7a
Read aws credentials from target environment variable
nikki-t Apr 27, 2023
661f332
Read aws credentials from target environment variable
nikki-t Apr 27, 2023
acffb1b
Fix format syntax
nikki-t Apr 27, 2023
3f24b9e
Fix reference to target environment
nikki-t Apr 27, 2023
777760e
Support deletion of AWS resources via terraform destroy
nikki-t Apr 28, 2023
a25ef0b
Update posix user for partition & submit
nikki-t Apr 28, 2023
46b4b8f
Allow root posix user for reporter creation of reports
nikki-t May 2, 2023
cc5199b
Move EDL token creation to top-level
nikki-t May 4, 2023
6fe7bb0
Update to central S3 bucket for Generate data
nikki-t May 15, 2023
30c8b4f
Update IDL licenses per dataset
nikki-t May 16, 2023
ae3cade
Remove upload of IDL files
nikki-t May 17, 2023
000121a
Increase max vcpus for batch compute environment
nikki-t Jun 6, 2023
2a7fc83
Set log retention to infinite
nikki-t Jul 20, 2023
a8b8bee
Merge branch 'development' into release/0.1.0
nikki-t Jul 20, 2023
d51dc3b
Create purger ECR repo
nikki-t Jul 25, 2023
e6099a1
Merge branch 'development' into release/0.1.0
nikki-t Jul 26, 2023
72989f5
Remove SSM Parameter Store parameter for EDL token
nikki-t Jul 31, 2023
705bad8
Implement SNYK blocking and report
nikki-t Aug 3, 2023
097f201
Modify snyk test argument to include entire codebase
nikki-t Aug 3, 2023
a13465a
Modify snyk test argument to include entire codebase v1
nikki-t Aug 3, 2023
4cc97b3
Change working directory to 'terraform' for SNYK action
nikki-t Aug 3, 2023
7e9a408
Modify action to use infrastructure as code for SNYK
nikki-t Aug 3, 2023
d456cae
Remove project name for iac action
nikki-t Aug 3, 2023
462e4c3
Remove fail on argument for iac test
nikki-t Aug 3, 2023
20efadf
Modify SNYK action for IAC to scan and report
nikki-t Aug 3, 2023
7b3e702
Merge branch 'development' into release/0.1.0
nikki-t Aug 3, 2023
38d472d
Merge branch 'release/0.1.0' into development
nikki-t Aug 14, 2023
142324f
Add cloudwatch alarm metric for total vCPUs
nikki-t Aug 14, 2023
0dcaca4
Merge branch 'development' into release/0.1.0
nikki-t Aug 14, 2023
26f26b3
Fix typo for alarms email
nikki-t Aug 14, 2023
0500d11
Merge branch 'development' into release/0.1.0
nikki-t Aug 14, 2023
47398da
Move to organizational secrets for AWS creds
nikki-t Aug 16, 2023
072d454
Merge branch 'development' into release/0.1.0
nikki-t Aug 16, 2023
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
39 changes: 0 additions & 39 deletions .github/deploy.yml

This file was deleted.

93 changes: 93 additions & 0 deletions .github/workflows/deploy-generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Main build pipeline that verifies, builds, and deploys the software
name: Build and Deploy
# Events that trigger the workflow
on:
# Trigger based on push to all branches
push:
branches:
- 'development'
- 'feature/**'
- 'release/**'
- 'main'
tags-ignore:
- '*'
# Run workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
name: Build and Deploy
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:

# SIT environment variables
- name: Set Environment Variables
if: |
startsWith(github.ref, 'refs/heads/development') ||
startsWith(github.ref, 'refs/heads/feature')
run: |
echo "TARGET_ENV=SIT" >> $GITHUB_ENV
echo "PREFIX_ENV=service-generate-sit" >> $GITHUB_ENV

# UAT environment variables
- name: Set Environment Variables
if: startsWith(github.ref, 'refs/heads/release')
run: |
echo "TARGET_ENV=UAT" >> $GITHUB_ENV
echo "PREFIX_ENV=service-generate-uat" >> $GITHUB_ENV

# OPS environment variables
- name: Set Environment Variables
if: startsWith(github.ref, 'refs/heads/main')
run: |
echo "TARGET_ENV=OPS" >> $GITHUB_ENV
echo "PREFIX_ENV=service-generate-ops" >> $GITHUB_ENV

# Check out GitHub repo
- uses: actions/checkout@v3

# SNYK scan and report
- name: Run Snyk to test and report
uses: snyk/actions/iac@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: test
args: >
--org=${{ secrets.SNYK_ORG_ID }}
--severity-threshold=high
--report

# Set up Terraform
- name: Setup Terraform
uses: hashicorp/[email protected]
with:
terraform_version: 1.3.7

# Validate Terraform file
- name: Validate Terraform
run: terraform validate -no-color

# Set up TF_VAR and AWS credentials environment variables
- name: TF_VAR and AWS credentials
run: |
echo "TF_VAR_environment=$TARGET_ENV" >> $GITHUB_ENV
echo "TF_VAR_prefix=$PREFIX_ENV" >> $GITHUB_ENV
echo "TF_VAR_cross_account_id=${{ secrets[format('CROSS_ACCOUNT_ID_{0}', env.TARGET_ENV)] }}" >> $GITHUB_ENV
echo "TF_VAR_sns_topic_email=${{ secrets[format('SNS_TOPIC_EMAIL_{0}', env.TARGET_ENV)] }}" >> $GITHUB_ENV
echo "TF_VAR_sns_topic_email_alarms=${{ secrets[format('SNS_TOPIC_EMAIL_ALARMS_{0}', env.TARGET_ENV)] }}" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=${{ secrets[format('AWS_ACCESS_KEY_ID_SERVICES_{0}', env.TARGET_ENV)] }}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV)] }}" >> $GITHUB_ENV
echo "AWS_DEFAULT_REGION=us-west-2" >> $GITHUB_ENV

# Deploy Terraform
- name: Deploy Terraform
working-directory: terraform/
run: |
terraform init -reconfigure \
-backend-config="bucket=${PREFIX_ENV}-tf-state" \
-backend-config="key=generate.tfstate" \
-backend-config="region=${AWS_DEFAULT_REGION}"

terraform apply -auto-approve
42 changes: 0 additions & 42 deletions .github/workflows/deploy.yml

This file was deleted.

18 changes: 12 additions & 6 deletions terraform/generate-batch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ resource "aws_batch_compute_environment" "generate_aqua" {
launch_template_id = aws_launch_template.aws_batch_ce_lt.id
version = aws_launch_template.aws_batch_ce_lt.latest_version
}
max_vcpus = 32
max_vcpus = 128
min_vcpus = 0
security_group_ids = data.aws_security_groups.vpc_default_sg.ids
subnets = data.aws_subnets.private_application_subnets.ids
Expand All @@ -44,7 +44,9 @@ resource "aws_batch_compute_environment" "generate_aqua" {
type = "MANAGED"

depends_on = [
aws_iam_role.aws_batch_service_role
aws_iam_role.aws_batch_service_role,
aws_iam_policy.batch_service_role_policy,
aws_iam_role_policy_attachment.aws_batch_service_role_policy_attach
]
}

Expand Down Expand Up @@ -84,7 +86,7 @@ resource "aws_batch_compute_environment" "generate_terra" {
launch_template_id = aws_launch_template.aws_batch_ce_lt.id
version = aws_launch_template.aws_batch_ce_lt.latest_version
}
max_vcpus = 32
max_vcpus = 128
min_vcpus = 0
security_group_ids = data.aws_security_groups.vpc_default_sg.ids
subnets = data.aws_subnets.private_application_subnets.ids
Expand All @@ -98,7 +100,9 @@ resource "aws_batch_compute_environment" "generate_terra" {
type = "MANAGED"

depends_on = [
aws_iam_role.aws_batch_service_role
aws_iam_role.aws_batch_service_role,
aws_iam_policy.batch_service_role_policy,
aws_iam_role_policy_attachment.aws_batch_service_role_policy_attach
]
}

Expand Down Expand Up @@ -138,7 +142,7 @@ resource "aws_batch_compute_environment" "generate_viirs" {
launch_template_id = aws_launch_template.aws_batch_ce_lt.id
version = aws_launch_template.aws_batch_ce_lt.latest_version
}
max_vcpus = 32
max_vcpus = 128
min_vcpus = 0
security_group_ids = data.aws_security_groups.vpc_default_sg.ids
subnets = data.aws_subnets.private_application_subnets.ids
Expand All @@ -152,7 +156,9 @@ resource "aws_batch_compute_environment" "generate_viirs" {
type = "MANAGED"

depends_on = [
aws_iam_role.aws_batch_service_role
aws_iam_role.aws_batch_service_role,
aws_iam_policy.batch_service_role_policy,
aws_iam_role_policy_attachment.aws_batch_service_role_policy_attach
]
}

Expand Down
47 changes: 39 additions & 8 deletions terraform/generate-cw.tf
Original file line number Diff line number Diff line change
@@ -1,46 +1,77 @@
# CloudWatch Alarm
resource "aws_cloudwatch_metric_alarm" "aws_cloudwatch_ec2_vcpu_alarm" {
alarm_name = "${var.prefix}-ec2-vcpu-alarm"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
threshold = "85"
alarm_description = "Alarm for when EC2 vCPU usage passes the 85% threshold for all available vCPUs in the account."
alarm_actions = [aws_sns_topic.aws_sns_topic_cloudwatch_alarms.arn]
metric_query {
id = "e1"
expression = "m1/SERVICE_QUOTA(m1)*100"
label = "Percentage"
return_data = "true"
}
metric_query {
id = "m1"
metric {
metric_name = "ResourceCount"
namespace = "AWS/Usage"
period = "180"
stat = "Average"
dimensions = {
Type = "Resource"
Service = "EC2"
Resource = "vCPU"
Class = "Standard/OnDemand"
}
}
}
}

# CloudWatch Logs

# Downloader
resource "aws_cloudwatch_log_group" "generate_cw_log_group_downloader" {
name = "/aws/batch/job/${var.prefix}-downloader/"
retention_in_days = 120
retention_in_days = 0
}

resource "aws_cloudwatch_log_group" "generate_cw_log_group_downloader_error" {
name = "/aws/batch/job/${var.prefix}-downloader-errors/"
retention_in_days = 120
retention_in_days = 0
}

# Combiner
resource "aws_cloudwatch_log_group" "generate_cw_log_group_combiner" {
name = "/aws/batch/job/${var.prefix}-combiner/"
retention_in_days = 120
retention_in_days = 0
}

resource "aws_cloudwatch_log_group" "generate_cw_log_group_combiner_error" {
name = "/aws/batch/job/${var.prefix}-combiner-errors/"
retention_in_days = 120
retention_in_days = 0
}

# Processor
resource "aws_cloudwatch_log_group" "generate_cw_log_group_processor" {
name = "/aws/batch/job/${var.prefix}-processor/"
retention_in_days = 120
retention_in_days = 0
}

resource "aws_cloudwatch_log_group" "generate_cw_log_group_processor_error" {
name = "/aws/batch/job/${var.prefix}-processor-errors/"
retention_in_days = 120
retention_in_days = 0
}

# Uploader
resource "aws_cloudwatch_log_group" "generate_cw_log_group_uploader" {
name = "/aws/batch/job/${var.prefix}-uploader/"
retention_in_days = 120
retention_in_days = 0
}

# CloudWatch Logs
resource "aws_cloudwatch_log_group" "generate_cw_log_group_license_returner" {
name = "/aws/batch/job/${var.prefix}-license-returner/"
retention_in_days = 120
retention_in_days = 0
}
18 changes: 18 additions & 0 deletions terraform/generate-ecr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resource "aws_ecr_repository" "download_list_creator" {
name = "${var.prefix}-download-list-creator"
image_tag_mutability = "MUTABLE"
force_delete = true
image_scanning_configuration {
scan_on_push = false
}
Expand All @@ -11,6 +12,7 @@ resource "aws_ecr_repository" "download_list_creator" {
resource "aws_ecr_repository" "partition_submit" {
name = "${var.prefix}-partition-submit"
image_tag_mutability = "MUTABLE"
force_delete = true
image_scanning_configuration {
scan_on_push = false
}
Expand All @@ -20,6 +22,7 @@ resource "aws_ecr_repository" "partition_submit" {
resource "aws_ecr_repository" "downloader" {
name = "${var.prefix}-downloader"
image_tag_mutability = "MUTABLE"
force_delete = true
image_scanning_configuration {
scan_on_push = false
}
Expand All @@ -29,6 +32,7 @@ resource "aws_ecr_repository" "downloader" {
resource "aws_ecr_repository" "combiner" {
name = "${var.prefix}-combiner"
image_tag_mutability = "MUTABLE"
force_delete = true
image_scanning_configuration {
scan_on_push = false
}
Expand All @@ -38,6 +42,7 @@ resource "aws_ecr_repository" "combiner" {
resource "aws_ecr_repository" "processor" {
name = "${var.prefix}-processor"
image_tag_mutability = "MUTABLE"
force_delete = true
image_scanning_configuration {
scan_on_push = false
}
Expand All @@ -47,6 +52,7 @@ resource "aws_ecr_repository" "processor" {
resource "aws_ecr_repository" "uploader" {
name = "${var.prefix}-uploader"
image_tag_mutability = "MUTABLE"
force_delete = true
image_scanning_configuration {
scan_on_push = false
}
Expand All @@ -56,6 +62,7 @@ resource "aws_ecr_repository" "uploader" {
resource "aws_ecr_repository" "license_returner" {
name = "${var.prefix}-license-returner"
image_tag_mutability = "MUTABLE"
force_delete = true
image_scanning_configuration {
scan_on_push = false
}
Expand All @@ -65,6 +72,17 @@ resource "aws_ecr_repository" "license_returner" {
resource "aws_ecr_repository" "reporter" {
name = "${var.prefix}-reporter"
image_tag_mutability = "MUTABLE"
force_delete = true
image_scanning_configuration {
scan_on_push = false
}
}

# Purger
resource "aws_ecr_repository" "purger" {
name = "${var.prefix}-purger"
image_tag_mutability = "MUTABLE"
force_delete = true
image_scanning_configuration {
scan_on_push = false
}
Expand Down
Loading