Skip to content

Migrate EC2 nodes plugin from AWS SDK v1 to v2#205

Open
fdevans wants to merge 2 commits into
mainfrom
aws-sdk-v2-migration
Open

Migrate EC2 nodes plugin from AWS SDK v1 to v2#205
fdevans wants to merge 2 commits into
mainfrom
aws-sdk-v2-migration

Conversation

@fdevans

@fdevans fdevans commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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.

  • Dependencies: replaced the com.amazonaws v1 artifacts with the v2 BOM plus ec2, sts, and apache-client; removed commons-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.
  • Clients: 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 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 behavior.
  • Mapping: Ec2Instance is now 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.

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 / check passes on Java 17 (54 tests, 0 failures)
  • Selector backwards-compatibility matrix unchanged and green (proves identical selector behavior on v2)
  • Built plugin jar bundles the v2 libs under lib/ and the Rundeck-Plugin-Libs manifest resolves
  • Docker-based tests run locally (require keyring auth)
  • Manual smoke test against a live AWS account (default region, multi-region/ALL_REGIONS, assume-role, HTTP proxy)

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.
@fdevans fdevans requested review from a team and Copilot June 26, 2026 20:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Ec2Client and introduces an Ec2Instance wrapper 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants