1{
2    "version": "1.0",
3    "parameters": {
4        "Region": {
5            "builtIn": "AWS::Region",
6            "required": false,
7            "documentation": "The AWS region used to dispatch the request.",
8            "type": "String"
9        },
10        "UseDualStack": {
11            "builtIn": "AWS::UseDualStack",
12            "required": true,
13            "default": false,
14            "documentation": "When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.",
15            "type": "Boolean"
16        },
17        "UseFIPS": {
18            "builtIn": "AWS::UseFIPS",
19            "required": true,
20            "default": false,
21            "documentation": "When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.",
22            "type": "Boolean"
23        },
24        "Endpoint": {
25            "builtIn": "SDK::Endpoint",
26            "required": false,
27            "documentation": "Override the endpoint used to send this request",
28            "type": "String"
29        }
30    },
31    "rules": [
32        {
33            "conditions": [
34                {
35                    "fn": "isSet",
36                    "argv": [
37                        {
38                            "ref": "Endpoint"
39                        }
40                    ]
41                }
42            ],
43            "type": "tree",
44            "rules": [
45                {
46                    "conditions": [
47                        {
48                            "fn": "booleanEquals",
49                            "argv": [
50                                {
51                                    "ref": "UseFIPS"
52                                },
53                                true
54                            ]
55                        }
56                    ],
57                    "error": "Invalid Configuration: FIPS and custom endpoint are not supported",
58                    "type": "error"
59                },
60                {
61                    "conditions": [
62                        {
63                            "fn": "booleanEquals",
64                            "argv": [
65                                {
66                                    "ref": "UseDualStack"
67                                },
68                                true
69                            ]
70                        }
71                    ],
72                    "error": "Invalid Configuration: Dualstack and custom endpoint are not supported",
73                    "type": "error"
74                },
75                {
76                    "conditions": [],
77                    "endpoint": {
78                        "url": {
79                            "ref": "Endpoint"
80                        },
81                        "properties": {},
82                        "headers": {}
83                    },
84                    "type": "endpoint"
85                }
86            ]
87        },
88        {
89            "conditions": [
90                {
91                    "fn": "isSet",
92                    "argv": [
93                        {
94                            "ref": "Region"
95                        }
96                    ]
97                }
98            ],
99            "type": "tree",
100            "rules": [
101                {
102                    "conditions": [
103                        {
104                            "fn": "aws.partition",
105                            "argv": [
106                                {
107                                    "ref": "Region"
108                                }
109                            ],
110                            "assign": "PartitionResult"
111                        }
112                    ],
113                    "type": "tree",
114                    "rules": [
115                        {
116                            "conditions": [
117                                {
118                                    "fn": "booleanEquals",
119                                    "argv": [
120                                        {
121                                            "ref": "UseFIPS"
122                                        },
123                                        true
124                                    ]
125                                },
126                                {
127                                    "fn": "booleanEquals",
128                                    "argv": [
129                                        {
130                                            "ref": "UseDualStack"
131                                        },
132                                        true
133                                    ]
134                                }
135                            ],
136                            "type": "tree",
137                            "rules": [
138                                {
139                                    "conditions": [
140                                        {
141                                            "fn": "booleanEquals",
142                                            "argv": [
143                                                true,
144                                                {
145                                                    "fn": "getAttr",
146                                                    "argv": [
147                                                        {
148                                                            "ref": "PartitionResult"
149                                                        },
150                                                        "supportsFIPS"
151                                                    ]
152                                                }
153                                            ]
154                                        },
155                                        {
156                                            "fn": "booleanEquals",
157                                            "argv": [
158                                                true,
159                                                {
160                                                    "fn": "getAttr",
161                                                    "argv": [
162                                                        {
163                                                            "ref": "PartitionResult"
164                                                        },
165                                                        "supportsDualStack"
166                                                    ]
167                                                }
168                                            ]
169                                        }
170                                    ],
171                                    "type": "tree",
172                                    "rules": [
173                                        {
174                                            "conditions": [],
175                                            "endpoint": {
176                                                "url": "https://runtime.lex-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",
177                                                "properties": {},
178                                                "headers": {}
179                                            },
180                                            "type": "endpoint"
181                                        }
182                                    ]
183                                },
184                                {
185                                    "conditions": [],
186                                    "error": "FIPS and DualStack are enabled, but this partition does not support one or both",
187                                    "type": "error"
188                                }
189                            ]
190                        },
191                        {
192                            "conditions": [
193                                {
194                                    "fn": "booleanEquals",
195                                    "argv": [
196                                        {
197                                            "ref": "UseFIPS"
198                                        },
199                                        true
200                                    ]
201                                }
202                            ],
203                            "type": "tree",
204                            "rules": [
205                                {
206                                    "conditions": [
207                                        {
208                                            "fn": "booleanEquals",
209                                            "argv": [
210                                                true,
211                                                {
212                                                    "fn": "getAttr",
213                                                    "argv": [
214                                                        {
215                                                            "ref": "PartitionResult"
216                                                        },
217                                                        "supportsFIPS"
218                                                    ]
219                                                }
220                                            ]
221                                        }
222                                    ],
223                                    "type": "tree",
224                                    "rules": [
225                                        {
226                                            "conditions": [
227                                                {
228                                                    "fn": "stringEquals",
229                                                    "argv": [
230                                                        "aws",
231                                                        {
232                                                            "fn": "getAttr",
233                                                            "argv": [
234                                                                {
235                                                                    "ref": "PartitionResult"
236                                                                },
237                                                                "name"
238                                                            ]
239                                                        }
240                                                    ]
241                                                }
242                                            ],
243                                            "endpoint": {
244                                                "url": "https://runtime-fips.lex.{Region}.amazonaws.com",
245                                                "properties": {},
246                                                "headers": {}
247                                            },
248                                            "type": "endpoint"
249                                        },
250                                        {
251                                            "conditions": [
252                                                {
253                                                    "fn": "stringEquals",
254                                                    "argv": [
255                                                        "aws-us-gov",
256                                                        {
257                                                            "fn": "getAttr",
258                                                            "argv": [
259                                                                {
260                                                                    "ref": "PartitionResult"
261                                                                },
262                                                                "name"
263                                                            ]
264                                                        }
265                                                    ]
266                                                }
267                                            ],
268                                            "endpoint": {
269                                                "url": "https://runtime-fips.lex.{Region}.amazonaws.com",
270                                                "properties": {},
271                                                "headers": {}
272                                            },
273                                            "type": "endpoint"
274                                        },
275                                        {
276                                            "conditions": [],
277                                            "endpoint": {
278                                                "url": "https://runtime.lex-fips.{Region}.{PartitionResult#dnsSuffix}",
279                                                "properties": {},
280                                                "headers": {}
281                                            },
282                                            "type": "endpoint"
283                                        }
284                                    ]
285                                },
286                                {
287                                    "conditions": [],
288                                    "error": "FIPS is enabled but this partition does not support FIPS",
289                                    "type": "error"
290                                }
291                            ]
292                        },
293                        {
294                            "conditions": [
295                                {
296                                    "fn": "booleanEquals",
297                                    "argv": [
298                                        {
299                                            "ref": "UseDualStack"
300                                        },
301                                        true
302                                    ]
303                                }
304                            ],
305                            "type": "tree",
306                            "rules": [
307                                {
308                                    "conditions": [
309                                        {
310                                            "fn": "booleanEquals",
311                                            "argv": [
312                                                true,
313                                                {
314                                                    "fn": "getAttr",
315                                                    "argv": [
316                                                        {
317                                                            "ref": "PartitionResult"
318                                                        },
319                                                        "supportsDualStack"
320                                                    ]
321                                                }
322                                            ]
323                                        }
324                                    ],
325                                    "type": "tree",
326                                    "rules": [
327                                        {
328                                            "conditions": [],
329                                            "endpoint": {
330                                                "url": "https://runtime.lex.{Region}.{PartitionResult#dualStackDnsSuffix}",
331                                                "properties": {},
332                                                "headers": {}
333                                            },
334                                            "type": "endpoint"
335                                        }
336                                    ]
337                                },
338                                {
339                                    "conditions": [],
340                                    "error": "DualStack is enabled but this partition does not support DualStack",
341                                    "type": "error"
342                                }
343                            ]
344                        },
345                        {
346                            "conditions": [
347                                {
348                                    "fn": "stringEquals",
349                                    "argv": [
350                                        "aws",
351                                        {
352                                            "fn": "getAttr",
353                                            "argv": [
354                                                {
355                                                    "ref": "PartitionResult"
356                                                },
357                                                "name"
358                                            ]
359                                        }
360                                    ]
361                                }
362                            ],
363                            "endpoint": {
364                                "url": "https://runtime.lex.{Region}.amazonaws.com",
365                                "properties": {},
366                                "headers": {}
367                            },
368                            "type": "endpoint"
369                        },
370                        {
371                            "conditions": [
372                                {
373                                    "fn": "stringEquals",
374                                    "argv": [
375                                        "aws-us-gov",
376                                        {
377                                            "fn": "getAttr",
378                                            "argv": [
379                                                {
380                                                    "ref": "PartitionResult"
381                                                },
382                                                "name"
383                                            ]
384                                        }
385                                    ]
386                                }
387                            ],
388                            "endpoint": {
389                                "url": "https://runtime.lex.{Region}.amazonaws.com",
390                                "properties": {},
391                                "headers": {}
392                            },
393                            "type": "endpoint"
394                        },
395                        {
396                            "conditions": [],
397                            "endpoint": {
398                                "url": "https://runtime.lex.{Region}.{PartitionResult#dnsSuffix}",
399                                "properties": {},
400                                "headers": {}
401                            },
402                            "type": "endpoint"
403                        }
404                    ]
405                }
406            ]
407        },
408        {
409            "conditions": [],
410            "error": "Invalid Configuration: Missing Region",
411            "type": "error"
412        }
413    ]
414}