Skip to content

Commit

Permalink
feat(client-support): This fixes incorrect endpoint construction when…
Browse files Browse the repository at this point in the history
… a customer is explicitly setting a region.
  • Loading branch information
awstools committed Jan 31, 2023
1 parent 32e4b9e commit c6f86d2
Show file tree
Hide file tree
Showing 2 changed files with 1,212 additions and 109 deletions.
54 changes: 36 additions & 18 deletions clients/client-support/src/endpoint/ruleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@ import { RuleSetObject } from "@aws-sdk/util-endpoints";
or see "smithy.rules#endpointRuleSet"
in codegen/sdk-codegen/aws-models/support.json */

const w="fn",
x="argv",
y="ref";
const E="type",
F="rules",
G="conditions",
H="fn",
I="argv",
J="ref",
K="url",
L="properties",
M="headers",
N="authSchemes",
O="name",
P="signingRegion",
Q="signingName";
const a=true,
b=false,
c="String",
Expand All @@ -17,19 +27,27 @@ e="tree",
f="error",
g="endpoint",
h="stringEquals",
i="us-gov-west-1",
j="https://support.us-gov-west-1.amazonaws.com",
k="sigv4",
l="support",
m={"required":true,"default":false,"type":"Boolean"},
n={[y]:"Region"},
o={[y]:"Endpoint"},
p={[w]:"booleanEquals",[x]:[{[y]:"UseFIPS"},true]},
q={[w]:"booleanEquals",[x]:[{[y]:"UseDualStack"},true]},
r={},
s={[w]:"booleanEquals",[x]:[true,{[w]:"getAttr",[x]:[{[y]:d},"supportsFIPS"]}]},
t={[w]:"booleanEquals",[x]:[true,{[w]:"getAttr",[x]:[{[y]:d},"supportsDualStack"]}]},
u=[p],
v=[q];
const _data={version:"1.0",parameters:{Region:{required:a,type:c},UseDualStack:m,UseFIPS:m,Endpoint:{required:b,type:c}},rules:[{conditions:[{[w]:"aws.partition",[x]:[n],assign:d}],type:e,rules:[{conditions:[{[w]:"isSet",[x]:[o]}],type:e,rules:[{conditions:u,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:f},{type:e,rules:[{conditions:v,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:f},{endpoint:{url:o,properties:r,headers:r},type:g}]}]},{conditions:[p,q],type:e,rules:[{conditions:[s,t],type:e,rules:[{endpoint:{url:"https://support-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:r,headers:r},type:g}]},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:f}]},{conditions:u,type:e,rules:[{conditions:[s],type:e,rules:[{type:e,rules:[{conditions:[{[w]:h,[x]:[n,i]}],endpoint:{url:j,properties:r,headers:r},type:g},{endpoint:{url:"https://support-fips.{Region}.{PartitionResult#dnsSuffix}",properties:r,headers:r},type:g}]}]},{error:"FIPS is enabled but this partition does not support FIPS",type:f}]},{conditions:v,type:e,rules:[{conditions:[t],type:e,rules:[{endpoint:{url:"https://support.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:r,headers:r},type:g}]},{error:"DualStack is enabled but this partition does not support DualStack",type:f}]},{type:e,rules:[{conditions:[{[w]:h,[x]:[n,"aws-global"]}],endpoint:{url:"https://support.us-east-1.amazonaws.com",properties:{authSchemes:[{name:k,signingRegion:"us-east-1",signingName:l}]},headers:r},type:g},{conditions:[{[w]:h,[x]:[n,"aws-cn-global"]}],endpoint:{url:"https://support.cn-north-1.amazonaws.com.cn",properties:{authSchemes:[{name:k,signingRegion:"cn-north-1",signingName:l}]},headers:r},type:g},{conditions:[{[w]:h,[x]:[n,"aws-us-gov-global"]}],endpoint:{url:j,properties:{authSchemes:[{name:k,signingRegion:i,signingName:l}]},headers:r},type:g},{conditions:[{[w]:h,[x]:[n,"aws-iso-global"]}],endpoint:{url:"https://support.us-iso-east-1.c2s.ic.gov",properties:{authSchemes:[{name:k,signingRegion:"us-iso-east-1",signingName:l}]},headers:r},type:g},{conditions:[{[w]:h,[x]:[n,"aws-iso-b-global"]}],endpoint:{url:"https://support.us-isob-east-1.sc2s.sgov.gov",properties:{authSchemes:[{name:k,signingRegion:"us-isob-east-1",signingName:l}]},headers:r},type:g},{endpoint:{url:"https://support.{Region}.{PartitionResult#dnsSuffix}",properties:r,headers:r},type:g}]}]}]};
i={"required":true,"default":false,[E]:"Boolean"},
j={[J]:"Region"},
k={[J]:"Endpoint"},
l={},
m={[H]:"getAttr",[I]:[{[J]:d},"name"]},
n={[G]:[{[H]:"booleanEquals",[I]:[{[J]:"UseFIPS"},true]},{[H]:"booleanEquals",[I]:[{[J]:"UseDualStack"},true]}],[E]:e,[F]:[{[G]:[{[H]:"booleanEquals",[I]:[true,{[H]:"getAttr",[I]:[{[J]:d},"supportsFIPS"]}]},{[H]:"booleanEquals",[I]:[true,{[H]:"getAttr",[I]:[{[J]:d},"supportsDualStack"]}]}],[E]:e,[F]:[{[g]:{[K]:"https://support-fips.{Region}.api.aws",[L]:{},[M]:{}},[E]:g}]},{[f]:"FIPS and DualStack are enabled, but this partition does not support one or both",[E]:f}]},
o={[f]:"FIPS and DualStack are enabled, but this partition does not support one or both",[E]:f},
p={[G]:[{[H]:"booleanEquals",[I]:[{[J]:"UseFIPS"},true]}],[E]:e,[F]:[{[G]:[{[H]:"booleanEquals",[I]:[true,{[H]:"getAttr",[I]:[{[J]:d},"supportsFIPS"]}]}],[E]:e,[F]:[{[g]:{[K]:"https://support-fips.{Region}.amazonaws.com",[L]:{},[M]:{}},[E]:g}]},{[f]:"FIPS is enabled but this partition does not support FIPS",[E]:f}]},
q={[f]:"FIPS is enabled but this partition does not support FIPS",[E]:f},
r={[G]:[{[H]:"booleanEquals",[I]:[{[J]:"UseDualStack"},true]}],[E]:e,[F]:[{[G]:[{[H]:"booleanEquals",[I]:[true,{[H]:"getAttr",[I]:[{[J]:d},"supportsDualStack"]}]}],[E]:e,[F]:[{[g]:{[K]:"https://support.{Region}.api.aws",[L]:{},[M]:{}},[E]:g}]},{[f]:"DualStack is enabled but this partition does not support DualStack",[E]:f}]},
s={[f]:"DualStack is enabled but this partition does not support DualStack",[E]:f},
t={[K]:"https://support.us-east-1.amazonaws.com",[L]:{[N]:[{[O]:"sigv4",[P]:"us-east-1",[Q]:"support"}]},[M]:{}},
u={[K]:"https://support.cn-north-1.amazonaws.com.cn",[L]:{[N]:[{[O]:"sigv4",[P]:"cn-north-1",[Q]:"support"}]},[M]:{}},
v={[K]:"https://support.us-gov-west-1.amazonaws.com",[L]:{[N]:[{[O]:"sigv4",[P]:"us-gov-west-1",[Q]:"support"}]},[M]:{}},
w={[K]:"https://support.us-iso-east-1.c2s.ic.gov",[L]:{[N]:[{[O]:"sigv4",[P]:"us-iso-east-1",[Q]:"support"}]},[M]:{}},
x={[K]:"https://support.us-isob-east-1.sc2s.sgov.gov",[L]:{[N]:[{[O]:"sigv4",[P]:"us-isob-east-1",[Q]:"support"}]},[M]:{}},
y=[{[H]:"booleanEquals",[I]:[{[J]:"UseFIPS"},true]}],
z=[{[H]:"booleanEquals",[I]:[{[J]:"UseDualStack"},true]}],
A=[{[H]:"booleanEquals",[I]:[{[J]:"UseFIPS"},true]},{[H]:"booleanEquals",[I]:[{[J]:"UseDualStack"},true]}],
B=[{[H]:"booleanEquals",[I]:[true,{[H]:"getAttr",[I]:[{[J]:d},"supportsFIPS"]}]},{[H]:"booleanEquals",[I]:[true,{[H]:"getAttr",[I]:[{[J]:d},"supportsDualStack"]}]}],
C=[{[H]:"booleanEquals",[I]:[true,{[H]:"getAttr",[I]:[{[J]:d},"supportsFIPS"]}]}],
D=[{[H]:"booleanEquals",[I]:[true,{[H]:"getAttr",[I]:[{[J]:d},"supportsDualStack"]}]}];
const _data={version:"1.0",parameters:{Region:{required:a,[E]:c},UseDualStack:i,UseFIPS:i,Endpoint:{required:b,[E]:c}},[F]:[{[G]:[{[H]:"aws.partition",[I]:[j],assign:d}],[E]:e,[F]:[{[G]:[{[H]:"isSet",[I]:[k]}],[E]:e,[F]:[{[G]:y,error:"Invalid Configuration: FIPS and custom endpoint are not supported",[E]:f},{[E]:e,[F]:[{[G]:z,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",[E]:f},{endpoint:{[K]:k,[L]:l,[M]:l},[E]:g}]}]},{[G]:[{[H]:h,[I]:[m,"aws"]}],[E]:e,[F]:[n,p,r,{endpoint:t,[E]:g}]},{[G]:[{[H]:h,[I]:[m,"aws-cn"]}],[E]:e,[F]:[{[G]:A,[E]:e,[F]:[{[G]:B,[E]:e,[F]:[{endpoint:{[K]:"https://support-fips.{Region}.api.amazonwebservices.com.cn",[L]:l,[M]:l},[E]:g}]},o]},{[G]:y,[E]:e,[F]:[{[G]:C,[E]:e,[F]:[{endpoint:{[K]:"https://support-fips.{Region}.amazonaws.com.cn",[L]:l,[M]:l},[E]:g}]},q]},{[G]:z,[E]:e,[F]:[{[G]:D,[E]:e,[F]:[{endpoint:{[K]:"https://support.{Region}.api.amazonwebservices.com.cn",[L]:l,[M]:l},[E]:g}]},s]},{endpoint:u,[E]:g}]},{[G]:[{[H]:h,[I]:[m,"aws-us-gov"]}],[E]:e,[F]:[n,p,r,{endpoint:v,[E]:g}]},{[G]:[{[H]:h,[I]:[m,"aws-iso"]}],[E]:e,[F]:[{[G]:y,[E]:e,[F]:[{[G]:C,[E]:e,[F]:[{endpoint:{[K]:"https://support-fips.{Region}.c2s.ic.gov",[L]:l,[M]:l},[E]:g}]},q]},{endpoint:w,[E]:g}]},{[G]:[{[H]:h,[I]:[m,"aws-iso-b"]}],[E]:e,[F]:[{[G]:y,[E]:e,[F]:[{[G]:C,[E]:e,[F]:[{endpoint:{[K]:"https://support-fips.{Region}.sc2s.sgov.gov",[L]:l,[M]:l},[E]:g}]},q]},{endpoint:x,[E]:g}]},{[G]:A,[E]:e,[F]:[{[G]:B,[E]:e,[F]:[{[E]:e,[F]:[{endpoint:{[K]:"https://support-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",[L]:l,[M]:l},[E]:g}]}]},o]},{[G]:y,[E]:e,[F]:[{[G]:C,[E]:e,[F]:[{[E]:e,[F]:[{endpoint:{[K]:"https://support-fips.{Region}.{PartitionResult#dnsSuffix}",[L]:l,[M]:l},[E]:g}]}]},q]},{[G]:z,[E]:e,[F]:[{[G]:D,[E]:e,[F]:[{[E]:e,[F]:[{endpoint:{[K]:"https://support.{Region}.{PartitionResult#dualStackDnsSuffix}",[L]:l,[M]:l},[E]:g}]}]},s]},{[E]:e,[F]:[{[G]:[{[H]:h,[I]:[j,"aws-global"]}],endpoint:t,[E]:g},{[G]:[{[H]:h,[I]:[j,"aws-cn-global"]}],endpoint:u,[E]:g},{[G]:[{[H]:h,[I]:[j,"aws-us-gov-global"]}],endpoint:v,[E]:g},{[G]:[{[H]:h,[I]:[j,"aws-iso-global"]}],endpoint:w,[E]:g},{[G]:[{[H]:h,[I]:[j,"aws-iso-b-global"]}],endpoint:x,[E]:g},{endpoint:{[K]:"https://support.{Region}.{PartitionResult#dnsSuffix}",[L]:l,[M]:l},[E]:g}]}]}]};
export const ruleSet: RuleSetObject = _data;
Loading

0 comments on commit c6f86d2

Please sign in to comment.