Skip to content

Commit

Permalink
gcp headers into a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Bamieh committed Sep 9, 2021
1 parent 368178e commit 9124470
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { CloudServiceResponse } from './cloud_response';
// GCP documentation shows both 'metadata.google.internal' (mostly) and '169.254.169.254' (sometimes)
// To bypass potential DNS changes, the IP was used because it's shared with other cloud services
const SERVICE_ENDPOINT = 'http://169.254.169.254/computeMetadata/v1/instance';
// GCP required headers
const SERVICE_HEADERS = { 'Metadata-Flavor': 'Google' };

/**
* Checks and loads the service metadata for an Google Cloud Platform VM if it is available.
Expand All @@ -32,10 +34,7 @@ export class GCPCloudService extends CloudService {
fields.map(async (field) => {
return await fetch(`${SERVICE_ENDPOINT}/${field}`, {
method: 'GET',
headers: {
// GCP requires this header
'Metadata-Flavor': 'Google',
},
headers: { ...SERVICE_HEADERS },
});
})
);
Expand Down

0 comments on commit 9124470

Please sign in to comment.