Skip to content

Commit

Permalink
Merge pull request #1976 from transcom/cg_fix_secure_migrations
Browse files Browse the repository at this point in the history
Add SECURE_MIGRATION_BUCKET_NAME to config file for deployment
  • Loading branch information
kahlouie committed Apr 6, 2019
2 parents 70a84d8 + 32d6f63 commit 9b25a58
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -656,11 +656,11 @@ run_prod_migrations:

.PHONY: run_staging_migrations
run_staging_migrations:
SECURE_MIGRATIONS_BUCKET_NAME=transcom-ppp-app-staging-us-west-2 ./scripts/run-prod-migrations
SECURE_MIGRATION_BUCKET_NAME=transcom-ppp-app-staging-us-west-2 ./scripts/run-prod-migrations

.PHONY: run_experimental_migrations
run_experimental_migrations:
SECURE_MIGRATIONS_BUCKET_NAME=transcom-ppp-app-experimental-us-west-2 ./scripts/run-prod-migrations
SECURE_MIGRATION_BUCKET_NAME=transcom-ppp-app-experimental-us-west-2 ./scripts/run-prod-migrations

#
# ----- END PROD_MIGRATION TARGETS -----
Expand Down
4 changes: 4 additions & 0 deletions config/app-migrations.container-definition.json
Expand Up @@ -32,6 +32,10 @@
"name": "SECURE_MIGRATION_DIR",
"value": "/migrate/secure/"
},
{
"name": "SECURE_MIGRATION_BUCKET_NAME",
"value": "transcom-ppp-app-{{ .environment }}-us-west-2"
},
{
"name": "DB_HOST",
"value": "{{ .db_host }}"
Expand Down
6 changes: 3 additions & 3 deletions scripts/apply-secure-migration.sh
Expand Up @@ -69,12 +69,12 @@ case $SECURE_MIGRATION_SOURCE in

sslmode=${PSQL_SSL_MODE:-require}

if [ -z "${SECURE_MIGRATIONS_BUCKET_NAME:-}" ]; then
echo "error: \$SECURE_MIGRATIONS_BUCKET_NAME needs to be set"
if [ -z "${SECURE_MIGRATION_BUCKET_NAME:-}" ]; then
echo "error: \$SECURE_MIGRATION_BUCKET_NAME needs to be set"
exit 1
fi

readonly url="s3://${SECURE_MIGRATIONS_BUCKET_NAME}/secure-migrations/$1"
readonly url="s3://${SECURE_MIGRATION_BUCKET_NAME}/secure-migrations/$1"

echo "Applying secure migrations from S3 using url $url"

Expand Down
6 changes: 3 additions & 3 deletions scripts/run-prod-migrations
Expand Up @@ -7,7 +7,7 @@ set -eu -o pipefail

# Required env vars for apply-secure-migration.sh
export SECURE_MIGRATION_SOURCE=s3
export SECURE_MIGRATIONS_BUCKET_NAME="${SECURE_MIGRATIONS_BUCKET_NAME:-transcom-ppp-app-prod-us-west-2}"
export SECURE_MIGRATION_BUCKET_NAME="${SECURE_MIGRATION_BUCKET_NAME:-transcom-ppp-app-prod-us-west-2}"
export PSQL_SSL_MODE=disable
export DB_NAME="${DB_NAME_PROD_MIGRATIONS:-prod_migrations}"
export DB_PORT="${DB_PORT_PROD_MIGRATIONS:-5434}"
Expand Down Expand Up @@ -40,14 +40,14 @@ command -v aws 2> /dev/null | grep "ppp-infra/bin/aws" &> /dev/null || \
)

# Test AWS command and freshen AWS session token
aws s3 ls "${SECURE_MIGRATIONS_BUCKET_NAME}/secure-migrations" > /dev/null
aws s3 ls "${SECURE_MIGRATION_BUCKET_NAME}/secure-migrations" > /dev/null

#
# Run migrations
#

echo
echo -e "\e[33mUsing ${SECURE_MIGRATIONS_BUCKET_NAME} to gather secure migrations\e[39m"
echo -e "\e[33mUsing ${SECURE_MIGRATION_BUCKET_NAME} to gather secure migrations\e[39m"
echo
proceed "Running production migrations against the ${DB_NAME} database. This will delete everything in that db."

Expand Down

0 comments on commit 9b25a58

Please sign in to comment.