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?

More than 1 year has passed since last update.

aws terraform importブロック使ってみた(簡易メモ)

Posted at

はじめに

importブロック便利だなと思いつつ、
まだ試せていなかったので、簡単に手順をまとめました。

手順

1.既存リソースの準備(S3)

$ aws s3 mb s3://tf-import-example

2.terraformコード化

resource "aws_s3_bucket" "example" {
  bucket = "tf-import-example" # 1.と同じバケット名
}

3.importブロックの追加

import {
  id = "tf-import-example" # リソース識別子
  to = aws_s3_bucket.example # import先
}

4.terraform実行

$ terraform init
$ terraform plan
$ terraform apply

その他

  • import を実行したあとの import ブロックは削除してOK
    • 残しておいてもいいが無意味

参考

https://zenn.dev/kou_pg_0131/articles/tf-import-block
https://dev.classmethod.jp/articles/terraform-v1-5-0-import-and-check-sample/

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?