TerraformでGCEの静的内部IPの設定

概要

TerraformでGCPのGCEのローカルIPを固定する設定の例です。

内部IPを10.146.0.1に設定している例です。

resource "google_compute_instance" "default" {
  name         = "test"
  machine_type = "n1-standard-1"
  zone         = "asia-northeast1-a"

  boot_disk {
    initialize_params {
      image = "centos-cloud/centos-7"
    }
  }

  network_interface {
    network       = "default"
    network_ip    = "10.146.0.1"
    access_config = {}
  }
}