<commit_before>#!/bin/bash
set -eu

echo "Began configure-ert"

export OPSMAN_DOMAIN_OR_IP_ADDRESS="opsman.$pcf_ert_domain"

echo "Generating certs"

source pcf-pipelines/functions/generate_cert.sh

if [[ ${pcf_ert_ssl_cert} == "" || ${pcf_ert_ssl_cert} == "generate" ]]; then
  domains=(
    "*.sys.${pcf_ert_domain}"
    "*.cfapps.${pcf_ert_domain}"
  )

  certificates=$(generate_cert "${domains[*]}")
  pcf_ert_ssl_cert=`echo $certificates | jq --raw-output '.certificate'`
  pcf_ert_ssl_key=`echo $certificates | jq --raw-output '.key'`
fi

saml_domains=(
  "*.sys.${pcf_ert_domain}"
  "*.login.sys.${pcf_ert_domain}"
  "*.uaa.sys.${pcf_ert_domain}"
)

saml_certificates=$(generate_cert "${saml_domains[*]}")
saml_cert_pem=`echo $saml_certificates | jq --raw-output '.certificate'`
saml_key_pem=`echo $saml_certificates | jq --raw-output '.key'`

if [[ "${pcf_iaas}" == "aws" ]]; then
  cd terraform-state
    output_json=$(terraform output --json -state *.tfstate)
    db_host=$(echo $output_json | jq --raw-output '.db_host.value')
    aws_region=$(echo $output_json | jq --raw-output '.region.value')
    aws_access_key=`terraform state show aws_iam_access_key.pcf_iam_user_access_key | grep ^id | awk '{print $3}'`
    aws_secret_key=`terraform state show aws_iam_access_key.pcf_iam_user_access_key | grep ^secret | awk '{print $3}'`
  cd -
elif [[ "${pcf_iaas}" == "gcp" ]]; then
  cd terraform-state
    db_host=$(terraform output --json -state *.tfstate | jq --raw-output '.sql_instance_ip.value')
  cd -

  if [ -z "$db_host" ]; then
    echo Failed to get SQL instance IP from Terraform state file
    exit 1
  fi
elif [[ "${pcf_iaas}" == "azure" ]]; then
  cd terraform-state
    db_host=$(terraform output --json -state *.tfstate | jq --raw-output '.mysql_dns.value')
  cd -
fi

cf_network=$(
  jq -n \
    --arg iaas $pcf_iaas \
    --arg singleton_availability_zone "$pcf_az_1" \
    --arg other_availability_zones "$pcf_az_1,$pcf_az_2,$pcf_az_3" \
    '
    {
      "network": {
        "name": (if $iaas == "aws" then "deployment" else "ert" end),
      },
      "other_availability_zones": ($other_availability_zones | split(",") | map({name: .})),
      "singleton_availability_zone": {
        "name": $singleton_availability_zone
      }
    }
    '
)

echo "Network:"
echo $cf_network

cf_resources=$(
  jq -n \
    --arg terraform_prefix $terraform_prefix \
    --arg iaas $pcf_iaas \
    '
    {
      "consul_server": {"internet_connected": false},
      "nats": {"internet_connected": false},
      "nfs_server": {"internet_connected": false},
      "mysql_proxy": {
        "instances": 0,
        "internet_connected": false
      },
      "mysql": {
        "instances": 0,
        "internet_connected": false
      },
      "backup-prepare": {"internet_connected": false},
      "diego_database": {"internet_connected": false},
      "uaa": {"internet_connected": false},
      "cloud_controller": {"internet_connected": false},
      "ha_proxy": {"internet_connected": false},
      "router": {"internet_connected": false},
      "mysql_monitor": {
        "instances": 0,
        "internet_connected": false
      },
      "clock_global": {"internet_connected": false},
      "cloud_controller_worker": {"internet_connected": false},
      "diego_brain": {"internet_connected": false},
      "diego_cell": {"internet_connected": false},
      "loggregator_trafficcontroller": {"internet_connected": false},
      "syslog_adapter": {"internet_connected": false},
      "syslog_scheduler": {"internet_connected": false},
      "doppler": {"internet_connected": false},
      "tcp_router": {"internet_connected": false},
      "smoke-tests": {"internet_connected": false},
      "push-apps-manager": {"internet_connected": false},
      "notifications": {"internet_connected": false},
      "notifications-ui": {"internet_connected": false},
      "push-pivotal-account": {"internet_connected": false},
      "autoscaling": {"internet_connected": false},
      "autoscaling-register-broker": {"internet_connected": false},
      "nfsbrokerpush": {"internet_connected": false},
      "bootstrap": {"internet_connected": false},
      "mysql-rejoin-unsafe": {"internet_connected": false}
    }

    |

    # ELBs

    if $iaas == "aws" then
      .router |= . + { "elb_names": ["\($terraform_prefix)-Pcf-Http-Elb"] }
      | .diego_brain |= . + { "elb_names": ["\($terraform_prefix)-Pcf-Ssh-Elb"] }
    elif $iaas == "gcp" then
      .router |= . + { "elb_names": ["http:\($terraform_prefix)-http-lb-backend","tcp:\($terraform_prefix)-wss-logs"] }
      | .diego_brain |= . + { "elb_names": ["tcp:\($terraform_prefix)-ssh-proxy"] }<commit_msg>Remove unused resources in SRT deployment<commit_after>#!/bin/bash
set -eu

echo "Began configure-ert"

export OPSMAN_DOMAIN_OR_IP_ADDRESS="opsman.$pcf_ert_domain"

echo "Generating certs"

source pcf-pipelines/functions/generate_cert.sh

if [[ ${pcf_ert_ssl_cert} == "" || ${pcf_ert_ssl_cert} == "generate" ]]; then
  domains=(
    "*.sys.${pcf_ert_domain}"
    "*.cfapps.${pcf_ert_domain}"
  )

  certificates=$(generate_cert "${domains[*]}")
  pcf_ert_ssl_cert=`echo $certificates | jq --raw-output '.certificate'`
  pcf_ert_ssl_key=`echo $certificates | jq --raw-output '.key'`
fi

saml_domains=(
  "*.sys.${pcf_ert_domain}"
  "*.login.sys.${pcf_ert_domain}"
  "*.uaa.sys.${pcf_ert_domain}"
)

saml_certificates=$(generate_cert "${saml_domains[*]}")
saml_cert_pem=`echo $saml_certificates | jq --raw-output '.certificate'`
saml_key_pem=`echo $saml_certificates | jq --raw-output '.key'`

if [[ "${pcf_iaas}" == "aws" ]]; then
  cd terraform-state
    output_json=$(terraform output --json -state *.tfstate)
    db_host=$(echo $output_json | jq --raw-output '.db_host.value')
    aws_region=$(echo $output_json | jq --raw-output '.region.value')
    aws_access_key=`terraform state show aws_iam_access_key.pcf_iam_user_access_key | grep ^id | awk '{print $3}'`
    aws_secret_key=`terraform state show aws_iam_access_key.pcf_iam_user_access_key | grep ^secret | awk '{print $3}'`
  cd -
elif [[ "${pcf_iaas}" == "gcp" ]]; then
  cd terraform-state
    db_host=$(terraform output --json -state *.tfstate | jq --raw-output '.sql_instance_ip.value')
  cd -

  if [ -z "$db_host" ]; then
    echo Failed to get SQL instance IP from Terraform state file
    exit 1
  fi
elif [[ "${pcf_iaas}" == "azure" ]]; then
  cd terraform-state
    db_host=$(terraform output --json -state *.tfstate | jq --raw-output '.mysql_dns.value')
  cd -
fi

cf_network=$(
  jq -n \
    --arg iaas $pcf_iaas \
    --arg singleton_availability_zone "$pcf_az_1" \
    --arg other_availability_zones "$pcf_az_1,$pcf_az_2,$pcf_az_3" \
    '
    {
      "network": {
        "name": (if $iaas == "aws" then "deployment" else "ert" end),
      },
      "other_availability_zones": ($other_availability_zones | split(",") | map({name: .})),
      "singleton_availability_zone": {
        "name": $singleton_availability_zone
      }
    }
    '
)

echo "Network:"
echo $cf_network

cf_resources=$(
  jq -n \
    --arg terraform_prefix $terraform_prefix \
    --arg iaas $pcf_iaas \
    '
    {
      "backup-prepare": {"internet_connected": false},
      "compute": {"internet_connected": false},
      "control": {"internet_connected": false},
      "database": {"internet_connected": false},
      "router": {"internet_connected": false},
      "mysql_monitor": {
        "instances": 0,
        "internet_connected": false
      },
      "tcp_router": {"internet_connected": false},
      "smoke-tests": {"internet_connected": false},
      "push-apps-manager": {"internet_connected": false},
      "notifications": {"internet_connected": false},
      "notifications-ui": {"internet_connected": false},
      "push-pivotal-account": {"internet_connected": false},
      "nfsbrokerpush": {"internet_connected": false},
      "mysql-rejoin-unsafe": {"internet_connected": false}
    }

    |

    # ELBs

    if $iaas == "aws" then
      .router |= . + { "elb_names": ["\($terraform_prefix)-Pcf-Http-Elb"] }
      | .diego_brain |= . + { "elb_names": ["\($terraform_prefix)-Pcf-Ssh-Elb"] }
    elif $iaas == "gcp" then
      .router |= . + { "elb_names": ["http:\($terraform_prefix)-http-lb-backend","tcp:\($terraform_prefix)-wss-logs"] }
      | .diego_brain |= . + { "elb_names": ["tcp:\($terraform_prefix)-ssh-proxy"] }
{'fraction_non_alphanumeric': 0.1758307434855367, 'fraction_numerical': 0.002151565861821659, 'mean_word_length': 3.620099392600773, 'pattern_counts': {'":': 112, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1048165', 'n_tokens_mistral': 3040, 'n_tokens_neox': 2985, 'n_words': 552}