Skip to content

Instantly share code, notes, and snippets.

@glaracuente
Created December 12, 2019 16:54
Show Gist options
  • Save glaracuente/fd66ebdde0fc5fd178f42eac5f425bbe to your computer and use it in GitHub Desktop.
Save glaracuente/fd66ebdde0fc5fd178f42eac5f425bbe to your computer and use it in GitHub Desktop.
#!/bin/bash
environmentX=$1
aws_output=$(aws elb describe-load-balancers --region=us-east-1 |grep "\"DNSName\": \"internal-$environmentX")
if [[ ${#aws_output} -lt 50 ]]; then
echo "No elbs were found for ${environmentX}".
exit
fi
internal_con=$(echo "$aws_output" |grep 'con-' |cut -d':' -f2 |cut -d'"' -f2)
internal_int=$(echo "$aws_output" |grep 'int-' |cut -d':' -f2 |cut -d'"' -f2)
echo "resource \"aws_route53_record\" \"$environmentX\" {
name = \"$environmentX\"
type = \"CNAME\"
records = [
\"$internal_con\",
]
ttl = 300
zone_id = \"\${aws_route53_zone.k8s_ext.id}\"
allow_overwrite = \"\${var.allow_overwrite}\"
}
resource \"aws_route53_record\" \"${environmentX}_api\" {
name = \"${environmentX}-api\"
type = \"CNAME\"
records = [
\"$internal_int\",
]
ttl = 300
zone_id = \"\${aws_route53_zone.k8s_ext.id}\"
allow_overwrite = \"\${var.allow_overwrite}\"
}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment