Skip to content

Commit

Permalink
updated sandbox for zander
Browse files Browse the repository at this point in the history
  • Loading branch information
abroddrick committed Aug 4, 2023
1 parent dcf8135 commit 889be27
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 79 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-sandbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
|| startsWith(github.head_ref, 'rb/')
|| startsWith(github.head_ref, 'ko/')
|| startsWith(github.head_ref, 'gd/')
|| startsWith(github.head_ref, 'za/')
outputs:
environment: ${{ steps.var.outputs.environment}}
runs-on: "ubuntu-latest"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/migrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
options:
- stable
- staging
- za
- gd
- rb
- ko
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/reset-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
options:
- stable
- staging
- za
- gd
- rb
- ko
Expand Down
158 changes: 79 additions & 79 deletions ops/scripts/create_dev_sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,85 @@
# infrastructure needed to run get.gov. It can serve for documentation for running
# NOTE: This script was written for MacOS and to be run at the root directory.

if [ -z "$1" ]; then
echo 'Please specify a new space to create (i.e. lmm)' >&2
exit 1
fi

if [ ! $(command -v gh) ] || [ ! $(command -v jq) ] || [ ! $(command -v cf) ]; then
echo "jq, cf, and gh packages must be installed. Please install via your preferred manager."
exit 1
fi

upcase_name=$(printf "%s" "$1" | tr '[:lower:]' '[:upper:]')

read -p "Are you on a new branch? We will have to commit this work. (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
git checkout -b new-dev-sandbox-$1
fi

cf target -o cisa-getgov-prototyping

read -p "Are you logged in to the cisa-getgov-prototyping CF org above? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
cf login -a https://api.fr.cloud.gov --sso
fi

gh auth status
read -p "Are you logged into a Github account with access to cisagov/getgov? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
gh auth login
fi

echo "Creating manifest for $1..."
cp ops/scripts/manifest-sandbox-template.yaml ops/manifests/manifest-$1.yaml
sed -i '' "s/ENVIRONMENT/$1/" "ops/manifests/manifest-$1.yaml"

echo "Adding new environment to settings.py..."
sed -i '' '/getgov-staging.app.cloud.gov/ {a\
'\"getgov-$1.app.cloud.gov\"',
}' src/registrar/config/settings.py

echo "Creating new cloud.gov space for $1..."
cf create-space $1
cf target -o "cisa-getgov-prototyping" -s $1
cf bind-security-group public_networks_egress cisa-getgov-prototyping --space $1
cf bind-security-group trusted_local_networks_egress cisa-getgov-prototyping --space $1

echo "Creating new cloud.gov DB for $1. This usually takes about 5 minutes..."
cf create-service aws-rds micro-psql getgov-$1-database

until cf service getgov-$1-database | grep -q 'The service instance status is succeeded'
do
echo "Database not up yet, waiting..."
sleep 30
done

echo "Creating new cloud.gov credentials for $1..."
django_key=$(python3 -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())')
openssl req -nodes -x509 -days 365 -newkey rsa:2048 -keyout private-$1.pem -out public-$1.crt
login_key=$(base64 -i private-$1.pem)
jq -n --arg django_key "$django_key" --arg login_key "$login_key" '{"DJANGO_SECRET_KEY":$django_key,"DJANGO_SECRET_LOGIN_KEY":$login_key}' > credentials-$1.json
cf cups getgov-credentials -p credentials-$1.json

echo "Now you will need to update some things for Login. Please sign-in to https://dashboard.int.identitysandbox.gov/."
echo "Navigate to our application config: https://dashboard.int.identitysandbox.gov/service_providers/2640/edit?"
echo "There are two things to update."
echo "1. You need to upload the public-$1.crt file generated as part of the previous command."
echo "2. You need to add two redirect URIs: https://getgov-$1.app.cloud.gov/openid/callback/login/ and
https://getgov-$1.app.cloud.gov/openid/callback/logout/ to the list of URIs."
read -p "Please confirm when this is done (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# if [ -z "$1" ]; then
# echo 'Please specify a new space to create (i.e. lmm)' >&2
# exit 1
# fi

# if [ ! $(command -v gh) ] || [ ! $(command -v jq) ] || [ ! $(command -v cf) ]; then
# echo "jq, cf, and gh packages must be installed. Please install via your preferred manager."
# exit 1
# fi

# upcase_name=$(printf "%s" "$1" | tr '[:lower:]' '[:upper:]')

# read -p "Are you on a new branch? We will have to commit this work. (y/n) " -n 1 -r
# echo
# if [[ ! $REPLY =~ ^[Yy]$ ]]
# then
# git checkout -b new-dev-sandbox-$1
# fi

# cf target -o cisa-getgov-prototyping

# read -p "Are you logged in to the cisa-getgov-prototyping CF org above? (y/n) " -n 1 -r
# echo
# if [[ ! $REPLY =~ ^[Yy]$ ]]
# then
# cf login -a https://api.fr.cloud.gov --sso
# fi

# gh auth status
# read -p "Are you logged into a Github account with access to cisagov/getgov? (y/n) " -n 1 -r
# echo
# if [[ ! $REPLY =~ ^[Yy]$ ]]
# then
# gh auth login
# fi

# echo "Creating manifest for $1..."
# cp ops/scripts/manifest-sandbox-template.yaml ops/manifests/manifest-$1.yaml
# sed -i '' "s/ENVIRONMENT/$1/" "ops/manifests/manifest-$1.yaml"

# echo "Adding new environment to settings.py..."
# sed -i '' '/getgov-staging.app.cloud.gov/ {a\
# '\"getgov-$1.app.cloud.gov\"',
# }' src/registrar/config/settings.py

# echo "Creating new cloud.gov space for $1..."
# cf create-space $1
# cf target -o "cisa-getgov-prototyping" -s $1
# cf bind-security-group public_networks_egress cisa-getgov-prototyping --space $1
# cf bind-security-group trusted_local_networks_egress cisa-getgov-prototyping --space $1

# echo "Creating new cloud.gov DB for $1. This usually takes about 5 minutes..."
# cf create-service aws-rds micro-psql getgov-$1-database

# until cf service getgov-$1-database | grep -q 'The service instance status is succeeded'
# do
# echo "Database not up yet, waiting..."
# sleep 30
# done

# echo "Creating new cloud.gov credentials for $1..."
# django_key=$(python3 -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())')
# openssl req -nodes -x509 -days 365 -newkey rsa:2048 -keyout private-$1.pem -out public-$1.crt
# login_key=$(base64 -i private-$1.pem)
# jq -n --arg django_key "$django_key" --arg login_key "$login_key" '{"DJANGO_SECRET_KEY":$django_key,"DJANGO_SECRET_LOGIN_KEY":$login_key}' > credentials-$1.json
# cf cups getgov-credentials -p credentials-$1.json

# echo "Now you will need to update some things for Login. Please sign-in to https://dashboard.int.identitysandbox.gov/."
# echo "Navigate to our application config: https://dashboard.int.identitysandbox.gov/service_providers/2640/edit?"
# echo "There are two things to update."
# echo "1. You need to upload the public-$1.crt file generated as part of the previous command."
# echo "2. You need to add two redirect URIs: https://getgov-$1.app.cloud.gov/openid/callback/login/ and
# https://getgov-$1.app.cloud.gov/openid/callback/logout/ to the list of URIs."
# read -p "Please confirm when this is done (y/n) " -n 1 -r
# echo
# if [[ ! $REPLY =~ ^[Yy]$ ]]
# then
# exit 1
# fi

echo "Database create succeeded and credentials created. Deploying the get.gov application to the new space $1..."
echo "Building assets..."
Expand Down

0 comments on commit 889be27

Please sign in to comment.