-
-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AWS Spring cloud map support (with AWS SDK v2) #506
base: main
Are you sure you want to change the base?
Conversation
690b3be
to
4465e63
Compare
Support for integrating with AWS Cloudmap
4465e63
to
9986358
Compare
Thanks @hariohmprasath. I'll do some polishing and very likely come back to you with some questions. In meantime, there are 3 things missing:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are quite a few unused fields that I am not sure if just should be deleted or some parts of implementation is still missing.
Missing integration tests stopped me from doing further refactoring. If we can't test against Localstack, we should mock AWS API and perhaps use Wiremock to stub EC2/ECS endpoints.
I feel like the CloudMapUtils
class is the center of this implementation and ideally we would refactor it to avoid having so much logic in the util class - but this can or even has to wait until we have integration tests so that we can refactor safely.
@hariohmprasath would you be willing to address these issues? In case I am missing something, your opinion is appreciated.
@Bean | ||
@ConditionalOnMissingBean | ||
CloudMapAutoRegistration createAutoRegistration(ServiceDiscoveryClient serviceDiscovery) { | ||
return new CloudMapAutoRegistration(context, serviceDiscovery, properties.getRegistry()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of ApplicationContext
, CloudMapRegistration
should use ApplicationEventPublisher
for publishing events.
Since it's the only bean that uses is, ApplicationEventPublisher
should be provided as a bean factory method parameter instead of a field in the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might need some help on this, do you have a sample for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a fix.
...e/src/main/java/io/awspring/cloud/autoconfigure/cloudmap/CloudMapBootstrapConfiguration.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/io/awspring/cloud/autoconfigure/cloudmap/CloudMapBootstrapConfiguration.java
Outdated
Show resolved
Hide resolved
...re/src/main/java/io/awspring/cloud/autoconfigure/cloudmap/properties/CloudMapProperties.java
Outdated
Show resolved
Hide resolved
...re/src/main/java/io/awspring/cloud/autoconfigure/cloudmap/properties/CloudMapProperties.java
Outdated
Show resolved
Hide resolved
...re/src/main/java/io/awspring/cloud/autoconfigure/cloudmap/properties/CloudMapProperties.java
Outdated
Show resolved
Hide resolved
...in/java/io/awspring/cloud/autoconfigure/cloudmap/properties/discovery/CloudMapDiscovery.java
Outdated
Show resolved
Hide resolved
<name>Spring Cloud Cloud Map</name> | ||
<description>Spring Cloud AWS Cloud Map</description> | ||
|
||
<dependencies> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These dependencies are not used in spring-cloud-aws-cloudmap
module. Since they are required by the autoconfiguration that is triggered only if these dependencies are on the classpath, they should go to starter module and autoconfiguration should trigger only if each of the required dependency is on the classpath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry can you please elaborate the change, I am not able to understand the recommendation here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module should have only dependencies used in this very particular module.
Starter should list all the dependencies that are used additionally in autoconfiguration.
Autoconfiguration should be have @ConditionalOnClass
listing classes from each dependency that is required for the integration to work.
...-cloud-aws-samples/spring-cloud-aws-cloud-map-sample/src/main/resources/bootstrap.properties
Show resolved
Hide resolved
Thanks for reviewing the code @maciejwalkowiak, let me start addressing some of the comments and we can sync up based on the changes |
|
new test cases, readme, instructions
ab03056
to
1e5f541
Compare
@maciejwalkowiak, The last commit that I pushed in has code changes to mock the required HTTP responses. So we can use these tests as a reference for further refactoring. Since CloudMap is not supported in It just requires the following environment variables to be set before running the sample application: AWS_ACCESS_KEY_ID=<key>
AWS_REGION=us-east1
AWS_SECRET_ACCESS_KEY=<secret>
DEPLOYMENT_PLATFORM=ECS Update |
@hariohmprasath thanks for an update. We still need to have an integration test that checks everything all together. Something like Considering it's not possible to use Localstack for that, either we need to mock responses from AWS or run the test against real AWS and spin up resources with Cloudformation. I can imagine this is quite a bit of work but we just cannot merge the integration lacking solid test coverage. |
Hi @maciejwalkowiak, Once the enhancement and PR gets approved I can use the same to add the required integration test cases. Hope this works for you, let me know your thoughts. Thanks |
@hariohmprasath sounds like the way to go! |
Hi @maciejwalkowiak, Just checking to see whether you had a chance to review the changes, let me know if you have any questions/suggestions. Thanks |
@hariohmprasath not yet unfortunately but it's still high in my priority list so don't worry - it won't be ignored :-) |
Hi @maciejwalkowiak, |
@hariohmprasath apologies again, but we didn't find enough time to include it in 3.0. 3.0 will be released in April, CloudMap is planned for 3.1, so Q2/Q3 2023. |
Sounds good, thanks for letting me know |
Any updates to when this will be included? |
Hi @maciejwalkowiak, Would love to get this merged by early 2024 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw this and think it is kindof cool, but it will be hard for any community to support unless localstack has a free OSS account. Do you have a relationship with them to ask? I think even if there was such an account it may imply test after merge to prevent key hijacking on pull requests.
I say this not knowing how other amazon resources are managed, so take this advice knowing it is a random drive by.
public static final String REGION = "us-east-1"; | ||
public static final String CIDR_BLOCK = "10.0.0.0/16"; | ||
public static final String META_DATA_MOCK_RESPONSE = "https://5qjz8e33hj.api.quickmocker.com"; | ||
public static final String LOCAL_STACK_API = "LOCALSTACK_API_KEY"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this PR, the key is now LOCALSTACK_AUTH_TOKEN
public static final String CIDR_BLOCK = "10.0.0.0/16"; | ||
public static final String META_DATA_MOCK_RESPONSE = "https://5qjz8e33hj.api.quickmocker.com"; | ||
public static final String LOCAL_STACK_API = "LOCALSTACK_API_KEY"; | ||
public static final String LOCAL_STACK_API_KEY = ""; // TODO: Add your localstack api key here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably wanna read from env and skip if not present
// Local stack container with Cloud Map and Ec2 services enabled | ||
@Container | ||
private static final LocalStackContainer localStackContainer = new LocalStackContainer( | ||
DockerImageName.parse("localstack/localstack:1.1.0")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this need to be localstack-pro? I tried to use normal and it didn't work until I switched the image name. Maybe that changed since this PR was raised (current version is 3.2.0)
* Register a service with no specification provided in application.properties. | ||
*/ | ||
@Test | ||
void registerEksContainerWithCloudMapWithNoSpecification() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curios on this.. ECS makes immediate sense as at the pure container layer it is basically just DNS. On the other hand EKS is in k8s, so there's services, endpoints etc.
what's your opinion on registration here clashing or otherwise being redundant with k8s (endpoint, service, etc) or layers over it (istio)? Is this to support multi-clusters? or is the idea to duplicate register for those using raw cloud map?
curious your thinking as I'm a cloudmap noob and missing the insight on this.
my first comment about license with localstack was wrong.. It seems by README and anecdotally in some issues, that there is a pro license for this project. Just it doesn't seem used in CI not even on protected branches. For example, I would expect an env variable sourced from a repo or org secret. So, the impact is integration tests even when merged, won't run.. unless I'm missing somewhere else where they are run (should be in README somewhere about how the localstack creds are used) |
We are interested in using this integration as well. What needs to be done to get this reviewed and merged, and how could we help with that process? |
Hi @maciejwalkowiak, The PR was created on Sep 4, 2022, probably 2 years back :) Any plans to merge it part of a mainline or release? |
+1 |
Again apologies for postponing it for so long. I'll get some support and we will get it through. |
Support for integrating with AWS Cloudmap
📢 Type of change
📜 Description
This pull request adds support for integrating spring boot application with AWS cloudmap. Here is an example of how an simple properties file integration looks like for both cloudmap registration and discovery
The property file is optional, any application can easily register themselves to cloudmap by adding
spring-cloud-starter-aws-cloudmap
dependency topom
orgradle
files, here is a example:💡 Motivation and Context
Adds support for cloudmap integration with spring boot applications for both service registry and discovery #5
💚 How did you test it?
I executed the following tests:
📝 Checklist
🔮 Next steps
Code review and merging code to 3.x branch