@@ -20,6 +20,7 @@ type partition struct {
2020 regions []string
2121 endpointServiceDomainPrefix string
2222 endpointServiceDomainPrefixAlt string
23+ v1SDKDNSPrefix string
2324}
2425
2526type partitions []partition
@@ -38,6 +39,47 @@ var awsPartition = partition{
3839 name : PartitionAWS ,
3940 serviceMappings : standardServiceMappings ,
4041 endpointServiceDomainPrefix : standardPartitionServiceDomainPrefix ,
42+ v1SDKDNSPrefix : "amazonaws.com" ,
43+ regions : []string {
44+ RegionUSWest1 ,
45+ RegionUSWest2 ,
46+ RegionUSEast1 ,
47+ RegionUSEast2 ,
48+ RegionCACentral1 ,
49+ RegionCAWest1 ,
50+ RegionEUWest1 ,
51+ RegionEUWest2 ,
52+ RegionEUWest3 ,
53+ RegionEUNorth1 ,
54+ RegionEUCentral1 ,
55+ RegionEUCentral2 ,
56+ RegionEUSouth1 ,
57+ RegionEUSouth2 ,
58+ RegionAPNorthEast1 ,
59+ RegionAPNorthEast2 ,
60+ RegionAPNorthEast3 ,
61+ RegionAPSouthEast1 ,
62+ RegionAPSouthEast2 ,
63+ RegionAPSouthEast3 ,
64+ RegionAPSouthEast4 ,
65+ RegionAPSouthEast5 ,
66+ RegionAPSouthEast7 ,
67+ RegionAPSouth1 ,
68+ RegionAPSouth2 ,
69+ RegionAPEast1 ,
70+ RegionAPEast2 ,
71+ RegionMECentral1 ,
72+ RegionMESouth1 ,
73+ RegionSAEast1 ,
74+ RegionAFSouth1 ,
75+ RegionILCentral1 ,
76+ RegionMXCentral1 ,
77+ RegionAPSoutheast6 ,
78+ },
79+ }
80+
81+ func (p partition ) Name () string {
82+ return p .name
4183}
4284
4385// Partitions is a list of supported AWS partitions.
@@ -48,6 +90,7 @@ var Partitions = partitions{
4890 serviceMappings : standardServiceMappings ,
4991 regions : []string {RegionUSGovEast1 , RegionUSGovWest1 },
5092 endpointServiceDomainPrefix : standardPartitionServiceDomainPrefix ,
93+ v1SDKDNSPrefix : "amazonaws.com" ,
5194 },
5295 {
5396 name : PartitionChina ,
@@ -58,6 +101,7 @@ var Partitions = partitions{
58101 },
59102 regions : []string {RegionCNNorth1 , RegionCNNorthwest1 },
60103 endpointServiceDomainPrefix : fmt .Sprintf ("cn.%s" , standardPartitionServiceDomainPrefix ),
104+ v1SDKDNSPrefix : "amazonaws.com.cn" ,
61105 },
62106 {
63107 name : PartitionISO ,
@@ -68,6 +112,7 @@ var Partitions = partitions{
68112 },
69113 regions : []string {RegionUSISOEast1 , RegionUSISOWest1 },
70114 endpointServiceDomainPrefix : "gov.ic.c2s" ,
115+ v1SDKDNSPrefix : "c2s.ic.gov" ,
71116 },
72117 {
73118 name : PartitionISOB ,
@@ -78,6 +123,7 @@ var Partitions = partitions{
78123 },
79124 regions : []string {RegionUSISOBEast1 },
80125 endpointServiceDomainPrefix : "gov.sgov.sc2s" ,
126+ v1SDKDNSPrefix : "sc2s.sgov.gov" ,
81127 },
82128 {
83129 name : PartitionISOE ,
@@ -89,6 +135,7 @@ var Partitions = partitions{
89135 regions : []string {RegionEUISOEWest1 },
90136 endpointServiceDomainPrefix : standardPartitionServiceDomainPrefix ,
91137 endpointServiceDomainPrefixAlt : "uk.adc-e.cloud" ,
138+ v1SDKDNSPrefix : "cloud.adc-e.uk" ,
92139 },
93140 {
94141 name : PartitionISOF ,
@@ -100,19 +147,36 @@ var Partitions = partitions{
100147 regions : []string {RegionUSISOFSouth1 , RegionUSISOFEast1 },
101148 endpointServiceDomainPrefix : standardPartitionServiceDomainPrefix ,
102149 endpointServiceDomainPrefixAlt : "gov.ic.hci.csp" ,
150+ v1SDKDNSPrefix : "csp.hci.ic.gov" ,
103151 },
104152}
105153
106- // ForRegion returns the partition a region belongs to.
107- func (p partitions ) ForRegion (region string ) string {
154+ func (p partitions ) partitionFromRegion (region string ) * partition {
108155 for _ , pt := range p {
109156 for _ , r := range pt .regions {
110157 if r == region {
111- return pt . name
158+ return & pt
112159 }
113160 }
114161 }
115- return PartitionAWS
162+ return nil
163+ }
164+
165+ // ForRegion returns the partition a region belongs to.
166+ func (p partitions ) ForRegion (region string ) string {
167+ pt := p .partitionFromRegion (region )
168+ if pt == nil {
169+ return PartitionAWS
170+ }
171+ return pt .name
172+ }
173+
174+ func (p partitions ) V1SDKDNSPrefixForRegion (region string ) (string , error ) {
175+ pt := p .partitionFromRegion (region )
176+ if pt == nil {
177+ return "" , fmt .Errorf ("failed to find DNS suffix for region %s" , region )
178+ }
179+ return pt .v1SDKDNSPrefix , nil
116180}
117181
118182// GetEndpointServiceDomainPrefix returns the domain prefix for the endpoint service.
0 commit comments