0
# Partition Resolution
1
2
The partition resolution functionality provides AWS region-to-partition mapping and partition-specific endpoint information. This is essential for resolving AWS service endpoints across different AWS partitions (commercial, GovCloud, China, etc.).
3
4
## Capabilities
5
6
### AwsPartition Function
7
8
The core library function for mapping AWS regions to partition information.
9
10
```java { .api }
11
/**
12
* An AWS rule-set function for mapping a region string to a partition.
13
*/
14
public final class AwsPartition extends LibraryFunction {
15
/** Function identifier used in endpoint rules */
16
public static final String ID = "aws.partition";
17
18
/** Result field identifiers */
19
public static final Identifier NAME = Identifier.of("name");
20
public static final Identifier DNS_SUFFIX = Identifier.of("dnsSuffix");
21
public static final Identifier DUAL_STACK_DNS_SUFFIX = Identifier.of("dualStackDnsSuffix");
22
public static final Identifier SUPPORTS_FIPS = Identifier.of("supportsFIPS");
23
public static final Identifier SUPPORTS_DUAL_STACK = Identifier.of("supportsDualStack");
24
public static final Identifier IMPLICIT_GLOBAL_REGION = Identifier.of("implicitGlobalRegion");
25
public static final Identifier INFERRED = Identifier.of("inferred");
26
27
/**
28
* Gets the function definition for use in the rules engine
29
* @return Function definition instance
30
*/
31
public static Definition getDefinition();
32
33
/**
34
* Creates a partition function from the given region expression
35
* @param region Expression that evaluates to an AWS region string
36
* @return AwsPartition function instance
37
*/
38
public static AwsPartition ofExpressions(ToExpression region);
39
}
40
```
41
42
### Partition Data Structures
43
44
#### Partition Class
45
```java { .api }
46
/**
47
* Represents an AWS partition with its regions and endpoint configuration
48
*/
49
public final class Partition {
50
/**
51
* Gets the partition name (e.g., "aws", "aws-us-gov", "aws-cn")
52
* @return Partition name
53
*/
54
public String name();
55
56
/**
57
* Gets the DNS suffix for this partition
58
* @return DNS suffix string
59
*/
60
public String dnsSuffix();
61
62
/**
63
* Gets the dual-stack DNS suffix for this partition
64
* @return Dual-stack DNS suffix string
65
*/
66
public String dualStackDnsSuffix();
67
68
/**
69
* Checks if this partition supports FIPS endpoints
70
* @return true if FIPS is supported
71
*/
72
public boolean supportsFips();
73
74
/**
75
* Checks if this partition supports dual-stack endpoints
76
* @return true if dual-stack is supported
77
*/
78
public boolean supportsDualStack();
79
80
/**
81
* Gets the implicit global region for this partition
82
* @return Global region name or null
83
*/
84
public String implicitGlobalRegion();
85
86
/**
87
* Gets the regions contained in this partition
88
* @return Set of region names
89
*/
90
public Set<String> regions();
91
}
92
```
93
94
#### Partitions Management
95
```java { .api }
96
/**
97
* Manages the collection of AWS partitions and provides lookup functionality
98
*/
99
public final class Partitions {
100
/**
101
* Gets all available partitions
102
* @return List of all partitions
103
*/
104
public static List<Partition> getPartitions();
105
106
/**
107
* Looks up partition by region name
108
* @param region AWS region name
109
* @return Partition containing the region, or null if not found
110
*/
111
public static Partition getPartitionForRegion(String region);
112
113
/**
114
* Adds a partition to the collection (primarily for testing)
115
* @param partition Partition to add
116
*/
117
public static void addPartition(Partition partition);
118
119
/**
120
* Clears all partitions (primarily for testing)
121
*/
122
public static void clearPartitions();
123
}
124
```
125
126
#### PartitionOutputs
127
```java { .api }
128
/**
129
* Represents the output structure returned by the aws.partition function
130
*/
131
public final class PartitionOutputs {
132
/**
133
* Creates partition outputs from a partition and region
134
* @param partition Source partition
135
* @param region Region name
136
* @return PartitionOutputs instance
137
*/
138
public static PartitionOutputs of(Partition partition, String region);
139
140
/**
141
* Gets the partition name
142
* @return Partition name
143
*/
144
public String name();
145
146
/**
147
* Gets the DNS suffix
148
* @return DNS suffix
149
*/
150
public String dnsSuffix();
151
152
/**
153
* Gets the dual-stack DNS suffix
154
* @return Dual-stack DNS suffix
155
*/
156
public String dualStackDnsSuffix();
157
158
/**
159
* Checks FIPS support
160
* @return true if FIPS is supported
161
*/
162
public boolean supportsFips();
163
164
/**
165
* Checks dual-stack support
166
* @return true if dual-stack is supported
167
*/
168
public boolean supportsDualStack();
169
170
/**
171
* Gets the implicit global region
172
* @return Global region name
173
*/
174
public String implicitGlobalRegion();
175
176
/**
177
* Indicates if the region was inferred from partition data
178
* @return true if inferred
179
*/
180
public boolean inferred();
181
}
182
```
183
184
### Region Override Support
185
186
#### RegionOverride
187
```java { .api }
188
/**
189
* Provides region override mechanisms for special cases
190
*/
191
public final class RegionOverride {
192
/**
193
* Creates a region override configuration
194
* @param originalRegion Original region name
195
* @param overrideRegion Override region name
196
* @return RegionOverride instance
197
*/
198
public static RegionOverride of(String originalRegion, String overrideRegion);
199
200
/**
201
* Gets the original region
202
* @return Original region name
203
*/
204
public String originalRegion();
205
206
/**
207
* Gets the override region
208
* @return Override region name
209
*/
210
public String overrideRegion();
211
}
212
```
213
214
**Usage Examples:**
215
216
```java
217
import software.amazon.smithy.rulesengine.aws.language.functions.AwsPartition;
218
import software.amazon.smithy.rulesengine.aws.language.functions.partition.*;
219
220
// Using the partition function in rules (conceptual)
221
AwsPartition partitionFunction = AwsPartition.ofExpressions(
222
Expression.of("us-east-1")
223
);
224
225
// Direct partition lookup
226
Partition partition = Partitions.getPartitionForRegion("us-east-1");
227
if (partition != null) {
228
System.out.println("Partition: " + partition.name()); // "aws"
229
System.out.println("DNS Suffix: " + partition.dnsSuffix()); // "amazonaws.com"
230
System.out.println("Supports FIPS: " + partition.supportsFips()); // true
231
}
232
233
// Working with partition outputs
234
PartitionOutputs outputs = PartitionOutputs.of(partition, "us-east-1");
235
String dnsSuffix = outputs.dnsSuffix();
236
boolean supportsDualStack = outputs.supportsDualStack();
237
238
// Get all partitions
239
List<Partition> allPartitions = Partitions.getPartitions();
240
// Typically includes:
241
// - aws (commercial partition)
242
// - aws-us-gov (GovCloud partition)
243
// - aws-cn (China partition)
244
```
245
246
## AWS Partitions
247
248
### Commercial Partition (`aws`)
249
- **Regions**: Most AWS regions (us-east-1, us-west-2, eu-west-1, etc.)
250
- **DNS Suffix**: `amazonaws.com`
251
- **Dual-Stack DNS**: `amazonaws.com`
252
- **FIPS Support**: Yes
253
- **Dual-Stack Support**: Yes
254
255
### GovCloud Partition (`aws-us-gov`)
256
- **Regions**: us-gov-east-1, us-gov-west-1
257
- **DNS Suffix**: `amazonaws.com`
258
- **FIPS Support**: Yes (required)
259
- **Dual-Stack Support**: Yes
260
261
### China Partition (`aws-cn`)
262
- **Regions**: cn-north-1, cn-northwest-1
263
- **DNS Suffix**: `amazonaws.com.cn`
264
- **FIPS Support**: Limited
265
- **Dual-Stack Support**: Yes
266
267
## Function Usage in Rules
268
269
The `aws.partition` function is used in endpoint rules to resolve partition-specific information:
270
271
```
272
# Endpoint rule example (conceptual)
273
aws.partition(Region) -> {
274
name: "aws",
275
dnsSuffix: "amazonaws.com",
276
dualStackDnsSuffix: "amazonaws.com",
277
supportsFIPS: true,
278
supportsDualStack: true,
279
implicitGlobalRegion: "us-east-1",
280
inferred: false
281
}
282
```
283
284
This enables dynamic endpoint construction based on the target AWS partition.