LoginSignup
0
0

More than 3 years have passed since last update.

GCP Access Context Managerの設定をterraform importする方法

Posted at

Access Context Managerの設定をimportしようとして意外とハマったのでメモ

terraform importするにはサービスアカウントが必要なので、何かしらのプロジェクトでサービスアカウントを作成

サービスアカウントにAccessContextManagerのimport出来る権限をつけるが
:no_good_tone1: プロジェクト設定のIAMで権限をつける
:ok_woman_tone1: 組織設定のIAMで権限をつける

サービスアカウントを作ったプロジェクトを選んだままIAM画面でサービスアカウントに権限を付けてもimportが出来ない

以下のようなエラーが出る

Error: Error reading AccessContextManagerAccessLevel "accessPolicies/1234/accessLevels/hogehoge": goog
leapi: Error 403: The caller does not have permission

組織レベルの設定のIAMで権限を付けないといけない

つける権限はこちらに記載されている以下の4つ
- Access Context Manager 管理者(roles/accesscontextmanager.policyAdmin)
- Access Context Manager 編集者(roles/accesscontextmanager.policyEditor)
- Access Context Manager リーダー(roles/accesscontextmanager.policyReader)
- Resource Manager 組織閲覧者(roles/resourcemanager.organizationViewer)

これらの権限をつけたら google_access_context_manager_access_level のresourceがあるtfファイル作ってimport可能

terraform import google_access_context_manager_access_level.access-level accessPolicies/1234/accessLevels/hogehoge
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