-
Notifications
You must be signed in to change notification settings - Fork 376
EC2MetadataUtils used to determine if running on cloud environment does not work on ECS Fargate #734
Comments
Thanks for the report. Indeed Starting from 2.3.0 |
Is the plan for this to improve |
I had a look in the AWS v1 SDK (current SDK for Spring Cloud AWS) with https://github.com/aws/aws-sdk-java/search?q=169.254.170&type=code but there doesn't appear (only from 10 minutes looking) to be a way to get the ECS metadata, the only thing I found was a way to load the container credentials: |
Under the hood the AwsCloudEnvironmentCheckUtils uses the SDK's EC2MetadataUtils. That util class calls an EC2-specific metadata endpoint that is present on EC2 instances. ECS has its own set of metadata endpoints (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint.html). One option would be to create a helper class to retrieve data from those endpoints and see if it comes back with any data. Another option would be to check for the presence of an ECS_CONTAINER_METADATA_URI environment variable and, if it's set, assume we're running in ECS and isRunningOnCloudEnvironment should return true. |
Type: Bug
Describe the bug
Version of Spring Cloud:
org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR9
Which resolves to spring cloud aws version 2.2.5.RELEASE
When the application starts up the org.springframework.cloud.aws.context.support.env.AwsCloudEnvironmentCheckUtils attempts to determine if the code is running in a cloud environment by using com.amazonaws.util.EC2MetadataUtils. This does not appear to work if the code is deployed to ECS Fargate.
I have already set the following in my application.yml:
As described in PR: #559
But this seems to be yet another case where the class being used needs to be configurable based on the platform in AWS the code is deployed to EC2 vs ECS Fargate.
Sample
Deploy any spring app using the spring cloud aws version 2.2.5.RELEASE to ECS Fargate and you should see this issue
The text was updated successfully, but these errors were encountered: