hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.34k stars 1.74k forks source link

Update `google/image.go` mappings #10401

Open upodroid opened 3 years ago

upodroid commented 3 years ago

Affected Resource(s)

Community Note

While looking at #10368, I noticed that the image mappings at https://github.com/hashicorp/terraform-provider-google/blob/master/google/image.go#L35 need to be updated.

coreos mapping is currently broken:

 REDACTED ī‚° MCW0CDP3YY ī‚° ~ ī‚° $ ī‚° gcloud compute images list --project coreos-cloud | grep coreos-cloud
fedora-coreos-34-20211004-3-1-gcp-x86-64              fedora-coreos-cloud  fedora-coreos-stable                          READY
fedora-coreos-34-20211016-2-1-gcp-x86-64              fedora-coreos-cloud  fedora-coreos-testing                         READY
fedora-coreos-35-20211017-1-0-gcp-x86-64              fedora-coreos-cloud  fedora-coreos-next                            READY
var imageMap = map[string]string{
    "centos":      "centos-cloud",
    "coreos":      "fedora-coreos-cloud", // point to new project
    "debian":      "debian-cloud",
    "opensuse":    "opensuse-cloud",
    "rhel":        "rhel-cloud",
    "sles":        "suse-cloud",
    "ubuntu":      "ubuntu-os-cloud",
        "ubuntu-pro": "ubuntu-os-pro-cloud",
    "windows":     "windows-cloud",
    "windows-sql": "windows-sql-cloud",
        "rocky": "rocky-linux-cloud", // centos replacement

}

https://cloud.redhat.com/learn/topics/coreos https://cloud.google.com/compute/docs/images/os-details

@rileykarson Can we squeeze this change in to v4? I can submit it.

Thanks

b/375672052

rileykarson commented 3 years ago

What'd be backwards-incompatible to change, sorry? If there are just new product mappings, we could add them additively right?

upodroid commented 3 years ago

It would be great to do coreos/fedora-coreos-stable instead of fedora-coreos/fedora-coreos-stable. Redhat ripped out all the images anyway so creating an instance with the image coreos/fedora-coreos-stable should be failing.

upodroid commented 3 years ago

https://registry.terraform.io/modules/matti/compute-instance/google/latest

 REDACTED ī‚° MCW0CDP3YY ī‚° ~ ī‚° Desktop ī‚± Git ī‚± magic-modules ī‚± test ī‚° ī‚  subnetwork-doc-fix ī‚° 1+ ī‚° 13āš‘ ī‚° $ ī‚°  TF_LOG=debug terraform plan
2021/10/25 22:05:51 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2021/10/25 22:05:51 [INFO] Terraform version: 0.14.11  
2021/10/25 22:05:51 [INFO] Go runtime version: go1.15.6
2021/10/25 22:05:51 [INFO] CLI args: []string{"/usr/local/Cellar/tfenv/2.0.0/versions/0.14.11/terraform", "plan"}
2021/10/25 22:05:51 [DEBUG] Attempting to open CLI config file: /Users/REDACTED/.terraformrc
2021/10/25 22:05:51 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021/10/25 22:05:51 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021/10/25 22:05:51 [DEBUG] ignoring non-existing provider search directory /Users/REDACTED/.terraform.d/plugins
2021/10/25 22:05:51 [DEBUG] ignoring non-existing provider search directory /Users/REDACTED/Library/Application Support/io.terraform/plugins
2021/10/25 22:05:51 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2021/10/25 22:05:51 [INFO] CLI command args: []string{"plan"}
2021/10/25 22:05:51 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2021/10/25 22:05:51 [DEBUG] New state was assigned lineage "7e3392f3-090f-f7b3-1202-41de51650bda"
2021/10/25 22:05:51 [DEBUG] checking for provisioner in "."
2021/10/25 22:05:51 [DEBUG] checking for provisioner in "/usr/local/Cellar/tfenv/2.0.0/versions/0.14.11"
2021/10/25 22:05:51 [INFO] Failed to read plugin lock file .terraform/plugins/darwin_amd64/lock.json: open .terraform/plugins/darwin_amd64/lock.json: no such file or directory
2021/10/25 22:05:51 [INFO] backend/local: starting Plan operation
2021-10-25T22:05:51.708+0100 [INFO]  plugin: configuring client automatic mTLS
2021-10-25T22:05:51.734+0100 [DEBUG] plugin: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5]
2021-10-25T22:05:51.741+0100 [DEBUG] plugin: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5 pid=65154
2021-10-25T22:05:51.741+0100 [DEBUG] plugin: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5
2021-10-25T22:05:52.937+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: configuring server automatic mTLS: timestamp=2021-10-25T22:05:52.937+0100
2021-10-25T22:05:52.976+0100 [DEBUG] plugin.terraform-provider-google_v3.89.0_x5: plugin address: address=/var/folders/b1/dthn83bs2qbcrg38qszm22440000gn/T/plugin286134929 network=unix timestamp=2021-10-25T22:05:52.976+0100
2021-10-25T22:05:52.977+0100 [DEBUG] plugin: using plugin: version=5
2021-10-25T22:05:53.124+0100 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-10-25T22:05:53.127+0100 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5 pid=65154
2021-10-25T22:05:53.127+0100 [DEBUG] plugin: plugin exited
2021/10/25 22:05:53 [INFO] terraform: building graph: GraphTypeValidate
2021/10/25 22:05:53 [DEBUG] adding implicit provider configuration provider["registry.terraform.io/hashicorp/google"], implied first by data.google_compute_image.coreos_stable
2021/10/25 22:05:53 [DEBUG] ProviderTransformer: "data.google_compute_image.coreos_stable" (*terraform.NodeValidatableResource) needs provider["registry.terraform.io/hashicorp/google"]
2021/10/25 22:05:53 [DEBUG] ReferenceTransformer: "data.google_compute_image.coreos_stable" references: []
2021/10/25 22:05:53 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/hashicorp/google\"]" references: []
2021/10/25 22:05:53 [DEBUG] Starting graph walk: walkValidate
2021-10-25T22:05:53.131+0100 [INFO]  plugin: configuring client automatic mTLS
2021-10-25T22:05:53.171+0100 [DEBUG] plugin: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5]
2021-10-25T22:05:53.180+0100 [DEBUG] plugin: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5 pid=65161
2021-10-25T22:05:53.180+0100 [DEBUG] plugin: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5
2021-10-25T22:05:53.219+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: configuring server automatic mTLS: timestamp=2021-10-25T22:05:53.218+0100
2021-10-25T22:05:53.262+0100 [DEBUG] plugin.terraform-provider-google_v3.89.0_x5: plugin address: address=/var/folders/b1/dthn83bs2qbcrg38qszm22440000gn/T/plugin268805828 network=unix timestamp=2021-10-25T22:05:53.262+0100
2021-10-25T22:05:53.262+0100 [DEBUG] plugin: using plugin: version=5
2021-10-25T22:05:53.400+0100 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-10-25T22:05:53.404+0100 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5 pid=65161
2021-10-25T22:05:53.404+0100 [DEBUG] plugin: plugin exited
2021/10/25 22:05:53 [INFO] backend/local: plan calling Plan
2021/10/25 22:05:53 [INFO] terraform: building graph: GraphTypePlan
2021/10/25 22:05:53 [DEBUG] adding implicit provider configuration provider["registry.terraform.io/hashicorp/google"], implied first by data.google_compute_image.coreos_stable (expand)
2021/10/25 22:05:53 [DEBUG] ProviderTransformer: "data.google_compute_image.coreos_stable (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/hashicorp/google"]
2021/10/25 22:05:53 [DEBUG] ReferenceTransformer: "data.google_compute_image.coreos_stable (expand)" references: []
2021/10/25 22:05:53 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/hashicorp/google\"]" references: []
2021/10/25 22:05:53 [DEBUG] Starting graph walk: walkPlan
2021-10-25T22:05:53.406+0100 [INFO]  plugin: configuring client automatic mTLS
2021-10-25T22:05:53.436+0100 [DEBUG] plugin: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5]
2021-10-25T22:05:53.448+0100 [DEBUG] plugin: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5 pid=65166
2021-10-25T22:05:53.448+0100 [DEBUG] plugin: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5
2021-10-25T22:05:53.477+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: configuring server automatic mTLS: timestamp=2021-10-25T22:05:53.477+0100
2021-10-25T22:05:53.513+0100 [DEBUG] plugin.terraform-provider-google_v3.89.0_x5: plugin address: address=/var/folders/b1/dthn83bs2qbcrg38qszm22440000gn/T/plugin512376069 network=unix timestamp=2021-10-25T22:05:53.513+0100
2021-10-25T22:05:53.513+0100 [DEBUG] plugin: using plugin: version=5
2021-10-25T22:05:53.610+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:53 [INFO] Authenticating using DefaultClient...: timestamp=2021-10-25T22:05:53.610+0100
2021-10-25T22:05:53.610+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:53 [INFO]   -- Scopes: [https://www.googleapis.com/auth/compute https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/cloud-identity https://www.googleapis.com/auth/ndev.clouddns.readwrite https://www.googleapis.com/auth/devstorage.full_control https://www.googleapis.com/auth/userinfo.email]: timestamp=2021-10-25T22:05:53.610+0100
2021-10-25T22:05:53.610+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:53 [INFO] Authenticating using DefaultClient...: timestamp=2021-10-25T22:05:53.610+0100
2021-10-25T22:05:53.610+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:53 [INFO]   -- Scopes: [https://www.googleapis.com/auth/compute https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/cloud-identity https://www.googleapis.com/auth/ndev.clouddns.readwrite https://www.googleapis.com/auth/devstorage.full_control https://www.googleapis.com/auth/userinfo.email]: timestamp=2021-10-25T22:05:53.610+0100
2021-10-25T22:05:53.610+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:53 [DEBUG] Waiting for state to become: [success]: timestamp=2021-10-25T22:05:53.610+0100
2021-10-25T22:05:54.251+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:54 [INFO] Terraform is using this identity: REDACTED: timestamp=2021-10-25T22:05:54.251+0100
2021/10/25 22:05:54 [DEBUG] Resource instance state not found for node "data.google_compute_image.coreos_stable", instance data.google_compute_image.coreos_stable
2021/10/25 22:05:54 [DEBUG] ReferenceTransformer: "data.google_compute_image.coreos_stable" references: []
2021-10-25T22:05:54.256+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:54 [DEBUG] Fetching latest non-deprecated image from family coreos-stable: timestamp=2021-10-25T22:05:54.256+0100
2021-10-25T22:05:54.256+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:54 [INFO] Instantiating GCE client for path https://compute.googleapis.com/compute/v1/: timestamp=2021-10-25T22:05:54.256+0100
2021-10-25T22:05:54.257+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:54 [DEBUG] Retry Transport: starting RoundTrip retry loop: timestamp=2021-10-25T22:05:54.256+0100
2021-10-25T22:05:54.257+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:54 [DEBUG] Retry Transport: request attempt 0: timestamp=2021-10-25T22:05:54.257+0100
2021-10-25T22:05:54.257+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:54 [DEBUG] Google API Request Details:
---[ REQUEST ]---------------------------------------
GET /compute/v1/projects/coreos-cloud/global/images/family/coreos-stable?alt=json&prettyPrint=false HTTP/1.1
Host: compute.googleapis.com
User-Agent: google-api-go-client/0.5 Terraform/0.14.11 (+https://www.terraform.io) Terraform-Plugin-SDK/2.5.0 terraform-provider-google/3.89.0
X-Goog-Api-Client: gl-go/1.16.2 gdcl/20210830
Accept-Encoding: gzip

-----------------------------------------------------: timestamp=2021-10-25T22:05:54.257+0100
2021-10-25T22:05:54.796+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:54 [DEBUG] Google API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 404 Not Found
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Mon, 25 Oct 2021 21:05:59 GMT
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
  "error": {
    "code": 404,
    "message": "The resource 'projects/coreos-cloud/global/images/family/coreos-stable' was not found",
    "errors": [
      {
        "message": "The resource 'projects/coreos-cloud/global/images/family/coreos-stable' was not found",
        "domain": "global",
        "reason": "notFound"
      }
    ]
  }
}

-----------------------------------------------------: timestamp=2021-10-25T22:05:54.796+0100
2021-10-25T22:05:54.796+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:54 [DEBUG] Retry Transport: Stopping retries, last request failed with non-retryable error: googleapi: got HTTP response code 404 with body: HTTP/2.0 404 Not Found
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Mon, 25 Oct 2021 21:05:59 GMT
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
  "error": {
    "code": 404,
    "message": "The resource 'projects/coreos-cloud/global/images/family/coreos-stable' was not found",
    "errors": [
      {
        "message": "The resource 'projects/coreos-cloud/global/images/family/coreos-stable' was not found",
        "domain": "global",
        "reason": "notFound"
      }
    ]
  }
}: timestamp=2021-10-25T22:05:54.796+0100
2021-10-25T22:05:54.796+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:54 [DEBUG] Retry Transport: Returning after 1 attempts: timestamp=2021-10-25T22:05:54.796+0100
2021-10-25T22:05:54.797+0100 [INFO]  plugin.terraform-provider-google_v3.89.0_x5: 2021/10/25 22:05:54 [DEBUG] Fetched latest non-deprecated image from family coreos-stable: timestamp=2021-10-25T22:05:54.796+0100
2021/10/25 22:05:54 [INFO] backend/local: plan operation completed

Error: error retrieving image information: googleapi: Error 404: The resource 'projects/coreos-cloud/global/images/family/coreos-stable' was not found, notFound

  on test.tf line 1, in data "google_compute_image" "coreos_stable":
   1: data "google_compute_image" "coreos_stable" {

2021-10-25T22:05:54.801+0100 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-10-25T22:05:54.805+0100 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/google/3.89.0/darwin_amd64/terraform-provider-google_v3.89.0_x5 pid=65166
2021-10-25T22:05:54.806+0100 [DEBUG] plugin: plugin exited
 REDACTED ī‚° MCW0CDP3YY ī‚° ~ ī‚° Desktop ī‚± Git ī‚± magic-modules ī‚± test ī‚° ī‚  subnetwork-doc-fix ī‚° 1+ ī‚° 13āš‘ ī‚° ERROR ī‚° $ ī‚°  cat test.tf 
data "google_compute_image" "coreos_stable" {
  family  = "coreos-stable"
  project = "coreos-cloud"
}