-
Notifications
You must be signed in to change notification settings - Fork 9
Terraform, Lambda, and Frontend Changes #104
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
Open
gt1074
wants to merge
57
commits into
main
Choose a base branch
from
Terraform2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 39 commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
4f34a7a
Only necessary changes
gt1074 3f5ed96
Implementing localstack Pro / terraform-local (tflocal)
gt1074 0e4cddb
Revert "Implementing localstack Pro / terraform-local (tflocal)"
gt1074 a2fea97
Create test file / Universal Region Usage / Bug fixes
gt1074 9fde3df
wibl-python: cloud: AWS: Update conversion start lambda permissions a…
selimnairb 5c996d1
Merge pull request #84 from CCOMJHC/conversion-start-lambda-permissio…
gt1074 37b4044
Creating new terraform module parallel to configure-manager-ecs.sh
gt1074 527cc7c
Merge remote-tracking branch 'origin/Terraform2' into Terraform2
gt1074 8dbd839
Changing lambda configuration due to aws policy change
gt1074 e3e6d30
Bug fixes
gt1074 6259df1
Fixing .proto config files / Lambda permission change / Changing ecs …
gt1074 6d26614
Adding force delete to ecr repos
gt1074 473bc37
Initial implementation of Manager/Frontend ECS / bug fixing
gt1074 72c1ebc
Adding terraform specific proto documents / Removing local stack from…
gt1074 f523b85
Starting rds implementation
gt1074 5d457cf
Embed RDS inside manager ecs module / configure security group and db…
gt1074 3507725
Frontend RDS instance / Expanded container definitions / Cloudwatch g…
gt1074 2cd656f
Implementing Django s3 static storage / Static file adjustments / Fro…
gt1074 834148a
Moving Static Files
gt1074 3a99f5b
Starting TLS frontend implementation
gt1074 20590ac
Cloudfront additions, vpc permission changes, static bucket access ch…
gt1074 c846761
Fixing gitignore for static files / adding back missing files
gt1074 fb989bb
Changing Bulma to correct file extension / addressing cors issues wit…
gt1074 ca2f925
Large scale changes to cloud front / adding elastic cache to replace …
gt1074 6b385f3
Deletion marking, no lost metadata / Adjusting S3 permissions for lam…
gt1074 cd07b5e
Fixing state implementation
gt1074 91a86b3
Started development with AWS Location Services to replace the Open St…
gt1074 d38cd47
Fix map to include style and glyph information
gt1074 3cda58e
Adding SSM auth string management / Submission lambda bug fixes / Man…
gt1074 ef0412b
Adding SSM auth string management / Submission lambda bug fixes / Man…
gt1074 9dbd3a0
Socket consumer changes / Index event manager bug fixes
gt1074 6f099b2
Merge branch 'main' into Terraform2
gt1074 a6d928a
Move Terraform folder into AWS folder / Add build instruction / add d…
gt1074 94dafbb
Documentation changes / removing commented code / adding extra nat ga…
gt1074 4293785
Adding "geojson" extension support for wibl manager downloading
gt1074 e42e4c3
Changing lambda configurations to no longer have verbose output / rem…
gt1074 81ad96f
Adding s3 state storage for the wibl-python terraform configuration
gt1074 fe83a0a
Adding secret generation script, changing readme to include the script.
gt1074 a1c9768
Updating documentation
gt1074 1ef1541
Fixing statistics endpoint bug / Adding plotly as static instead of c…
gt1074 b439187
Bug Fixes
gt1074 42cf86a
tfvars now points to the generate_secret script for creating values.
gt1074 ee141a4
Adding the terraform bootstrap process from the upload server
gt1074 386fa03
Updating README to account for manual variable replacement in the s3 …
gt1074 7141815
Upadting README to account for the necessary update of the configurat…
gt1074 4b07c17
Fixing the bounding box bug.
gt1074 15f6cee
Merge branch '105-bounding-box-bugfixes' into Terraform2
gt1074 ceb65c9
Updating the gitignore to include terraform.tfvars and default_auth.txt
gt1074 3b385e9
Updating documentation / Removing auth files from git (tfvars, defaul…
gt1074 48966a1
Updating gitignore
gt1074 8f71a9c
Changed bucket configurations / raising minimum terraform, aws, and d…
gt1074 38861c1
Updated DetailTable to use Enums instead of magic numbers for the fil…
gt1074 752b22b
Commented code removal
gt1074 29527f2
Fixed bug in shell variable parsing
gt1074 5776ed9
Changed git auto line space settings to keep LR for the required scri…
gt1074 5d44c71
Readme style changed
gt1074 cccc8c3
Updated setup instructions / Changed the Terraform boostrap to genera…
gt1074 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
File renamed without changes.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,48 @@ | ||
| # Terraform AWS Build Instructions | ||
|
|
||
| ## Setup | ||
| The following software items must be installed and configured before continuing | ||
|
|
||
| - Docker | ||
| - AWS CLI | ||
| - Terraform | ||
|
|
||
| ### 1. Change default configurations | ||
| Edit the `terraform.tfvars` file as needed. Due to the nature of the cloud, all AWS components must have name unique to | ||
| its region and type. Thus, the default names provided will most likely already be taken. | ||
|
|
||
| #### Important Variables To Consider: | ||
| - region: Must be a valid AWS region code. Consider this list for available regions. [AWS_Region_List](https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-regions.html) | ||
| - auth_file_name: Like it describes in the configuration file, it must be set to a valid file name that exists in the | ||
| `auth` folder. The easiest solution is to copy and paste your string into the `default_auth.txt` file. | ||
| - frontend_secret_key: Following the directions is the configuration file to generate a Django secret is highly | ||
| recommended. The script is located [here](./generate_secret.sh) | ||
| - origin_secret: This password phrase adds an extra level of security between the CloudFront module and the | ||
| frontend's load balancer. Run the generate_secret script again to create a new value. | ||
| - DCDB_provider_id: Replace with your given DCDB provider id. | ||
| - DCDB_mode: By default the test mode is active. To switch to using the production URL, set this variable to 1. | ||
|
|
||
| ### 2. Building The Lambda Package | ||
| This step only works if `docker` is currently running on your system. Inside the outer `AWS` folder is a script called | ||
| `build-lambda.sh`, run this script. Even if the script is successful, there may still be a lingering `build` or `package` | ||
| folder, pay these no mind and continue to the next step. | ||
|
|
||
| ### 3. Building The System With Terraform | ||
|
gt1074 marked this conversation as resolved.
Outdated
|
||
| This step also requires `docker` to work, so ensure it is running. First, run the `plan.sh` script inside the Terraform | ||
| folder. This is where any you will be alerted of any misconfigured or missing variables. If script says "Plan: 125 to | ||
| add, 0 to change, 0 to destroy." without returning any errors, run the next script `build.sh`. If you do experience any | ||
| errors, you need to then run the `destroy.sh` script before you can attempt another build. | ||
|
|
||
| #### IMPORTANT: The system can take upwards of 15 to 25 minutes to fully build or destroy. | ||
|
|
||
| ### How To Tear Down The System | ||
| #### WARNING: This script destroys ALL resources, meaning all data put into the system will be unrecoverable. | ||
| To destroy the resources in the cloud, including all AWS and docker resources, run the `destroy.sh` script. | ||
| The following resources tend to take longer to destroy than their counter-parts. | ||
| - module.configure-manager-ecs.aws_internet_gateway.ig_public | ||
| - module.configure-manager-ecs.aws_cloudfront_distribution.frontend | ||
|
|
||
| This is mostly due to a bug with AWS's resource state management system. AWS believes select lambda functions are still | ||
| running, which can often leave multiple components hanging on each other waiting for the other to be destroyed. If it | ||
| seems like this might be the case, using ^c to cancel the script and rerunning it may solve the issue. | ||
|
|
||
|
gt1074 marked this conversation as resolved.
Outdated
|
This file contains hidden or 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 @@ | ||
| Replace with your DCDB auth string |
This file contains hidden or 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,52 @@ | ||
| resource "aws_s3_bucket" "incoming_bucket" { | ||
| bucket = var.incoming_bucket | ||
| force_destroy = true | ||
| } | ||
|
|
||
| resource "aws_s3_bucket" "staging_bucket" { | ||
| bucket = var.staging_bucket | ||
| force_destroy = true | ||
| } | ||
|
|
||
| resource "aws_s3_bucket" "viz_bucket" { | ||
| bucket = var.viz_bucket | ||
| force_destroy = true | ||
| } | ||
|
|
||
| resource "aws_s3_bucket" "static_bucket" { | ||
| bucket = var.static_bucket | ||
| force_destroy = true | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "static_bucket_policy" { | ||
| statement { | ||
| actions = ["s3:GetObject"] | ||
|
|
||
| resources = [ | ||
| "${aws_s3_bucket.static_bucket.arn}/static/*" | ||
| ] | ||
|
|
||
| principals { | ||
| type = "AWS" | ||
| identifiers = [var.oai_iam_arn] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_policy" "static" { | ||
| bucket = aws_s3_bucket.static_bucket.id | ||
| policy = data.aws_iam_policy_document.static_bucket_policy.json | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_cors_configuration" "static_files" { | ||
| bucket = aws_s3_bucket.static_bucket.id | ||
|
|
||
| cors_rule { | ||
| allowed_methods = ["GET", "HEAD"] | ||
| allowed_origins = [var.alb_url] | ||
| allowed_headers = ["*"] | ||
| max_age_seconds = 3000 | ||
| } | ||
| depends_on = [aws_s3_bucket.static_bucket] | ||
| } | ||
|
|
18 changes: 18 additions & 0 deletions
18
wibl-python/scripts/cloud/AWS/Terraform/buckets/outputs.tf
This file contains hidden or 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,18 @@ | ||
| output "incoming_bucket_arn" { | ||
| value = aws_s3_bucket.incoming_bucket.arn | ||
| } | ||
|
|
||
| output "incoming_bucket_id" { | ||
| value = aws_s3_bucket.incoming_bucket.id | ||
| } | ||
| output "staging_bucket_arn" { | ||
| value = aws_s3_bucket.staging_bucket.arn | ||
| } | ||
|
|
||
| output "viz_bucket_arn" { | ||
| value = aws_s3_bucket.viz_bucket.arn | ||
| } | ||
|
|
||
| output "static_bucket_regional_dns_name" { | ||
| value = aws_s3_bucket.static_bucket.bucket_regional_domain_name | ||
| } |
28 changes: 28 additions & 0 deletions
28
wibl-python/scripts/cloud/AWS/Terraform/buckets/variables.tf
This file contains hidden or 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,28 @@ | ||
| variable "incoming_bucket" { | ||
| description = "Name of the incoming s3 bucket" | ||
| type = string | ||
| } | ||
|
|
||
| variable "staging_bucket" { | ||
| description = "Name of the staging s3 bucket" | ||
| type = string | ||
| } | ||
|
|
||
| variable "viz_bucket" { | ||
| description = "Name of the viz s3 bucket" | ||
| type = string | ||
| } | ||
|
|
||
| variable "static_bucket" { | ||
| description = "Name of the static bucket" | ||
| type = string | ||
| } | ||
|
|
||
| variable "alb_url" { | ||
| description = "Frontend cloudfront distribution url" | ||
| type = string | ||
| } | ||
|
|
||
| variable "oai_iam_arn" { | ||
| type = string | ||
| } |
This file contains hidden or 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,7 @@ | ||
| #!/bin/bash | ||
|
|
||
| WIBL_BUILD_LOCATION=$(git rev-parse --show-toplevel)/wibl-python/awsbuild | ||
| ACCOUNT_NUMBER=$(aws sts get-caller-identity --query Account --output text) | ||
| SRC_PATH=$(git rev-parse --show-toplevel)/wibl-python | ||
| TF_LOG=DEBUG | ||
| terraform init && terraform apply -auto-approve -var="src_path=${SRC_PATH}" -var="wibl_build_path=${WIBL_BUILD_LOCATION}" -var="account_number=${ACCOUNT_NUMBER}" |
This file contains hidden or 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,6 @@ | ||
| #!/bin/bash | ||
|
|
||
| WIBL_BUILD_LOCATION=$(git rev-parse --show-toplevel)/wibl-python/awsbuild | ||
| ACCOUNT_NUMBER=$(aws sts get-caller-identity --query Account --output text) | ||
| SRC_PATH=$(git rev-parse --show-toplevel)/wibl-python | ||
| terraform destroy -auto-approve -var="wibl_build_path=${WIBL_BUILD_LOCATION}" -var="src_path=${SRC_PATH}" -var="account_number=${ACCOUNT_NUMBER}" |
This file contains hidden or 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 @@ | ||
| dd if=/dev/random bs=4096 count=1 status=none | sha512sum --quiet |
99 changes: 99 additions & 0 deletions
99
wibl-python/scripts/cloud/AWS/Terraform/lambda/configure_roles.tf
This file contains hidden or 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,99 @@ | ||
| resource "aws_iam_role" "conversion_lambda_role" { | ||
| name = var.conversion_lambda_role_name | ||
| assume_role_policy = data.aws_iam_policy_document.lambda-trust-policy-doc.json | ||
| } | ||
|
|
||
| resource "aws_iam_role" "validation_lambda_role" { | ||
| name = var.validation_lambda_role_name | ||
| assume_role_policy = data.aws_iam_policy_document.lambda-trust-policy-doc.json | ||
| } | ||
|
|
||
| resource "aws_iam_role" "submission_lambda_role" { | ||
| name = var.submission_lambda_role_name | ||
| assume_role_policy = data.aws_iam_policy_document.lambda-trust-policy-doc.json | ||
| } | ||
|
|
||
| resource "aws_iam_role" "conversion_start_lambda_role" { | ||
| name = var.conversion_start_lambda_role_name | ||
| assume_role_policy = data.aws_iam_policy_document.lambda-trust-policy-doc.json | ||
| } | ||
|
|
||
| resource "aws_iam_role" "viz_lambda_role" { | ||
| name = var.viz_lambda_role_name | ||
| assume_role_policy = data.aws_iam_policy_document.lambda-trust-policy-doc.json | ||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "lambda_basic_policy_attach" { | ||
| name = "lambda_basic_policy_attach" | ||
|
|
||
| roles = [aws_iam_role.conversion_lambda_role.name, aws_iam_role.submission_lambda_role.name, | ||
| aws_iam_role.validation_lambda_role.name, aws_iam_role.viz_lambda_role.name, aws_iam_role.conversion_start_lambda_role.name] | ||
|
|
||
| policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
|
|
||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "lambda_nic_policy_attach" { | ||
| name = "lambda_nic_policy_attach" | ||
|
|
||
| roles = [aws_iam_role.conversion_lambda_role.name, aws_iam_role.submission_lambda_role.name, | ||
| aws_iam_role.validation_lambda_role.name, aws_iam_role.viz_lambda_role.name, aws_iam_role.conversion_start_lambda_role.name] | ||
|
|
||
| policy_arn = aws_iam_policy.lambda-nic-policy.arn | ||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "conversion_lambda_s3_access_policy_attach" { | ||
| name = "lambda_s3_access_policy_attach" | ||
|
|
||
| roles = [aws_iam_role.conversion_lambda_role.name] | ||
|
|
||
| policy_arn = aws_iam_policy.lambda-s3-access-all-policy.arn | ||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "conversion_lambda_sns_validation_policy_attach" { | ||
| name = "lambda_sns_validation_policy_attach" | ||
| roles = [aws_iam_role.conversion_lambda_role.name] | ||
| policy_arn = aws_iam_policy.lambda-sns-access-validation.arn | ||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "validation_lambda_s3_access_policy_attach" { | ||
| name = "validation_lambda_s3_access_policy_attach" | ||
| roles = [aws_iam_role.validation_lambda_role.name] | ||
| policy_arn = aws_iam_policy.lambda-s3-access-staging-policy.arn | ||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "validation_lambda_sns_submission_policy_attach" { | ||
| name = "validation_lambda_sns_submission_policy_attach" | ||
| roles = [aws_iam_role.validation_lambda_role.name] | ||
| policy_arn = aws_iam_policy.lambda-sns-access-submission.arn | ||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "submission_lambda_s3_access_policy_attach" { | ||
| name = "submission_lambda_s3_access_policy_attach" | ||
| roles = [aws_iam_role.submission_lambda_role.name] | ||
| policy_arn = aws_iam_policy.lambda-s3-access-staging-policy.arn | ||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "submission_lambda_sns_submitted_policy_attach" { | ||
| name = "submission_lambda_sns_submitted_policy_attach" | ||
| roles = [aws_iam_role.submission_lambda_role.name] | ||
| policy_arn = aws_iam_policy.lambda-sns-access-submitted.arn | ||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "submission_lambda_ssm_policy_attach" { | ||
| name = "submission_lambda_ssm_policy_attach" | ||
| roles = [aws_iam_role.submission_lambda_role.name] | ||
| policy_arn = aws_iam_policy.lambda-ssm-access-submission.arn | ||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "conversion_start_lambda_s3_access_policy_attach" { | ||
| name = "conversion_start_lambda_s3_access_policy_attach" | ||
| roles = [aws_iam_role.conversion_start_lambda_role.name] | ||
| policy_arn = aws_iam_policy.lambda-s3-access-incoming-policy.arn | ||
| } | ||
|
|
||
| resource "aws_iam_policy_attachment" "conversion_start_lambda_sns_conversion_policy_attach" { | ||
| name = "conversion_start_lambda_sns_conversion_policy_attach" | ||
| roles = [aws_iam_role.conversion_start_lambda_role.name] | ||
| policy_arn = aws_iam_policy.lambda-sns-access-conversion.arn | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.