Socket
Socket
Sign inDemoInstall

gcp-metadata

Package Overview
Dependencies
56
Maintainers
13
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gcp-metadata

Get the metadata from a Google Cloud Platform environment


Version published
Weekly downloads
8.4M
decreased by-23.23%
Maintainers
13
Install size
3.96 MB
Created
Weekly downloads
 

Package description

What is gcp-metadata?

The gcp-metadata npm package is a library that allows users to query Google Cloud Platform's (GCP) metadata service for information about the currently running instance and project. This can be useful for applications that need to understand their environment within GCP, such as retrieving instance attributes or project details.

What are gcp-metadata's main functionalities?

Instance Metadata

Retrieve metadata of the current GCP instance. This includes details like the instance ID, zone, and custom metadata.

const gcpMetadata = require('gcp-metadata');

async function getInstanceMetadata() {
  if (await gcpMetadata.isAvailable()) {
    const instanceMetadata = await gcpMetadata.instance();
    console.log(instanceMetadata);
  }
}
getInstanceMetadata();

Project Metadata

Fetch metadata of the current GCP project. This can include project-wide attributes like project ID and numeric project number.

const gcpMetadata = require('gcp-metadata');

async function getProjectMetadata() {
  if (await gcpMetadata.isAvailable()) {
    const projectMetadata = await gcpMetadata.project();
    console.log(projectMetadata);
  }
}
getProjectMetadata();

Check Metadata Server Availability

Determine if the GCP metadata server is available and reachable from the instance.

const gcpMetadata = require('gcp-metadata');

async function checkAvailability() {
  const isAvailable = await gcpMetadata.isAvailable();
  console.log('Metadata service available:', isAvailable);
}
checkAvailability();

Other packages similar to gcp-metadata

Readme

Source

gcp-metadata

Get the metadata from a Google Cloud Platform environment

$ npm install --save gcp-metadata
var gcpMetadata = require('gcp-metadata')
Access all metadata
gcpMetadata.instance(function(err, response, metadata) {
  // All metadata properties
})
Access specific properties
gcpMetadata.instance('hostname', function(err, response, metadata) {
  // All metadata properties
})
Access specific properties with query parameters
gcpMetadata.instance({
  property: 'tags',
  qs: { alt: 'text' }
}, function(err, response, metadata) {
  // Tags as newline-delimited list
})

Keywords

FAQs

Last updated on 21 Sep 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc