Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@

package software.amazon.awssdk.codegen.lite.maven.plugin;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
Expand Down Expand Up @@ -79,7 +83,7 @@ public void execute() throws MojoExecutionException {
generateRegions(baseSourcesDirectory, regionPartitions);
generatePartitionProvider(baseSourcesDirectory, regionPartitions);
generateRegionProvider(baseSourcesDirectory, regionPartitions);
generateServiceProvider(baseSourcesDirectory, partitions);
generateServiceProvider(baseSourcesDirectory);
generateEndpointTags(baseSourcesDirectory, partitions);

project.addCompileSourceRoot(baseSourcesDirectory.toFile().getAbsolutePath());
Expand All @@ -105,7 +109,10 @@ public void generateServiceMetadata(Path baseSourcesDirectory, Partitions partit
Set<String> services = new HashSet<>();
partitions.getPartitions().forEach(p -> services.addAll(p.getServices().keySet()));

services.forEach(s -> new CodeGenerator(sourcesDirectory.toString(), new ServiceMetadataGenerator(partitions,
Set<String> allowedServices = loadServiceMetadataAllowlist();
services.stream()
.filter(allowedServices::contains)
.forEach(s -> new CodeGenerator(sourcesDirectory.toString(), new ServiceMetadataGenerator(partitions,
s,
SERVICE_METADATA_BASE,
REGION_BASE))
Expand Down Expand Up @@ -141,16 +148,32 @@ public void generateRegionProvider(Path baseSourcesDirectory, PartitionsRegionsM
.generate();
}

public void generateServiceProvider(Path baseSourcesDirectory, Partitions partitions) {
public void generateServiceProvider(Path baseSourcesDirectory) {
Path sourcesDirectory = baseSourcesDirectory.resolve(StringUtils.replace(REGION_BASE, ".", "/"));
new CodeGenerator(sourcesDirectory.toString(), new ServiceMetadataProviderGenerator(partitions,
SERVICE_METADATA_BASE,
REGION_BASE))
Set<String> allowedServices = loadServiceMetadataAllowlist();
new CodeGenerator(sourcesDirectory.toString(), new ServiceMetadataProviderGenerator(SERVICE_METADATA_BASE,
REGION_BASE,
allowedServices))
.generate();
}

public void generateEndpointTags(Path baseSourcesDirectory, Partitions partitions) {
Path sourcesDirectory = baseSourcesDirectory.resolve(StringUtils.replace(REGION_BASE, ".", "/"));
new CodeGenerator(sourcesDirectory.toString(), new EndpointTagGenerator(partitions, REGION_BASE)).generate();
}

private Set<String> loadServiceMetadataAllowlist() {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
java.util.Objects.requireNonNull(
getClass().getResourceAsStream("/software/amazon/awssdk/codegen/lite/service-metadata-allowlist.txt"),
"Failed to load service-metadata-allowlist.txt"),
StandardCharsets.UTF_8))) {
return reader.lines()
.map(String::trim)
.filter(line -> !line.isEmpty() && !line.startsWith("#"))
.collect(Collectors.toSet());
} catch (Exception e) {
throw new RuntimeException("Failed to load service-metadata-allowlist.txt", e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,310 @@
# Frozen list of service endpoint prefixes for which ServiceMetadata classes are generated.
# New services should NOT be added to this list. ServiceMetadata is a legacy endpoint resolution
# system that has been superseded by Endpoints 2.0.
access-analyzer
account
acm
acm-pca
agreement-marketplace
airflow
amplify
amplifybackend
amplifyuibuilder
aoss
api.detective
api.ecr
api.ecr-public
api.iotdeviceadvisor
api.iotwireless
api.mediatailor
api.pricing
api.sagemaker
api.tunneling.iot
apigateway
app-integrations
appconfig
appconfigdata
appflow
application-autoscaling
applicationinsights
appmesh
apprunner
appstream2
appsync
aps
arc-zonal-shift
athena
auditmanager
autoscaling
autoscaling-plans
backup
backup-gateway
batch
bedrock
billingconductor
braket
budgets
cases
cassandra
catalog.marketplace
ce
chime
cleanrooms
cloud9
cloudcontrolapi
clouddirectory
cloudformation
cloudfront
cloudhsm
cloudhsmv2
cloudsearch
cloudtrail
cloudtrail-data
codeartifact
codebuild
codecatalyst
codecommit
codedeploy
codeguru-profiler
codeguru-reviewer
codepipeline
codestar-connections
codestar-notifications
cognito-identity
cognito-idp
cognito-sync
comprehend
comprehendmedical
compute-optimizer
config
connect
connect-campaigns
contact-lens
controltower
cost-optimization-hub
cur
data-ats.iot
data.iot
data.jobs.iot
data.mediastore
databrew
dataexchange
datapipeline
datasync
datazone
dax
devicefarm
devops-guru
directconnect
discovery
dlm
dms
docdb
drs
ds
dynamodb
ebs
ec2
ecs
edge.sagemaker
eks
eks-auth
elasticache
elasticbeanstalk
elasticfilesystem
elasticloadbalancing
elasticmapreduce
email
emr-containers
emr-serverless
entitlement.marketplace
es
events
finspace
finspace-api
firehose
fms
forecast
forecastquery
frauddetector
fsx
gamelift
gameliftstreams
geo
glacier
globalaccelerator
glue
grafana
greengrass
groundstation
guardduty
health
healthlake
iam
identity-chime
identitystore
importexport
ingest.timestream
inspector
inspector2
internetmonitor
iot
iotfleetwise
iotsecuredtunneling
iotsitewise
iotthingsgraph
iottwinmaker
iotwireless
ivs
ivschat
ivsrealtime
kafka
kafkaconnect
kendra
kendra-ranking
kinesis
kinesisanalytics
kinesisvideo
kms
lakeformation
lambda
license-manager
license-manager-linux-subscriptions
license-manager-user-subscriptions
lightsail
logs
lookoutequipment
m2
machinelearning
macie2
managedblockchain
managedblockchain-query
marketplacecommerceanalytics
media-pipelines-chime
mediaconnect
mediaconvert
medialive
mediapackage
mediapackage-vod
mediapackagev2
mediastore
meetings-chime
memory-db
messaging-chime
metering.marketplace
metrics.sagemaker
mgh
mgn
migrationhub-orchestrator
migrationhub-strategy
mobileanalytics
models-v2-lex
models.lex
monitoring
mq
mturk-requester
neptune
network-firewall
networkmanager
notifications
notifications-contacts
nova-act
oam
oidc
omics
organizations
osis
outposts
participant.connect
partnercentral-channel
personalize
pi
pinpoint
pipes
polly
portal.sso
profile
proton
qbusiness
query.timestream
quicksight
ram
rbin
rds
rds-data
redshift
redshift-serverless
rekognition
resiliencehub
resource-explorer-2
resource-groups
rolesanywhere
route53
route53-recovery-control-config
route53domains
route53profiles
route53resolver
rum
runtime-v2-lex
runtime.lex
runtime.sagemaker
s3
s3-control
s3-outposts
sagemaker-geospatial
savingsplans
scheduler
schemas
sdb
secretsmanager
securityhub
securitylake
serverlessrepo
servicecatalog
servicecatalog-appregistry
servicediscovery
servicequotas
shield
signer
sms-voice
snowball
sns
sqs
ssm
ssm-contacts
ssm-incidents
ssm-quicksetup
ssm-sap
sso
states
storagegateway
streams.dynamodb
sts
support
supportapp
swf
synthetics
tagging
tax
textract
thinclient
tnb
transcribe
transcribestreaming
transfer
translate
trustedadvisor
verifiedpermissions
voice-chime
voiceid
vpc-lattice
waf
waf-regional
wafv2
wellarchitected
wisdom
workdocs
workmail
workspaces
workspaces-web
xray
Loading
Loading