1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【OCI】importブロックでオブジェクトストレージをインポートする【リソースマネージャ】

Posted at

importブロックの基本構文

v1.5からimportブロックを利用し、Terraformの管理下にない既存のリソースをインポートできるようになりました。(OCIでの)基本的な書き方は以下の通りです。

main.tf
import {
    to = module.storage.oci_objectstorage_bucket.this["log"]
    id = "<OCID>"
}

module "objectstorage" {
    source = "../../modules/objectstorage"
# 以下略

しかし、オブジェクトストレージをインポートする際にこのように書いても、以下のエラーになります。

Error: can not marshal to path in request for field NamespaceName. Due to can not marshal a nil pointer

Terraformのドキュメントを確認

各ページの最下部にインポート用のコマンドサンプルが記載されており、それによると、ネームスペースとバケット名の記載が必要なようです。

スクリーンショット 2025-02-22 9.11.27.png

オブジェクトストレージのimportブロック

というわけで、オブジェクトストレージの場合は以下のように書くことでインポートできます。

main.tf
import {
    to = module.storage.oci_objectstorage_bucket.this["log"]
    id = "n/<name_space>/b/<bucket_name>"
}
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?