Skip to content

Commit

Permalink
fix: set use_aws_shared_config_files opts-in
Browse files Browse the repository at this point in the history
This change makes the ConfigurationResolver to load configuration from aws shared config files based on the configuration `use_aws_shared_config_files` either provided as provider arguments or as service client arguments.
  • Loading branch information
yenfryherrerafeliz committed Mar 6, 2024
1 parent b1c05a5 commit 67df55b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Credentials/InstanceProfileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class InstanceProfileProvider
/** @var string */
private $endpointMode;

/** @var bool */
private $useAwsSharedConfigFiles;

/**
* The constructor accepts the following options:
*
Expand Down Expand Up @@ -88,6 +91,7 @@ public function __construct(array $config = [])
}

$this->endpointMode = $config[self::CFG_EC2_METADATA_SERVICE_ENDPOINT_MODE] ?? null;
$this->useAwsSharedConfigFiles = $config['use_aws_shared_config_files'] ?? false;
}

/**
Expand Down Expand Up @@ -344,7 +348,7 @@ private function shouldFallbackToIMDSv1(): bool
self::CFG_EC2_METADATA_V1_DISABLED,
self::DEFAULT_AWS_EC2_METADATA_V1_DISABLED,
'bool',
['use_aws_shared_config_files' => true]
['use_aws_shared_config_files' => $this->useAwsSharedConfigFiles]
)
)
?? self::DEFAULT_AWS_EC2_METADATA_V1_DISABLED;
Expand All @@ -369,7 +373,7 @@ private function resolveEndpoint(): string
self::CFG_EC2_METADATA_SERVICE_ENDPOINT,
$this->getDefaultEndpoint(),
'string',
['use_aws_shared_config_files' => true]
['use_aws_shared_config_files' => $this->useAwsSharedConfigFiles]
);
}

Expand Down Expand Up @@ -420,7 +424,7 @@ private function resolveEndpointMode(): string
self::CFG_EC2_METADATA_SERVICE_ENDPOINT_MODE,
self::ENDPOINT_MODE_IPv4,
'string',
['use_aws_shared_config_files' => true]
['use_aws_shared_config_files' => $this->useAwsSharedConfigFiles]
);
}

Expand Down

0 comments on commit 67df55b

Please sign in to comment.