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                    "type": "tree",
63                    "rules": [
64                        {
65                            "conditions": [
66                                {
67                                    "fn": "booleanEquals",
68                                    "argv": [
69                                        {
70                                            "ref": "UseDualStack"
71                                        },
72                                        true
73                                    ]
74                                }
75                            ],
76                            "error": "Invalid Configuration: Dualstack and custom endpoint are not supported",
77                            "type": "error"
78                        },
79                        {
80                            "conditions": [],
81                            "endpoint": {
82                                "url": {
83                                    "ref": "Endpoint"
84                                },
85                                "properties": {},
86                                "headers": {}
87                            },
88                            "type": "endpoint"
89                        }
90                    ]
91                }
92            ]
93        },
94        {
95            "conditions": [],
96            "type": "tree",
97            "rules": [
98                {
99                    "conditions": [
100                        {
101                            "fn": "isSet",
102                            "argv": [
103                                {
104                                    "ref": "Region"
105                                }
106                            ]
107                        }
108                    ],
109                    "type": "tree",
110                    "rules": [
111                        {
112                            "conditions": [
113                                {
114                                    "fn": "aws.partition",
115                                    "argv": [
116                                        {
117                                            "ref": "Region"
118                                        }
119                                    ],
120                                    "assign": "PartitionResult"
121                                }
122                            ],
123                            "type": "tree",
124                            "rules": [
125                                {
126                                    "conditions": [
127                                        {
128                                            "fn": "booleanEquals",
129                                            "argv": [
130                                                {
131                                                    "ref": "UseFIPS"
132                                                },
133                                                true
134                                            ]
135                                        },
136                                        {
137                                            "fn": "booleanEquals",
138                                            "argv": [
139                                                {
140                                                    "ref": "UseDualStack"
141                                                },
142                                                true
143                                            ]
144                                        }
145                                    ],
146                                    "type": "tree",
147                                    "rules": [
148                                        {
149                                            "conditions": [
150                                                {
151                                                    "fn": "booleanEquals",
152                                                    "argv": [
153                                                        true,
154                                                        {
155                                                            "fn": "getAttr",
156                                                            "argv": [
157                                                                {
158                                                                    "ref": "PartitionResult"
159                                                                },
160                                                                "supportsFIPS"
161                                                            ]
162                                                        }
163                                                    ]
164                                                },
165                                                {
166                                                    "fn": "booleanEquals",
167                                                    "argv": [
168                                                        true,
169                                                        {
170                                                            "fn": "getAttr",
171                                                            "argv": [
172                                                                {
173                                                                    "ref": "PartitionResult"
174                                                                },
175                                                                "supportsDualStack"
176                                                            ]
177                                                        }
178                                                    ]
179                                                }
180                                            ],
181                                            "type": "tree",
182                                            "rules": [
183                                                {
184                                                    "conditions": [],
185                                                    "type": "tree",
186                                                    "rules": [
187                                                        {
188                                                            "conditions": [],
189                                                            "endpoint": {
190                                                                "url": "https://glacier-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",
191                                                                "properties": {},
192                                                                "headers": {}
193                                                            },
194                                                            "type": "endpoint"
195                                                        }
196                                                    ]
197                                                }
198                                            ]
199                                        },
200                                        {
201                                            "conditions": [],
202                                            "error": "FIPS and DualStack are enabled, but this partition does not support one or both",
203                                            "type": "error"
204                                        }
205                                    ]
206                                },
207                                {
208                                    "conditions": [
209                                        {
210                                            "fn": "booleanEquals",
211                                            "argv": [
212                                                {
213                                                    "ref": "UseFIPS"
214                                                },
215                                                true
216                                            ]
217                                        }
218                                    ],
219                                    "type": "tree",
220                                    "rules": [
221                                        {
222                                            "conditions": [
223                                                {
224                                                    "fn": "booleanEquals",
225                                                    "argv": [
226                                                        true,
227                                                        {
228                                                            "fn": "getAttr",
229                                                            "argv": [
230                                                                {
231                                                                    "ref": "PartitionResult"
232                                                                },
233                                                                "supportsFIPS"
234                                                            ]
235                                                        }
236                                                    ]
237                                                }
238                                            ],
239                                            "type": "tree",
240                                            "rules": [
241                                                {
242                                                    "conditions": [],
243                                                    "type": "tree",
244                                                    "rules": [
245                                                        {
246                                                            "conditions": [
247                                                                {
248                                                                    "fn": "stringEquals",
249                                                                    "argv": [
250                                                                        "aws-us-gov",
251                                                                        {
252                                                                            "fn": "getAttr",
253                                                                            "argv": [
254                                                                                {
255                                                                                    "ref": "PartitionResult"
256                                                                                },
257                                                                                "name"
258                                                                            ]
259                                                                        }
260                                                                    ]
261                                                                }
262                                                            ],
263                                                            "endpoint": {
264                                                                "url": "https://glacier.{Region}.amazonaws.com",
265                                                                "properties": {},
266                                                                "headers": {}
267                                                            },
268                                                            "type": "endpoint"
269                                                        },
270                                                        {
271                                                            "conditions": [],
272                                                            "endpoint": {
273                                                                "url": "https://glacier-fips.{Region}.{PartitionResult#dnsSuffix}",
274                                                                "properties": {},
275                                                                "headers": {}
276                                                            },
277                                                            "type": "endpoint"
278                                                        }
279                                                    ]
280                                                }
281                                            ]
282                                        },
283                                        {
284                                            "conditions": [],
285                                            "error": "FIPS is enabled but this partition does not support FIPS",
286                                            "type": "error"
287                                        }
288                                    ]
289                                },
290                                {
291                                    "conditions": [
292                                        {
293                                            "fn": "booleanEquals",
294                                            "argv": [
295                                                {
296                                                    "ref": "UseDualStack"
297                                                },
298                                                true
299                                            ]
300                                        }
301                                    ],
302                                    "type": "tree",
303                                    "rules": [
304                                        {
305                                            "conditions": [
306                                                {
307                                                    "fn": "booleanEquals",
308                                                    "argv": [
309                                                        true,
310                                                        {
311                                                            "fn": "getAttr",
312                                                            "argv": [
313                                                                {
314                                                                    "ref": "PartitionResult"
315                                                                },
316                                                                "supportsDualStack"
317                                                            ]
318                                                        }
319                                                    ]
320                                                }
321                                            ],
322                                            "type": "tree",
323                                            "rules": [
324                                                {
325                                                    "conditions": [],
326                                                    "type": "tree",
327                                                    "rules": [
328                                                        {
329                                                            "conditions": [],
330                                                            "endpoint": {
331                                                                "url": "https://glacier.{Region}.{PartitionResult#dualStackDnsSuffix}",
332                                                                "properties": {},
333                                                                "headers": {}
334                                                            },
335                                                            "type": "endpoint"
336                                                        }
337                                                    ]
338                                                }
339                                            ]
340                                        },
341                                        {
342                                            "conditions": [],
343                                            "error": "DualStack is enabled but this partition does not support DualStack",
344                                            "type": "error"
345                                        }
346                                    ]
347                                },
348                                {
349                                    "conditions": [],
350                                    "type": "tree",
351                                    "rules": [
352                                        {
353                                            "conditions": [],
354                                            "endpoint": {
355                                                "url": "https://glacier.{Region}.{PartitionResult#dnsSuffix}",
356                                                "properties": {},
357                                                "headers": {}
358                                            },
359                                            "type": "endpoint"
360                                        }
361                                    ]
362                                }
363                            ]
364                        }
365                    ]
366                },
367                {
368                    "conditions": [],
369                    "error": "Invalid Configuration: Missing Region",
370                    "type": "error"
371                }
372            ]
373        }
374    ]
375}