forked from googleapis/gcp-metadata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.readme-partials.yaml
77 lines (60 loc) · 2.56 KB
/
.readme-partials.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
body: |-
#### Check to see if the metadata server is available
```js
const isAvailable = await gcpMetadata.isAvailable();
```
#### Access all metadata
```js
const data = await gcpMetadata.instance();
console.log(data); // ... All metadata properties
```
#### Access specific properties
```js
const data = await gcpMetadata.instance('hostname');
console.log(data); // ...Instance hostname
const projectId = await gcpMetadata.project('project-id');
console.log(projectId); // ...Project ID of the running instance
```
#### Access nested properties with the relative path
```js
const data = await gcpMetadata.instance('service-accounts/default/email');
console.log(data); // ...Email address of the Compute identity service account
```
#### Access specific properties with query parameters
```js
const data = await gcpMetadata.instance({
property: 'tags',
params: { alt: 'text' }
});
console.log(data) // ...Tags as newline-delimited list
```
#### Access with custom headers
```js
await gcpMetadata.instance({
headers: { 'no-trace': '1' }
}); // ...Request is untraced
```
### Take care with large number valued properties
In some cases number valued properties returned by the Metadata Service may be
too large to be representable as JavaScript numbers. In such cases we return
those values as `BigNumber` objects (from the [bignumber.js](https://github.com/MikeMcl/bignumber.js) library). Numbers
that fit within the JavaScript number range will be returned as normal number
values.
```js
const id = await gcpMetadata.instance('id');
console.log(id) // ... BigNumber { s: 1, e: 18, c: [ 45200, 31799277581759 ] }
console.log(id.toString()) // ... 4520031799277581759
```
### Environment variables
* `GCE_METADATA_HOST`: provide an alternate host or IP to perform lookup against (useful, for example, you're connecting through a custom proxy server).
For example:
```
export GCE_METADATA_HOST='169.254.169.254'
```
* `DETECT_GCP_RETRIES`: number representing number of retries that should be attempted on metadata lookup.
* `DEBUG_AUTH`: emit debugging logs
* `METADATA_SERVER_DETECTION`: configure desired metadata server availability check behavior.
* `assume-present`: don't try to ping the metadata server, but assume it's present
* `none`: don't try to ping the metadata server, but don't try to use it either
* `bios-only`: treat the result of a BIOS probe as canonical (don't fall back to pinging)
* `ping-only`: skip the BIOS probe, and go straight to pinging