@@ -70,6 +70,73 @@ terraform {
7070}
7171"""
7272PROCESS = None
73+ # some services have aliases which are mutually exclusive to each other
74+ # see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/custom-service-endpoints#available-endpoint-customizations
75+ SERVICE_ALIASES = [
76+ ("amp" , "prometheus" , "prometheusservice" ),
77+ ("appautoscaling" , "applicationautoscaling" ),
78+ ("appintegrations" , "appintegrationsservice" ),
79+ ("ce" , "costexplorer" ),
80+ ("cloudcontrol" , "cloudcontrolapi" ),
81+ ("cloudhsmv2" , "cloudhsm" ),
82+ ("cognitoidp" , "cognitoidentityprovider" ),
83+ ("configservice" , "config" ),
84+ ("cur" , "costandusagereportservice" ),
85+ ("deploy" , "codedeploy" ),
86+ ("dms" , "databasemigration" , "databasemigrationservice" ),
87+ ("ds" , "directoryservice" ),
88+ ("elasticbeanstalk" , "beanstalk" ),
89+ ("elasticsearch" , "es" , "elasticsearchservice" ),
90+ ("elb" , "elasticloadbalancing" ),
91+ ("elbv2" , "elasticloadbalancingv2" ),
92+ ("events" , "eventbridge" , "cloudwatchevents" ),
93+ ("evidently" , "cloudwatchevidently" ),
94+ ("grafana" , "managedgrafana" , "amg" ),
95+ ("inspector2" , "inspectorv2" ),
96+ ("kafka" , "msk" ),
97+ ("lexmodels" , "lexmodelbuilding" , "lexmodelbuildingservice" , "lex" ),
98+ ("lexv2models" , "lexmodelsv2" ),
99+ ("location" , "locationservice" ),
100+ ("logs" , "cloudwatchlog" , "cloudwatchlogs" ),
101+ ("oam" , "cloudwatchobservabilityaccessmanager" ),
102+ ("opensearch" , "opensearchservice" ),
103+ ("osis" , "opensearchingestion" ),
104+ ("rbin" , "recyclebin" ),
105+ ("redshiftdata" , "redshiftdataapiservice" ),
106+ ("resourcegroupstaggingapi" , "resourcegroupstagging" ),
107+ ("rum" , "cloudwatchrum" ),
108+ ("s3" , "s3api" ),
109+ ("serverlessrepo" , "serverlessapprepo" , "serverlessapplicationrepository" ),
110+ ("servicecatalogappregistry" , "appregistry" ),
111+ ("sfn" , "stepfunctions" ),
112+ ("simpledb" , "sdb" ),
113+ ("transcribe" , "transcribeservice" ),
114+ ]
115+ # service names to be excluded (not yet available in TF)
116+ SERVICE_EXCLUSIONS = ["meteringmarketplace" ]
117+ # maps services to be replaced with alternative names
118+ # skip services which do not have equivalent endpoint overrides
119+ # see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/custom-service-endpoints
120+ SERVICE_REPLACEMENTS = {
121+ "apigatewaymanagementapi" : "" ,
122+ "appconfigdata" : "" ,
123+ "ce" : "costexplorer" ,
124+ "dynamodbstreams" : "" ,
125+ "edge" : "" ,
126+ "emrserverless" : "" ,
127+ "iotdata" : "" ,
128+ "ioteventsdata" : "" ,
129+ "iotjobsdata" : "" ,
130+ "iotwireless" : "" ,
131+ "logs" : "cloudwatchlogs" ,
132+ "mediastoredata" : "" ,
133+ "qldbsession" : "" ,
134+ "rdsdata" : "" ,
135+ "sagemakerruntime" : "" ,
136+ "support" : "" ,
137+ "timestream" : "" ,
138+ "timestreamquery" : "" ,
139+ }
73140
74141
75142# ---
@@ -79,40 +146,17 @@ PROCESS = None
79146def create_provider_config_file (provider_aliases = None ):
80147 provider_aliases = provider_aliases or []
81148
82- # maps services to be replaced with alternative names
83- # skip services which do not have equivalent endpoint overrides
84- # see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/custom-service-endpoints
85- service_replaces = {
86- "apigatewaymanagementapi" : "" ,
87- "appconfigdata" : "" ,
88- "ce" : "costexplorer" ,
89- "dynamodbstreams" : "" ,
90- "edge" : "" ,
91- "emrserverless" : "" ,
92- "iotdata" : "" ,
93- "ioteventsdata" : "" ,
94- "iotjobsdata" : "" ,
95- "iotwireless" : "" ,
96- "logs" : "cloudwatchlogs" ,
97- "mediastoredata" : "" ,
98- "qldbsession" : "" ,
99- "rdsdata" : "" ,
100- "sagemakerruntime" : "" ,
101- "support" : "" ,
102- "timestream" : "" ,
103- "timestreamquery" : "" ,
104- }
105- # service names to be excluded (not yet available in TF)
106- service_excludes = ["meteringmarketplace" ]
149+ # Force service alias replacements
150+ SERVICE_REPLACEMENTS .update ({alias : alias_pairs [0 ] for alias_pairs in SERVICE_ALIASES for alias in alias_pairs if alias != alias_pairs [0 ]})
107151
108152 # create list of service names
109153 services = list (config .get_service_ports ())
110- services = [srvc for srvc in services if srvc not in service_excludes ]
154+ services = [srvc for srvc in services if srvc not in SERVICE_EXCLUSIONS ]
111155 services = [s .replace ("-" , "" ) for s in services ]
112- for old , new in service_replaces .items ():
156+ for old , new in SERVICE_REPLACEMENTS .items ():
113157 try :
114158 services .remove (old )
115- if new :
159+ if new and new not in services :
116160 services .append (new )
117161 except ValueError :
118162 pass
0 commit comments