diff --git a/bin/cloudgov/create-domain-services-for-space b/bin/cloudgov/create-domain-services-for-space new file mode 100755 index 0000000000..ba77732577 --- /dev/null +++ b/bin/cloudgov/create-domain-services-for-space @@ -0,0 +1,88 @@ +#!/usr/bin/env bash + +# Create the domains and domain services for the "cms" and "www" hosts in one of these spaces: +# - dev +# - dr +# - stage +# - prod +# +# This is a one-time operation we would need to do when re-creating a space. +# NB: the DNS records for the domain must already be set up, including the _acme-challenge +# records, as described at https://cloud.gov/docs/services/external-domain-service/#how-to-create-an-instance-of-this-service + + +# we might be running in circleci +if [ -f /home/circleci/project/env.local ]; then + . /home/circleci/project/env.local +fi +# we might be running from a local dev machine +SCRIPT_DIR="$(dirname "$0")" +if [ -f $SCRIPT_DIR/env.local ]; then + . $SCRIPT_DIR/env.local +fi +if [ -f ./env.local ]; then + . ./env.local +fi +if [ -f $SCRIPT_DIR/../deploy/includes ]; then + . $SCRIPT_DIR/../deploy/includes +else + echo Cannot find $SCRIPT_DIR/../deploy/includes + exit 1 +fi + +# just testing? +if [ x$1 = x"--dryrun" ]; then + export echo=echo + shift +fi + +SPACE=${1:-please-provide-space-name-as-first-argument} +SPACE=$(echo "$SPACE" | tr '[:upper:]' '[:lower:]') +assertCurSpace $SPACE + +ORG=$(getOrg) + +# -p domain-with-cdn-dedicated-waf -c '{"alarm_notification_email": "usagov-website-alerts@gsa.gov"}' +CMS_DOMAIN="cms-${SPACE}.usa.gov" +WWW_DOMAIN="beta-${SPACE}.usa.gov" +WWW_DOMAIN_PLAN="domain-with-cdn-dedicated-waf" +if [ ${SPACE} = 'prod' ]; then + CMS_DOMAIN="cms.usa.gov" + WWW_DOMAIN="www.usa.gov" +fi + +# dev and dr are restricted to the GSA network, so a cloudfront CDN isn't appropriate +if [ ${SPACE} = 'dev' ]; then + WWW_DOMAIN_PLAN="domain" +fi +if [ ${SPACE} = 'dr' ]; then + WWW_DOMAIN_PLAN="domain" +fi + +echo "Creating domains ${CMS_DOMAIN} and ${WWW_DOMAIN}" +$echo cf create-domain $ORG $CMS_DOMAIN +$echo cf create-domain $ORG $WWW_DOMAIN + +echo +echo "Creating external domain services. Each of these could take awhile to come up." + +# Passing JSON to this command inline works on the command line, but not when it is +# called from the shell (why?). So we create a file and pass that instead. +tmpfile=$(mktemp) +domainjson=`printf "{\"domains\": \"%s\"}" ${CMS_DOMAIN}` +echo $domainjson > $tmpfile + +echo cf create-service external-domain domain ${SPACE}-cms-usagov-domain -c $tmpfile +$echo cf create-service external-domain domain ${SPACE}-cms-usagov-domain -c $tmpfile + +if [ ${WWW_DOMAIN_PLAN} = "domain" ]; then + domainjson=`printf "{\"domains\": \"%s\"}" ${WWW_DOMAIN}` +else + domainjson=`printf "{\"domains\": \"%s\", \"alarm_notification_email\": \"usagov-website-alerts@gsa.gov\"}" ${WWW_DOMAIN}` +fi +echo $domainjson > $tmpfile +echo cf create-service external-domain domain-with-cdn ${SPACE}-www-usagov-domain -c $tmpfile +$echo cf create-service external-domain domain-with-cdn ${SPACE}-www-usagov-domain -c $tmpfile + +rm $tmpfile +# The above commands output a message saying how to check them, so we don't need to explain further. diff --git a/bin/cloudgov/deploy-waf b/bin/cloudgov/deploy-waf index a856d8a950..08a944bce8 100755 --- a/bin/cloudgov/deploy-waf +++ b/bin/cloudgov/deploy-waf @@ -30,14 +30,6 @@ SPACE=$( cf target | grep space: | awk '{ print $2 }') # The Image digest for this tag should be looked up from cloud.gov storage # Any tag with a stored Image digest should be referenced by hash instead of tag -# Need to create 'external-domain' service for custom routes: *.usa.gov -# cf delete-service dev-usagov-domain -# cf create-service external-domain domain dev-usagov-domain -c '{"domains": "cms-dev.usa.gov,beta-dev.usa.gov"}' -# cf create-service external-domain domain-with-cdn stage-usagov-domain -c '{"domains": "cms-stage.usa.gov,beta-stage.usa.gov"}' -# cf create-service external-domain domain-with-cdn prod-www-usagov-domain -c '{"domains": "beta.usa.gov"}' -# cf create-service external-domain domain prod-cms-usagov-domain -c '{"domains": "cms.usa.gov"}' -# cf service prod-cms-usagov-domain - if ! command -v jq >/dev/null; then printf "\nMust have JQ installed\n" exit 1