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 3 years have passed since last update.

GCP VM Managerの設定

Last updated at Posted at 2021-04-07

はじめに

GCEのOSバージョンの一覧を取得するためにGCPにVM Managerを設定する。
GCPコンソールからも設定できるが、IaC(Infrastructure as Code)したいのでTerraformでの手順をまとめる。

Terraformを実行するサービスアカウントにroles/iam.serviceAccountUserを追加

gcloud projects add-iam-policy-binding <PROJECT_ID> --member serviceAccount:<SERVICE_ACCOUNT>@<PROJECT_ID>.iam.gserviceaccount.com --role roles/iam.serviceAccountUser

OS Config API, Container Analysis APIの有効化

terraform
# OS Config API
resource "google_project_service" "osconfig" {
  project = var.project
  service = "osconfig.googleapis.com"
}

# Container Analysis API
resource "google_project_service" "containeranalysis" {
  project = var.project
  service = "containeranalysis.googleapis.com"
}

メタデータにenable-osconfig, enable-guest-attributesをTRUEに設定

terraform
resource "google_compute_project_metadata" "default" {
  metadata = {
    enable-osconfig = "TRUE"
    enable-guest-attributes = "TRUE"
  }
}

インスタンスにログインしてOS Configエージェントがインストールされているか確認

sudo systemctl status google-osconfig-agent

ローカルPCからOS情報を取得できることを確認

gcloud compute instances os-inventory describe <VM_NAME>

参考

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?