Skip to content

Commit

Permalink
Fix AWS Metadata Server timeout issue
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyrpoli authored and yaroslavmo committed May 4, 2020
1 parent 2d5f1ab commit 30433e8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Utility/AWSMetaDataParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function getToken()
{
$this->token = Curl::put($this->metadataServer . '/latest/api/token', null, [
CURLOPT_CONNECTTIMEOUT => 1,
CURLOPT_TIMEOUT => 1,
CURLOPT_HTTPHEADER => [
'X-aws-ec2-metadata-token-ttl-seconds: ' . $this->tokenTimeToLive,
],
Expand All @@ -50,6 +51,7 @@ public function getInstanceIdentity()
if ($token) {
$instanceIdentity = Curl::get($this->metadataServer . '/latest/dynamic/instance-identity/document', null, [
CURLOPT_CONNECTTIMEOUT => 1,
CURLOPT_TIMEOUT => 1,
CURLOPT_HTTPHEADER => [ 'X-aws-ec2-metadata-token: ' . $token, ],
]);
if (Curl::getLastHttpCode() != 200) {
Expand All @@ -69,6 +71,7 @@ protected function getInstanceIdentityPKCS7()
if ($token) {
$pkcs7 = Curl::get($this->metadataServer . '/latest/dynamic/instance-identity/pkcs7', null, [
CURLOPT_CONNECTTIMEOUT => 1,
CURLOPT_TIMEOUT => 1,
CURLOPT_HTTPHEADER => ['X-aws-ec2-metadata-token: ' . $token,],
]);
if (Curl::getLastHttpCode() != 200) {
Expand Down

0 comments on commit 30433e8

Please sign in to comment.