ユーザ用ツール

サイト用ツール


terraform

terraform

import

手動で作ったリソースをterraform管理にする

例)既存のsnsトピック hoge を管理下に持ってくる

既存トピックに対する resource を作成

resource "aws_sns_topic" "hoge" {
}

既存トピックの id(arn) をimport

$ terraform import aws_sns_topic.hoge arn:aws:sns:ap-northeast-1:000000000000:hoge

管理下に入ったことを確認

$ terraform state show aws_sns_topic.hoge

resourceを修正

resource "aws_sns_topic" "hoge" {
  name = "hoge"
}

設定の確認、変更点がなければOK

terraform plan --target aws_sns_topic.hoge

ログを出す

以下の変数をセット

$ export TF_LOG=INFO
$ export TF_LOG_PATH=./terraform.log

TF_LOGに設定できるログレベルは TRACE/DEBUG/INFO/WARN/ERROR

terraform.txt · 最終更新: 2019/06/12 06:48 by nullpon