Skip to content

Include partitions.json data statically in provider #3637

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

Merged
merged 1 commit into from
Dec 16, 2022

Conversation

dagnir
Copy link
Contributor

@dagnir dagnir commented Dec 16, 2022

Motivation and Context

Simplifies code generation and avoids issues with build systems needing to package the resource file correctly.

Modifications

Include the raw partitions.json data as a string within DefaultPartitionDataProvider so it doesn't need to be loaded at runtime as a classpath resource.

Example generated provider
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.protocols.jsoncore.JsonNode;
import software.amazon.awssdk.utils.Lazy;

@Generated("software.amazon.awssdk:codegen")
class DefaultPartitionDataProvider implements PartitionDataProvider {
    private static final String DEFAULT_PARTITION_DATA = "{\n" + "  \"partitions\" : [ {\n" + "    \"id\" : \"aws\",\n"
            + "    \"outputs\" : {\n" + "      \"dnsSuffix\" : \"amazonaws.com\",\n"
            + "      \"dualStackDnsSuffix\" : \"api.aws\",\n" + "      \"name\" : \"aws\",\n"
            + "      \"supportsDualStack\" : true,\n" + "      \"supportsFIPS\" : true\n" + "    },\n"
            + "    \"regionRegex\" : \"^(us|eu|ap|sa|ca|me|af)\\\\-\\\\w+\\\\-\\\\d+$\",\n" + "    \"regions\" : {\n"
            + "      \"af-south-1\" : {\n" + "        \"description\" : \"Africa (Cape Town)\"\n" + "      },\n"
            + "      \"ap-east-1\" : {\n" + "        \"description\" : \"Asia Pacific (Hong Kong)\"\n" + "      },\n"
            + "      \"ap-northeast-1\" : {\n" + "        \"description\" : \"Asia Pacific (Tokyo)\"\n" + "      },\n"
            + "      \"ap-northeast-2\" : {\n" + "        \"description\" : \"Asia Pacific (Seoul)\"\n" + "      },\n"
            + "      \"ap-northeast-3\" : {\n" + "        \"description\" : \"Asia Pacific (Osaka)\"\n" + "      },\n"
            + "      \"ap-south-1\" : {\n" + "        \"description\" : \"Asia Pacific (Mumbai)\"\n" + "      },\n"
            + "      \"ap-south-2\" : {\n" + "        \"description\" : \"Asia Pacific (Hyderabad)\"\n" + "      },\n"
            + "      \"ap-southeast-1\" : {\n" + "        \"description\" : \"Asia Pacific (Singapore)\"\n" + "      },\n"
            + "      \"ap-southeast-2\" : {\n" + "        \"description\" : \"Asia Pacific (Sydney)\"\n" + "      },\n"
            + "      \"ap-southeast-3\" : {\n" + "        \"description\" : \"Asia Pacific (Jakarta)\"\n" + "      },\n"
            + "      \"aws-global\" : {\n" + "        \"description\" : \"AWS Standard global region\"\n" + "      },\n"
            + "      \"ca-central-1\" : {\n" + "        \"description\" : \"Canada (Central)\"\n" + "      },\n"
            + "      \"eu-central-1\" : {\n" + "        \"description\" : \"Europe (Frankfurt)\"\n" + "      },\n"
            + "      \"eu-central-2\" : {\n" + "        \"description\" : \"Europe (Zurich)\"\n" + "      },\n"
            + "      \"eu-north-1\" : {\n" + "        \"description\" : \"Europe (Stockholm)\"\n" + "      },\n"
            + "      \"eu-south-1\" : {\n" + "        \"description\" : \"Europe (Milan)\"\n" + "      },\n"
            + "      \"eu-south-2\" : {\n" + "        \"description\" : \"Europe (Spain)\"\n" + "      },\n"
            + "      \"eu-west-1\" : {\n" + "        \"description\" : \"Europe (Ireland)\"\n" + "      },\n"
            + "      \"eu-west-2\" : {\n" + "        \"description\" : \"Europe (London)\"\n" + "      },\n"
            + "      \"eu-west-3\" : {\n" + "        \"description\" : \"Europe (Paris)\"\n" + "      },\n"
            + "      \"me-central-1\" : {\n" + "        \"description\" : \"Middle East (UAE)\"\n" + "      },\n"
            + "      \"me-south-1\" : {\n" + "        \"description\" : \"Middle East (Bahrain)\"\n" + "      },\n"
            + "      \"sa-east-1\" : {\n" + "        \"description\" : \"South America (Sao Paulo)\"\n" + "      },\n"
            + "      \"us-east-1\" : {\n" + "        \"description\" : \"US East (N. Virginia)\"\n" + "      },\n"
            + "      \"us-east-2\" : {\n" + "        \"description\" : \"US East (Ohio)\"\n" + "      },\n"
            + "      \"us-west-1\" : {\n" + "        \"description\" : \"US West (N. California)\"\n" + "      },\n"
            + "      \"us-west-2\" : {\n" + "        \"description\" : \"US West (Oregon)\"\n" + "      }\n" + "    }\n"
            + "  }, {\n" + "    \"id\" : \"aws-cn\",\n" + "    \"outputs\" : {\n"
            + "      \"dnsSuffix\" : \"amazonaws.com.cn\",\n"
            + "      \"dualStackDnsSuffix\" : \"api.amazonwebservices.com.cn\",\n" + "      \"name\" : \"aws-cn\",\n"
            + "      \"supportsDualStack\" : true,\n" + "      \"supportsFIPS\" : true\n" + "    },\n"
            + "    \"regionRegex\" : \"^cn\\\\-\\\\w+\\\\-\\\\d+$\",\n" + "    \"regions\" : {\n"
            + "      \"aws-cn-global\" : {\n" + "        \"description\" : \"AWS China global region\"\n" + "      },\n"
            + "      \"cn-north-1\" : {\n" + "        \"description\" : \"China (Beijing)\"\n" + "      },\n"
            + "      \"cn-northwest-1\" : {\n" + "        \"description\" : \"China (Ningxia)\"\n" + "      }\n" + "    }\n"
            + "  }, {\n" + "    \"id\" : \"aws-us-gov\",\n" + "    \"outputs\" : {\n"
            + "      \"dnsSuffix\" : \"amazonaws.com\",\n" + "      \"dualStackDnsSuffix\" : \"api.aws\",\n"
            + "      \"name\" : \"aws-us-gov\",\n" + "      \"supportsDualStack\" : true,\n" + "      \"supportsFIPS\" : true\n"
            + "    },\n" + "    \"regionRegex\" : \"^us\\\\-gov\\\\-\\\\w+\\\\-\\\\d+$\",\n" + "    \"regions\" : {\n"
            + "      \"aws-us-gov-global\" : {\n" + "        \"description\" : \"AWS GovCloud (US) global region\"\n"
            + "      },\n" + "      \"us-gov-east-1\" : {\n" + "        \"description\" : \"AWS GovCloud (US-East)\"\n"
            + "      },\n" + "      \"us-gov-west-1\" : {\n" + "        \"description\" : \"AWS GovCloud (US-West)\"\n"
            + "      }\n" + "    }\n" + "  }, {\n" + "    \"id\" : \"aws-iso\",\n" + "    \"outputs\" : {\n"
            + "      \"dnsSuffix\" : \"c2s.ic.gov\",\n" + "      \"dualStackDnsSuffix\" : \"c2s.ic.gov\",\n"
            + "      \"name\" : \"aws-iso\",\n" + "      \"supportsDualStack\" : false,\n" + "      \"supportsFIPS\" : true\n"
            + "    },\n" + "    \"regionRegex\" : \"^us\\\\-iso\\\\-\\\\w+\\\\-\\\\d+$\",\n" + "    \"regions\" : {\n"
            + "      \"aws-iso-global\" : {\n" + "        \"description\" : \"AWS ISO (US) global region\"\n" + "      },\n"
            + "      \"us-iso-east-1\" : {\n" + "        \"description\" : \"US ISO East\"\n" + "      },\n"
            + "      \"us-iso-west-1\" : {\n" + "        \"description\" : \"US ISO WEST\"\n" + "      }\n" + "    }\n"
            + "  }, {\n" + "    \"id\" : \"aws-iso-b\",\n" + "    \"outputs\" : {\n"
            + "      \"dnsSuffix\" : \"sc2s.sgov.gov\",\n" + "      \"dualStackDnsSuffix\" : \"sc2s.sgov.gov\",\n"
            + "      \"name\" : \"aws-iso-b\",\n" + "      \"supportsDualStack\" : false,\n" + "      \"supportsFIPS\" : true\n"
            + "    },\n" + "    \"regionRegex\" : \"^us\\\\-isob\\\\-\\\\w+\\\\-\\\\d+$\",\n" + "    \"regions\" : {\n"
            + "      \"aws-iso-b-global\" : {\n" + "        \"description\" : \"AWS ISOB (US) global region\"\n" + "      },\n"
            + "      \"us-isob-east-1\" : {\n" + "        \"description\" : \"US ISOB East (Ohio)\"\n" + "      }\n" + "    }\n"
            + "  } ],\n" + "  \"version\" : \"1.1\"\n" + "}";

    private static final Lazy<Partitions> PARTITIONS = new Lazy<>(DefaultPartitionDataProvider::doLoadPartitions);;

    @Override
    public Partitions loadPartitions() {
        return PARTITIONS.getValue();
    }

    private static Partitions doLoadPartitions() {
        return Partitions.fromNode(JsonNode.parser().parse(DEFAULT_PARTITION_DATA));
    }
}

Testing

  • New unit tests.
  • Running integ tests.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

Include the raw partitions.json data as a string within
DefaultPartitionDataProvider so it doesn't need to be loaded at runtime as a
classpath resource.
@dagnir dagnir requested a review from a team as a code owner December 16, 2022 19:38
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@dagnir dagnir merged commit 43b1f1b into master Dec 16, 2022
@dagnir
Copy link
Contributor Author

dagnir commented Dec 16, 2022

Note: native image tests are currently broken after the latest Netty version bump #3628

aws-sdk-java-automation pushed a commit that referenced this pull request Feb 6, 2025
…6f262b7ee

Pull request: release <- staging/a67c6178-9301-4138-b983-6ab6f262b7ee
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