-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from podaac/release/0.1.0
Release/0.1.0
- Loading branch information
Showing
12 changed files
with
228 additions
and
124 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.