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
已提問 2 個月前檢視次數 188 次
2 個答案
0
已接受的答案

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
專家
已回答 2 個月前
profile pictureAWS
專家
已審閱 2 個月前
  • 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
專家
已回答 2 個月前
profile picture
專家
已審閱 2 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南