From 5f5fc52794cf8343f397b81bd0922997ef9f2e6f Mon Sep 17 00:00:00 2001 From: Sarah-Jaine Szekeresh Date: Mon, 23 Nov 2020 11:44:33 -0600 Subject: [PATCH] Terraform: Create S3 bucket for doc upload (#72) * add service instance * add binding * correct service binding * add bucket to sand, stag, prod * take out rds bind Co-authored-by: Sarah-Jaine Szekeresh --- .circleci/config.yml | 2 +- deployment_config/dev_vars.yml | 1 + deployment_config/prod_vars.yml | 1 + deployment_config/sandbox_vars.yml | 1 + deployment_config/staging_vars.yml | 1 + manifest.yml | 3 ++- terraform/dev/main.tf | 14 ++++++++++++++ terraform/prod/main.tf | 14 ++++++++++++++ terraform/sandbox/main.tf | 14 ++++++++++++++ terraform/staging/main.tf | 14 ++++++++++++++ 10 files changed, 63 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8b5c25c821..b1ddd03359 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -109,7 +109,7 @@ parameters: default: "main" type: string sandbox_git_branch: # change to feature branch to test deployment - default: "sj-bind-rds" + default: "sj-tf-s3-init" type: string jobs: build: diff --git a/deployment_config/dev_vars.yml b/deployment_config/dev_vars.yml index 44f3d8f473..49bc2c3e02 100644 --- a/deployment_config/dev_vars.yml +++ b/deployment_config/dev_vars.yml @@ -7,5 +7,6 @@ NODE_ENV: production # This env variable should go away soon in favor of TTA_SMART_HUB_URI REDIRECT_URI_HOST: https://tta-smarthub-dev.app.cloud.gov rds_instance: ttahub-dev +s3_doc_upload_bucket: ttahub-document-upload-dev SESSION_SECRET: ((SESSION_SECRET)) TTA_SMART_HUB_URI: https://tta-smarthub-dev.app.cloud.gov diff --git a/deployment_config/prod_vars.yml b/deployment_config/prod_vars.yml index 502dab021e..f1c3638067 100644 --- a/deployment_config/prod_vars.yml +++ b/deployment_config/prod_vars.yml @@ -7,5 +7,6 @@ NODE_ENV: production # This env variable should go away soon in favor of TTA_SMART_HUB_URI REDIRECT_URI_HOST: https://tta-smarthub-prod.app.cloud.gov rds_instance: ttahub-prod +s3_doc_upload_bucket: ttahub-document-upload-prod SESSION_SECRET: ((SESSION_SECRET)) TTA_SMART_HUB_URI: https://tta-smarthub-prod.app.cloud.gov diff --git a/deployment_config/sandbox_vars.yml b/deployment_config/sandbox_vars.yml index 3ce4e0e7e3..09f42838d5 100644 --- a/deployment_config/sandbox_vars.yml +++ b/deployment_config/sandbox_vars.yml @@ -7,5 +7,6 @@ NODE_ENV: production # This env variable should go away soon in favor of TTA_SMART_HUB_URI REDIRECT_URI_HOST: https://tta-smarthub-sandbox.app.cloud.gov rds_instance: ttahub-sandbox +s3_doc_upload_bucket: ttahub-document-upload-sandbox SESSION_SECRET: ((SESSION_SECRET)) TTA_SMART_HUB_URI: https://tta-smarthub-sandbox.app.cloud.gov diff --git a/deployment_config/staging_vars.yml b/deployment_config/staging_vars.yml index 6884c5e1f5..06129b645e 100644 --- a/deployment_config/staging_vars.yml +++ b/deployment_config/staging_vars.yml @@ -7,5 +7,6 @@ NODE_ENV: production # This env variable should go away soon in favor of TTA_SMART_HUB_URI REDIRECT_URI_HOST: https://tta-smarthub-staging.app.cloud.gov rds_instance: ttahub-staging +s3_doc_upload_bucket: ttahub-document-upload-staging SESSION_SECRET: ((SESSION_SECRET)) TTA_SMART_HUB_URI: https://tta-smarthub-staging.app.cloud.gov diff --git a/manifest.yml b/manifest.yml index 417aa2ff57..785bfcccda 100644 --- a/manifest.yml +++ b/manifest.yml @@ -10,7 +10,8 @@ applications: NODE_ENV: ((NODE_ENV)) # Soon to be removed in favor of TTA_SMART_HUB_URI REDIRECT_URI_HOST: ((REDIRECT_URI_HOST)) - TTA_SMART_HUB_URI: ((TTA_SMART_HUB_URI)) SESSION_SECRET: ((SESSION_SECRET)) + TTA_SMART_HUB_URI: ((TTA_SMART_HUB_URI)) services: - ((rds_instance)) + - ((s3_doc_upload_bucket)) diff --git a/terraform/dev/main.tf b/terraform/dev/main.tf index 82742eff27..dbd6f60b81 100644 --- a/terraform/dev/main.tf +++ b/terraform/dev/main.tf @@ -52,3 +52,17 @@ resource "cloudfoundry_service_instance" "database" { space = data.cloudfoundry_space.space.id service_plan = data.cloudfoundry_service.rds.service_plans["micro-psql"] } + +### +# S3 bucket +### + +data "cloudfoundry_service" "s3" { + name = "s3" +} + +resource "cloudfoundry_service_instance" "document_upload_bucket" { + name = "ttahub-document-upload-${var.env}" + space = data.cloudfoundry_space.space.id + service_plan = data.cloudfoundry_service.s3.service_plans["basic"] +} diff --git a/terraform/prod/main.tf b/terraform/prod/main.tf index a42253239f..5103a02072 100644 --- a/terraform/prod/main.tf +++ b/terraform/prod/main.tf @@ -52,3 +52,17 @@ resource "cloudfoundry_service_instance" "database" { space = data.cloudfoundry_space.space.id service_plan = data.cloudfoundry_service.rds.service_plans["small-psql"] } + +### +# S3 bucket +### + +data "cloudfoundry_service" "s3" { + name = "s3" +} + +resource "cloudfoundry_service_instance" "document_upload_bucket" { + name = "ttahub-document-upload-${var.env}" + space = data.cloudfoundry_space.space.id + service_plan = data.cloudfoundry_service.s3.service_plans["basic"] +} diff --git a/terraform/sandbox/main.tf b/terraform/sandbox/main.tf index aeb4a3d1d1..7f13608834 100644 --- a/terraform/sandbox/main.tf +++ b/terraform/sandbox/main.tf @@ -52,3 +52,17 @@ resource "cloudfoundry_service_instance" "database" { space = data.cloudfoundry_space.space.id service_plan = data.cloudfoundry_service.rds.service_plans["micro-psql"] } + +### +# S3 bucket +### + +data "cloudfoundry_service" "s3" { + name = "s3" +} + +resource "cloudfoundry_service_instance" "document_upload_bucket" { + name = "ttahub-document-upload-${var.env}" + space = data.cloudfoundry_space.space.id + service_plan = data.cloudfoundry_service.s3.service_plans["basic"] +} diff --git a/terraform/staging/main.tf b/terraform/staging/main.tf index 7f93fcd972..9e3318baac 100644 --- a/terraform/staging/main.tf +++ b/terraform/staging/main.tf @@ -52,3 +52,17 @@ resource "cloudfoundry_service_instance" "database" { space = data.cloudfoundry_space.space.id service_plan = data.cloudfoundry_service.rds.service_plans["micro-psql"] } + +### +# S3 bucket +### + +data "cloudfoundry_service" "s3" { + name = "s3" +} + +resource "cloudfoundry_service_instance" "document_upload_bucket" { + name = "ttahub-document-upload-${var.env}" + space = data.cloudfoundry_space.space.id + service_plan = data.cloudfoundry_service.s3.service_plans["basic"] +}