title: CloudFormation PublicDnsName returns wrong value if elastic IP is set
body: <p>I use following function can get PublicDnsName:</p>
  
  <pre><code>        {
           "Fn::GetAtt": [
             "EC2Instance",
             "PublicDnsName"
           ]
         }
  </code></pre>
  
  <p>However, after I assign static ip to the instance, this above function <strong>SOMETIMES</strong> return the newly PublicDnsName and <strong>sometimes</strong> it returns <strong>old</strong> PublicDnsName (the dns name that before we assign static IP).</p>
  
  <p>Have you seen this issue before? I'm scatching my head to figure out why. Please let me know what seem to be the issue or how I should resolve it. Thanks.</p>
  
  <p>Following is my partial CloudFormation template:</p>
  
  <pre><code>{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Graphite and StatsD",
    "Parameters": {
      "InstanceType": {
        "Type": "String",
        "Default": "m1.xlarge"
      }
    },
    "Mappings": {
      "RegionMap": {
        "us-east-1": {
          "AMI": "ami-5ffaa636",
          "RecordSetName": "ue1"
        },
        "us-west-1": {
          "AMI": "ami-4ad8ef0f",
          "RecordSetName": "uw1"
        },
        "us-west-2": {
          "AMI": "ami-66049d56",
          "RecordSetName": "uw2"
        },
        "eu-west-1": {
          "AMI": "ami-861bfbf1",
          "RecordSetName": "ew1"
        },
        "ap-southeast-1": {
          "AMI": "ami-42134610",
          "RecordSetName": "as1"
        },
        "ap-southeast-2": {
          "AMI": "ami-c98b17f3",
          "RecordSetName": "as2"
        },
        "ap-northeast-1": {
          "AMI": "ami-0733a806",
          "RecordSetName": "an1"
        },
        "sa-east-1": {
          "AMI": "ami-2bac0a36",
          "RecordSetName": "se1"
        }
      }
    },
    "Resources": {
      "ElasticIP": {
        "Type": "AWS::EC2::EIP"
      },
      "EIPAssociation": {
        "Type": "AWS::EC2::EIPAssociation",
        "Properties": {
          "InstanceId": {
            "Ref": "EC2Instance"
          },
          "EIP": {
            "Ref": "ElasticIP"
          }
        }
      },
      "DNSRecords": {
        "Type": "AWS::Route53::RecordSetGroup",
        "Properties": {
          "HostedZoneName": "mydomain.com.",
          "RecordSets": [
            {
              "Name": {
                "Fn::Join": [
                  "",
                  [
                    "graphite-",
                    {
                      "Fn::FindInMap": [
                        "RegionMap",
                        {
                          "Ref": "AWS::Region"
                        },
                        "RecordSetName"
                      ]
                    },
                    ".mydomain.com"
                  ]
                ]
              },
              "Type": "CNAME",
              "TTL": "300",
              "ResourceRecords": [
                {
                  "Fn::GetAtt": [
                    "EC2Instance",
                    "PublicDnsName"
                  ]
                }
              ]
            }
          ]
        }
      },
      "EC2Instance": {
        "Type": "AWS::EC2::Instance",
        "Properties": {
          "KeyName": "MyKeyName",
          "SecurityGroups": [
            "MySecurityGroup"
          ],
          "ImageId": {
            "Fn::FindInMap": [
              "RegionMap",
              {
                "Ref": "AWS::Region"
              },
              "AMI"
            ]
          },
          "InstanceType": {
            "Ref": "InstanceType"
          },
          "Tags": [
            {
              "Key": "Name",
              "Value": "graphite-statsd"
            }
          ],
          "UserData": {
            "Fn::Base64": {
              "Fn::Join": [
                "",
                [
                  ....
                  VERY LONG SHELL INSTALL SCRIPT
                  ....
                ]
              ]
            }
          }
        }
      }
    }
  }
  </code></pre>