ひげぶろぐ

開発とか組織とかの話

CloudFormation で RDS の ARN を動的に指定したい

Serverless Framework で Aurora Serverless の arn を指定したかったが、若干特殊だったのでメモ。

結論

(執筆時点で)CloudFormationでは RDS( AWS::RDS::DBCluster )のARNを動的に取得する手段を提供しておらず、
こちら をベースに手動で指定するのが代替手段のようです。

調査ログ

Serverless Step Functions

You can use CloudFormation intrinsic functions such as Ref and Fn::GetAtt to reference Lambda functions, SNS topics, SQS queues and DynamoDB tables declared in the same serverless.yml. Since Ref returns different things (ARN, ID, resource name, etc.) depending on the type of CloudFormation resource, please refer to this page to see whether you need to use Ref or Fn::GetAtt.

日本語訳

serverless.yml では RefFn::GetAtt によって参照を実現出来るが、リソースタイプに応じて異なるもの(ARN、ID、リソース名など)を返すため、このページ を参照して、Ref または Fn :: GetAtt のどちらを使用する必要があるかを確認してください。

というわけで以下を参照。

theburningmonk.com

RDSではARNを返してくれなさそうです。

同じ悩みを抱えた人を発見しました。 こちらで紹介されていたのが結論に示した手動指定(文字列連結)の手法です。

stackoverflow.com

TypeORM とか使ってるとRDSのARNが環境変数に欲しくなると思うので、早く RefFn :: GetAtt が対応してくれると嬉しいですね。