0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CloudFormationでエクスポートした値をTerraformから参照する

Last updated at Posted at 2025-06-08

はじめに

前回の記事でCloudFormaitonのStackSetsを使用して以下のような構成を構築し、リソース情報をエクスポートしました。

結果だけ知りたい方はこちらから

MakeNetwork (4).png

今回はTerraformを使用してエクスポートされたAWSリソース情報を参照し、以下の様に構築をやっていきたいと思います。
Trraform1.drawio.png

前提

・Terraform実行環境を用意
 →筆者はCloud9(実態はEC2)から実行しております。この場合EC2にアタッチされ
 たロールの権限を使用する形になるので、RDSとSecretsManagerの権限がある事。

構築

コードは以下のものを使用します。
README1.mdに記載されている手順を使用しています。
https://github.com/Snooze2929/auto-maintenance

構文

TerraformからCloudformationのエクスポートされた値を参照するには以下のようになります。

data "aws_cloudformation_export" "任意のterraform上での名前" {
  name = "cloudformationのコンソールの出力タブの「エクスポート名」を入力"
}

以下、コンソールからの確認方法です。
スクリーンショット 2025-06-08 21.18.35.png

以上です、お疲れ様でした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?