Having this code relies on AWS Metadata server being always available. There are instances where an ECS task cannot reach the metadata server which makes the task marked as unhealthy.
|
$provider = CredentialProvider::defaultProvider(); |
|
$credentials = call_user_func( $provider )->wait(); |
Check if this is critical or can be obtained elsewhere (environment variable) without relying on AWS Metadata server.