title: Creating Route53 Record Sets via Shell Script
body: <p>As a part of my shell script, I am trying to create record sets in AWS Route53. However, using variables in the aws cli within my shell script to create those records set, my variables exported in the Shell scripted are not being passed to the <strong>aws cli command</strong>. </p>
  
  <p>AWS CLI command provided by AWS:</p>
  
  <pre><code>$ aws route53 change-resource-record-sets --hosted-zone-id 1234567890ABC \
    --change-batch file:///path/to/record.json
  </code></pre>
  
  <p>I do not want to create a separate json file on my computer for simplicity purpose, I want to have all my commands and variables within the shell script.</p>
  
  <pre><code>#!/bin/bash
  
  export TARGET_ENVIRONMENT=uat 
  export BASE_ENVIRONMENT_DNS=abcd-External-9982627718-1916763929.us-west-1.elb.amazonaws.com
  
  # Creates route 53 records based on env name
  
  aws route53 change-resource-record-sets --hosted-zone-id 1234567890ABC  
  --change-batch '{ "Comment": "Testing creating a record set", 
  "Changes": [ { "Action": "CREATE", "ResourceRecordSet": { "Name": 
  "$(TARGET_ENVIRONMENT).company.com", "Type": "CNAME", "TTL": 
  120, "ResourceRecords": [ { "Value": "$(BASE_ENVIRONMENT_DNS)" } ] } } ] }'
  </code></pre>
  
  <p>This last command is creating a record set on the AWS Route53 as:</p>
  
  <pre><code>$(TARGET_ENVIRONMENT).company.com
  </code></pre>
  
  <p>with CNAME as </p>
  
  <pre><code>$(BASE_ENVIRONMENT_DNS)
  </code></pre>
  
  <p>and <strong>NOT</strong> really as I want it to be, which is:</p>
  
  <pre><code>uat.company.com
  </code></pre>
  
  <p>with the CNAME:</p>
  
  <pre><code>abcd-External-9982627718-1916763929.us-west-1.elb.amazonaws.com
  </code></pre>
  
  <p>How can I pass the environment variables into my aws cli command within the script? </p>
  
  <p>Any help will be highly appreciated.</p>
  
  <p>Thanks!    </p>