Migrate EC2 nodes plugin from AWS SDK v1 to v2#205
Open
fdevans wants to merge 2 commits into
Open
Conversation
The AWS Java SDK v1 reached end-of-life in December 2025 and AWS is flagging the integration as at-risk (rundeck/rundeck#10197). This moves the plugin to AWS SDK v2 (2.46.17) while preserving a frictionless upgrade for existing customers. - Dependencies: replace com.amazonaws v1 artifacts with the v2 BOM plus ec2, sts, and apache-client. Bundle only the Apache 4.x HTTP client and exclude the Netty async + Apache 5.x clients the service modules pull in (an explicit Apache client is always set), trimming the plugin jar. - Clients: AmazonEC2 -> Ec2Client, default region preserved (us-east-1), endpoint-override path derives the signing region from the endpoint host. HTTP proxy config moves to a shared ApacheHttpClient reused by the EC2 and STS clients. - Credentials/STS: rewritten with AwsBasicCredentials, StsClient, and AssumeRoleRequest; STS pinned to the global endpoint to match v1. - Mapping: Ec2Instance becomes a delegating wrapper (the v2 Instance is final and cannot be subclassed) carrying the imageName/region extras. commons-beanutils is replaced with a custom reflection resolver over the v2 fluent accessors that prefers the <field>AsString() variant, so enum fields (architecture, state.name, etc.) return the same wire values and every documented selector keeps working unchanged. - Tests: rebuilt against v2 builders and Ec2Client mocks; the selector assertion matrix is unchanged to prove backwards compatibility.
There was a problem hiding this comment.
Pull request overview
Migrates the Rundeck EC2 Nodes resource model plugin from AWS Java SDK v1 (com.amazonaws) to AWS SDK v2 (software.amazon.awssdk), updating EC2/STS client construction, credentials handling, proxy support, and selector/property resolution while aiming to preserve existing configuration and selector behavior.
Changes:
- Replaces AWS SDK v1 dependencies with the AWS SDK v2 BOM and EC2/STS/Apache HTTP client modules; updates Gradle bundling/exclusions accordingly.
- Updates EC2 querying/mapping to use
Ec2Clientand introduces anEc2Instancewrapper plus a reflection-based selector resolver to replace BeanUtils. - Updates Spock tests and documentation to reflect AWS SDK v2 model types and accessors.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/groovy/com/dtolabs/rundeck/plugin/resources/ec2/InstanceToNodeMapperSpec.groovy | Updates mapper unit tests to use AWS SDK v2 model builders and Ec2Client mocks. |
| src/test/groovy/com/dtolabs/rundeck/plugin/resources/ec2/EC2ResourceModelSourceSpec.groovy | Adapts credential assertions to AWS SDK v2 credential accessors. |
| src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/InstanceToNodeMapper.java | Migrates instance querying/mapping to Ec2Client, replaces BeanUtils selector resolution with reflection, and updates extra attribute enrichment. |
| src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2SupplierImpl.java | Replaces v1 client builder logic with v2 Ec2ClientBuilder, shared HTTP client support, and endpoint signing-region derivation. |
| src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2Supplier.java | Updates supplier interface to return Ec2Client. |
| src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2ResourceModelSource.java | Migrates credentials + STS assume-role + proxy configuration to AWS SDK v2 and shared ApacheHttpClient. |
| src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/Ec2Instance.java | Replaces v1 model subclassing with a v2 Instance wrapper carrying extra mapping attributes. |
| Readme.md | Updates selector documentation link to AWS SDK v2 Instance model. |
| gradle/libs.versions.toml | Updates AWS SDK version and replaces v1 artifacts with v2 BOM/modules. |
| build.gradle | Adds AWS SDK v2 BOM usage, bundles v2 modules into plugin libs, and excludes unused HTTP clients. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+196
to
+200
| private Set<Ec2Instance> getInstancesByRegion(String endpoint) { | ||
| Set<Ec2Instance> allInstances = new HashSet<>(); | ||
| Ec2Client ec2 = ec2Supplier.getEC2ForEndpoint(endpoint); | ||
| zones = ec2.describeAvailabilityZones(); | ||
| final ArrayList<Filter> filters = buildFilters(); | ||
| final List<Filter> filters = buildFilters(); |
Comment on lines
+570
to
+580
| private static Method lookupAccessor(final Class<?> type, final String name) { | ||
| try { | ||
| final Method method = type.getMethod(name); | ||
| if (method.getParameterCount() == 0 | ||
| && method.getReturnType() != void.class | ||
| && method.getDeclaringClass().getName().startsWith("software.amazon.awssdk")) { | ||
| return method; | ||
| } | ||
| } catch (NoSuchMethodException ignored) { | ||
| // not a property accessor | ||
| } |
Comment on lines
708
to
710
| }catch(Exception e){ | ||
| logger.error("error getting image info{}", e.getMessage()); | ||
| } |
Comment on lines
717
to
720
| }else{ | ||
| customInstance.setImageName("Not found"); | ||
| logger.debug("Image not found" + inst.getImageId()); | ||
| inst.setImageName("Not found"); | ||
| logger.debug("Image not found" + imageId); | ||
| } |
- Fix availability-zone race condition: thread the DescribeAvailabilityZones response through addExtraMappingAttribute/addingRegion/getRegionAvailableZone instead of a shared mutable field, so parallel multi-region queries no longer derive the region from another thread's zones. - Relax the selector accessor guard to allow traversing into JDK value types (e.g. java.time on launchTime) while still rejecting Object methods, keeping object-graph traversal behavior closer to the legacy BeanUtils resolver. - Improve image-lookup error log: add a separator and include the stack trace. - Use parameterized SLF4J logging for the "Image not found" debug message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the EC2 Nodes resource model plugin off the end-of-life AWS Java SDK v1 onto AWS SDK v2 (2.46.17), addressing rundeck/rundeck#10197. The migration is designed for a frictionless upgrade: no configuration changes are required for existing customers.
com.amazonawsv1 artifacts with the v2 BOM plusec2,sts, andapache-client; removedcommons-beanutils. Only the Apache 4.x HTTP client is bundled (an explicit client is always set), with the Netty async and Apache 5.x clients excluded to keep the plugin jar smaller.AmazonEC2->Ec2Client, default region preserved (us-east-1); the endpoint-override path derives the signing region from the endpoint host. HTTP proxy configuration moves to a sharedApacheHttpClientreused by the EC2 and STS clients.AwsBasicCredentials,StsClient, andAssumeRoleRequest; STS pinned to the global endpoint to match v1 behavior.Ec2Instanceis now a delegating wrapper (the v2Instanceis final and cannot be subclassed) carrying theimageName/regionextras.commons-beanutilsis replaced with a custom reflection resolver over the v2 fluent accessors that prefers the<field>AsString()variant, so enum fields (architecture,state.name, etc.) return the same wire values and every documented selector keeps working unchanged.Customer impact
No action required for existing users. Credentials, HTTP proxy, filters, endpoints/
ALL_REGIONS, and all mapping selectors behave exactly as before. This removes the at-risk EOL SDK that AWS has been emailing about.Test plan
gradle clean build/checkpasses on Java 17 (54 tests, 0 failures)lib/and theRundeck-Plugin-Libsmanifest resolvesALL_REGIONS, assume-role, HTTP proxy)