micronaut-gcp icon indicating copy to clipboard operation
micronaut-gcp copied to clipboard

ComputeInstanceMetadata.getMetadata Should Return Full JSON

Open jamesward opened this issue 5 years ago • 1 comments

Right now ComputeInstanceMetadata.getMetadata seems to return just the known metadata in both impls, ie: https://github.com/micronaut-projects/micronaut-core/blob/e3e3dd16f3c8641c02696e45c1f8bd6de5838c22/runtime/src/main/java/io/micronaut/discovery/cloud/gcp/GoogleComputeInstanceMetadataResolver.java#L178

It'd be nice to instead have access to the full JSON returned.

jamesward avatar Apr 02 '19 17:04 jamesward

GoogleComputeInstanceMetadataResolver is broken for me.

(1) The fetch of "http://metadata.google.internal/computeMetadata/v1/project/" returns a 404 on GCE machines.

(2) The fetch of "http://metadata.google.internal/project/v1/project/" returns just the project info:

{                                                                                                                                                                                                                   "attributes":{
    "gke-us-central1...-cidr": "default:10.8.0.0/14",
    "ssh-keys": "...n",
    "sshKeys": "..."
  },
  "numericProjectId": 31415...,
  "projectId": "xyz-123"
}

Dropping '/project/' from the end of the second URL (GoogleComputeMetadataConfiguration#DEFAULT_PROJECTMETADATAURL) fixes the issue for me:

micronaut:
  application:
    gcp:
      metadata:
        metadata-url: "http://metadata.google.internal/computeMetadata/v1/"
        project-metadata-url: "http://metadata.google.internal/computeMetadata/v1/project/"

kfowler avatar Sep 24 '22 13:09 kfowler