以下の内容はhttps://kakakakakku.hatenablog.com/entry/2026/02/16/102259より取得しました。


Terraform で region を指定したリソースをインポートする場合は @<region> を付ける

Terraform AWS Provider v6 から「リソースレベルで」リージョンを指定できる.たとえばプロバイダーで ap-northeast-1 リージョンを指定しつつ,Amazon ECR リポジトリを us-east-1 リージョンにデプロイする場合は以下のように実装すれば OK👌

resource "aws_ecr_repository" "main" {
  region = "us-east-1"

  name = "sandbox-repository"
}

詳しくは前にブログにまとめてある.

kakakakakku.hatenablog.com

この region プロパティを指定したリソースをインポートする場合に以下のように import block を実装すると

import {
  to = aws_ecr_repository.main
  id = "sandbox-repository"
}

リソースが見つからずに Cannot import non-existent remote object というエラーが出てしまう🔥

╷
│ Error: Cannot import non-existent remote object
│ 
│ While attempting to import an existing object to "aws_ecr_repository.main", the provider detected that no object exists with the given id. Only pre-existing objects can be imported; check that the id is correct and
│ that it is associated with the provider's configured region or endpoint, or use "terraform apply" to create a new remote object for this resource.
╵

Enhanced Region Support というドキュメントに書いてある通り,インポートするときに ID の末尾に @us-east-1 を付ける必要がある.Amazon ECR リポジトリの場合は sandbox-repository@us-east-1 となる❗️

import {
  to = aws_ecr_repository.main
  id = "sandbox-repository@us-east-1"
}

覚えておこう \( 'ω')/




以上の内容はhttps://kakakakakku.hatenablog.com/entry/2026/02/16/102259より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14