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": "stringEquals",
119                                    "argv": [
120                                        {
121                                            "fn": "getAttr",
122                                            "argv": [
123                                                {
124                                                    "ref": "PartitionResult"
125                                                },
126                                                "name"
127                                            ]
128                                        },
129                                        "aws"
130                                    ]
131                                },
132                                {
133                                    "fn": "booleanEquals",
134                                    "argv": [
135                                        {
136                                            "ref": "UseFIPS"
137                                        },
138                                        false
139                                    ]
140                                },
141                                {
142                                    "fn": "booleanEquals",
143                                    "argv": [
144                                        {
145                                            "ref": "UseDualStack"
146                                        },
147                                        false
148                                    ]
149                                }
150                            ],
151                            "endpoint": {
152                                "url": "https://savingsplans.amazonaws.com",
153                                "properties": {
154                                    "authSchemes": [
155                                        {
156                                            "name": "sigv4",
157                                            "signingName": "savingsplans",
158                                            "signingRegion": "us-east-1"
159                                        }
160                                    ]
161                                },
162                                "headers": {}
163                            },
164                            "type": "endpoint"
165                        },
166                        {
167                            "conditions": [
168                                {
169                                    "fn": "booleanEquals",
170                                    "argv": [
171                                        {
172                                            "ref": "UseFIPS"
173                                        },
174                                        true
175                                    ]
176                                },
177                                {
178                                    "fn": "booleanEquals",
179                                    "argv": [
180                                        {
181                                            "ref": "UseDualStack"
182                                        },
183                                        true
184                                    ]
185                                }
186                            ],
187                            "type": "tree",
188                            "rules": [
189                                {
190                                    "conditions": [
191                                        {
192                                            "fn": "booleanEquals",
193                                            "argv": [
194                                                true,
195                                                {
196                                                    "fn": "getAttr",
197                                                    "argv": [
198                                                        {
199                                                            "ref": "PartitionResult"
200                                                        },
201                                                        "supportsFIPS"
202                                                    ]
203                                                }
204                                            ]
205                                        },
206                                        {
207                                            "fn": "booleanEquals",
208                                            "argv": [
209                                                true,
210                                                {
211                                                    "fn": "getAttr",
212                                                    "argv": [
213                                                        {
214                                                            "ref": "PartitionResult"
215                                                        },
216                                                        "supportsDualStack"
217                                                    ]
218                                                }
219                                            ]
220                                        }
221                                    ],
222                                    "type": "tree",
223                                    "rules": [
224                                        {
225                                            "conditions": [],
226                                            "endpoint": {
227                                                "url": "https://savingsplans-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",
228                                                "properties": {},
229                                                "headers": {}
230                                            },
231                                            "type": "endpoint"
232                                        }
233                                    ]
234                                },
235                                {
236                                    "conditions": [],
237                                    "error": "FIPS and DualStack are enabled, but this partition does not support one or both",
238                                    "type": "error"
239                                }
240                            ]
241                        },
242                        {
243                            "conditions": [
244                                {
245                                    "fn": "booleanEquals",
246                                    "argv": [
247                                        {
248                                            "ref": "UseFIPS"
249                                        },
250                                        true
251                                    ]
252                                }
253                            ],
254                            "type": "tree",
255                            "rules": [
256                                {
257                                    "conditions": [
258                                        {
259                                            "fn": "booleanEquals",
260                                            "argv": [
261                                                true,
262                                                {
263                                                    "fn": "getAttr",
264                                                    "argv": [
265                                                        {
266                                                            "ref": "PartitionResult"
267                                                        },
268                                                        "supportsFIPS"
269                                                    ]
270                                                }
271                                            ]
272                                        }
273                                    ],
274                                    "type": "tree",
275                                    "rules": [
276                                        {
277                                            "conditions": [],
278                                            "endpoint": {
279                                                "url": "https://savingsplans-fips.{Region}.{PartitionResult#dnsSuffix}",
280                                                "properties": {},
281                                                "headers": {}
282                                            },
283                                            "type": "endpoint"
284                                        }
285                                    ]
286                                },
287                                {
288                                    "conditions": [],
289                                    "error": "FIPS is enabled but this partition does not support FIPS",
290                                    "type": "error"
291                                }
292                            ]
293                        },
294                        {
295                            "conditions": [
296                                {
297                                    "fn": "booleanEquals",
298                                    "argv": [
299                                        {
300                                            "ref": "UseDualStack"
301                                        },
302                                        true
303                                    ]
304                                }
305                            ],
306                            "type": "tree",
307                            "rules": [
308                                {
309                                    "conditions": [
310                                        {
311                                            "fn": "booleanEquals",
312                                            "argv": [
313                                                true,
314                                                {
315                                                    "fn": "getAttr",
316                                                    "argv": [
317                                                        {
318                                                            "ref": "PartitionResult"
319                                                        },
320                                                        "supportsDualStack"
321                                                    ]
322                                                }
323                                            ]
324                                        }
325                                    ],
326                                    "type": "tree",
327                                    "rules": [
328                                        {
329                                            "conditions": [],
330                                            "endpoint": {
331                                                "url": "https://savingsplans.{Region}.{PartitionResult#dualStackDnsSuffix}",
332                                                "properties": {},
333                                                "headers": {}
334                                            },
335                                            "type": "endpoint"
336                                        }
337                                    ]
338                                },
339                                {
340                                    "conditions": [],
341                                    "error": "DualStack is enabled but this partition does not support DualStack",
342                                    "type": "error"
343                                }
344                            ]
345                        },
346                        {
347                            "conditions": [],
348                            "endpoint": {
349                                "url": "https://savingsplans.{Region}.{PartitionResult#dnsSuffix}",
350                                "properties": {},
351                                "headers": {}
352                            },
353                            "type": "endpoint"
354                        }
355                    ]
356                }
357            ]
358        },
359        {
360            "conditions": [],
361            "error": "Invalid Configuration: Missing Region",
362            "type": "error"
363        }
364    ]
365}