Module mds

Source
Expand description

Metadata Service Credentials type.

Google Cloud environments such as Google Compute Engine (GCE), Google Kubernetes Engine (GKE), or Cloud Run provide a metadata service. This is a local service to the VM (or pod) which (as the name implies) provides metadata information about the VM. The service also provides access tokens associated with the default service account for the corresponding VM.

The default host name of the metadata service is metadata.google.internal. If you would like to use a different hostname, you can set it using the GCE_METADATA_HOST environment variable.

You can use this access token to securely authenticate with Google Cloud, without having to download secrets or other credentials. The types in this module allow you to retrieve these access tokens, and can be used with the Google Cloud client libraries for Rust.

While the Google Cloud client libraries for Rust default to using the types defined in this module. You may want to use said types directly to customize some of the properties of these credentials.

§Example

let credentials: Credentials = Builder::default()
    .with_quota_project_id("my-quota-project")
    .build()?;
let headers = credentials.headers(Extensions::new()).await?;
println!("Headers: {headers:?}");

Structs§

Builder
Creates Credentials instances backed by the Metadata Service.