Challenge accessing Endpoint.Address of AWS::RDS::DBInstance from Clouformation

0

Hi All,

I'm trying to create a CNAME for AWS::RDS::DBInstance created by a CF template by doing "Fn::GetAtt": ["MyAppDBInstance", "Endpoint.Address"],

but I get an error that "Unknown attribute in resource type AWS::RDS::DBInstance: Endpoint.Address". According to https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbinstance.html, this should work, but it doesn't. I was really hoping to stay inside CF for something this simple. I'd be super grateful for any help.

Below is the problematics CF code.

"MyDBInstanceCNAME": {
      "Type": "AWS::Route53::RecordSet",
      "Properties": {
        "HostedZoneId": {
          "Ref": "MyPrivateHostedZone"
        },
        "Name": "db.vpc.app.my.com.",
        "Type": "CNAME",
        "TTL": "300",
        "ResourceRecords": [
          {
            "Fn::GetAtt": ["MyAppDBInstance", "Endpoint.Address"]
          }
        ]
      }
    }
  },

Thank you!

profile picture
asked a month ago171 views
2 Answers
0
Accepted Answer

Hello.

When I tried it in my environment, I was able to confirm that it works if you do the following.
It worked when I changed the line break with "Fn::GetAtt".

    "MyDBInstanceCNAME": {
      "Type": "AWS::Route53::RecordSet",
      "Properties": {
        "HostedZoneId": {
          "Ref": "MyPrivateHostedZone"
        },
        "Name": "db.vpc.app.my.com",
        "Type": "CNAME",
        "TTL": "300",
        "ResourceRecords": [
          {
            "Fn::GetAtt": [
              "MyAppDBInstance",
              "Endpoint.Address"
            ]
          }
        ]
      }
    }
profile picture
EXPERT
answered a month ago
profile pictureAWS
EXPERT
reviewed a month ago
  • Thank you. It does work. I suspect this is a problem with a CF parser in my IDE.

0

Below is the entire template as I tried it.
The template was too long to fit into comments, so I split it into parts.

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Test RDS instance",
  "Parameters": {
    "DBName": {
      "Default": "mydb",
      "Description": "RDS Name",
      "Type": "String",
      "MinLength": "1",
      "MaxLength": "64",
      "AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*"
    },
    "DBUser": {
      "NoEcho": "true",
      "Description": "Username",
      "Type": "String",
      "MinLength": "1",
      "MaxLength": "16",
      "AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*"
    },
    "DBPassword": {
      "NoEcho": "true",
      "Description": "Password",
      "Type": "String",
      "MinLength": "8",
      "MaxLength": "41"
    },
    "DBAllocatedStorage": {
      "Default": "20",
      "Description": "Storage Size",
      "Type": "Number",
      "MinValue": "5",
      "MaxValue": "1024"
    },
    "DBInstanceClass": {
      "Description": "Instance Type",
      "Type": "String",
      "Default": "db.t3.micro",
      "AllowedValues": [
        "db.t3.micro",
        "db.t3.small",
        "db.t3.medium",
        "db.t3.large"
      ]
    },
    "MyPrivateHostedZone": {
      "Description": "HostedZone ID",
      "Type": "String"
    }
  },
  "Resources": {
    "MyAppDBInstance": {
      "Type": "AWS::RDS::DBInstance",
      "Properties": {
        "DBName": {
          "Ref": "DBName"
        },
        "Engine": "MySQL",
        "MasterUsername": {
          "Ref": "DBUser"
        },
        "MasterUserPassword": {
          "Ref": "DBPassword"
        },
        "DBInstanceClass": {
          "Ref": "DBInstanceClass"
        },
        "AllocatedStorage": {
          "Ref": "DBAllocatedStorage"
        }
      }
    },
    "MyDBInstanceCNAME": {
      "Type": "AWS::Route53::RecordSet",
      "Properties": {
        "HostedZoneId": {
          "Ref": "MyPrivateHostedZone"
        },
        "Name": "db.vpc.app.my.com",
        "Type": "CNAME",
        "TTL": "300",
        "ResourceRecords": [
          {
            "Fn::GetAtt": [
              "MyAppDBInstance",
              "Endpoint.Address"
            ]
          }
        ]
      }
    }
  },
  "Outputs": {
    "EndPoint": {
      "Description": "MySQL instance endpoint",
      "Value": {
        "Fn::GetAtt": [
          "MyAppDBInstance",
          "Endpoint.Address"
        ]
      }
    }
  }
}
profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions