Skip to content

Conversation

vpavic
Copy link
Contributor

@vpavic vpavic commented Oct 10, 2025

This commit adds support for detecting AWS ECS to CloudPlatform. The detection is based on presence of AWS_EXECUTION_ENV environment variable with value starting with AWS_ECS.

Related resources:

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 10, 2025
@wilkinsona
Copy link
Member

Thanks for the suggestion. What about EC2 (and any other deployment option other than ECS and Lambda that there may be now or in the future)? AWS feels rather broad to me.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Oct 10, 2025
@vpavic
Copy link
Contributor Author

vpavic commented Oct 10, 2025

If EC2 is the underlying ECS runtime, that gets picked up using AWS_EXECUTION_ENV (see the first link). If you're referring to the bare EC2, I think you have to make a call to instance metadata service. But that's a plain VM you need to manage manually either way, so I'm not sure it qualifies as a true cloud platform.

AWS as CloudPlatform option might be broad, but as a developer you probably just want to reliably figure out you're running on AWS so that you prepare some group of configuration properties using spring.config.activate.on-cloud-platform. I'm not sure what would be a use case for a more precise detection.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 10, 2025
@wilkinsona
Copy link
Member

We need to consider more than spring.config.activate.on-cloud-platform. For example, there's @ConditionalOnCloudPlatform as well. If the platform's named AWS, I think it sets the expectation that @ConditionOnCloudPlatform(CloudPlatform.AWS) would match whenever the app is deployed to AWS. That isn't the case and, therefore, I think the proposed name is misleading.

@vpavic
Copy link
Contributor Author

vpavic commented Oct 10, 2025

I see. In that case, I can update this PR to focus on ECS - that can be detected quite accurately (using AWS_EXECUTION_ENV value) and is also the most popular option on AWS for running Spring Boot applications (see #47483).

I'm not sure detecting AWS Lambda using similar mechanism is worth it, as lambdas are quite coupled to the runtime either way.

This commit adds support for detecting AWS ECS to `CloudPlatform`. The
detection is based on presence of `AWS_EXECUTION_ENV` environment
variable with value starting with `AWS_ECS`.

Signed-off-by: Vedran Pavic <[email protected]>
@vpavic vpavic force-pushed the cloud-platform-aws branch from 605797a to 2340571 Compare October 11, 2025 18:15
@vpavic vpavic changed the title Add AWS to cloud platforms Add AWS ECS to cloud platforms Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants