aws-cloudformationamazon-rdsaws-rds-data-service

Getting an Aurora Serverless Cluster ARN in CloudFormation (Output)


I am having trouble retrieving the ARN for a new RDS Aurora Serverless cluster inside a CloudFormation template.

Can someone please advise on what reference the output value should be below?

Resources:
  RDSCluster:
    Type: AWS::RDS::DBCluster
    Properties:
      MasterUsername: someusername
      MasterUserPassword: somepass
      DatabaseName: mydb
      Engine: aurora-postgresql
      EngineMode: serverless
      EngineVersion: '10.7'
      EnableHttpEndpoint: true
      ScalingConfiguration:
        AutoPause: false
        MaxCapacity: 16
        MinCapacity: 2
        SecondsUntilAutoPause: 300

Outputs:
  RDSClusterARN:
    Description: RDS Cluster ARN
    Export:
      Name: RDSCluster
    Value:
      Ref: RDSCluster # Help! What should this value be?

The output I currently get:

    {
        "OutputKey": "RDSClusterARN",
        "OutputValue": "t1-rdscluster-1i771l6x4amfg",
        "Description": "RDS Cluster ARN",
        "ExportName": "RDSCluster"
    },

Solution

  • Because of current limitations of the AWS CloudFormation AWS::RDS::DBCluster resource, you have to construct its ARN by hand as follows (see also Working with Amazon Resource Names (ARNs) in Amazon RDS)

    !Sub "arn:${AWS::Partition}:rds:${AWS::Region}:${AWS::AccountId}:cluster:${RDSCluster}"