From f8dab61ad7ca35fe145a6d12d9ad46d3d736adbd Mon Sep 17 00:00:00 2001 From: awstools Date: Mon, 23 Dec 2024 19:20:52 +0000 Subject: [PATCH] feat(client-ecr-public): Add support for Dualstack endpoints --- .../src/endpoint/EndpointParameters.ts | 11 +- .../src/endpoint/endpointResolver.ts | 2 +- .../client-ecr-public/src/endpoint/ruleset.ts | 33 +- .../sdk-codegen/aws-models/ecr-public.json | 556 ++---------------- 4 files changed, 78 insertions(+), 524 deletions(-) diff --git a/clients/client-ecr-public/src/endpoint/EndpointParameters.ts b/clients/client-ecr-public/src/endpoint/EndpointParameters.ts index 43751a91e526..988f83f61b21 100644 --- a/clients/client-ecr-public/src/endpoint/EndpointParameters.ts +++ b/clients/client-ecr-public/src/endpoint/EndpointParameters.ts @@ -1,14 +1,13 @@ // smithy-typescript generated code -import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provider } from "@smithy/types"; +import { EndpointParameters as __EndpointParameters, Provider } from "@smithy/types"; /** * @public */ export interface ClientInputEndpointParameters { region?: string | Provider; - useDualstackEndpoint?: boolean | Provider; useFipsEndpoint?: boolean | Provider; - endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; + useDualstackEndpoint?: boolean | Provider; } export type ClientResolvedEndpointParameters = ClientInputEndpointParameters & { @@ -20,22 +19,20 @@ export const resolveClientEndpointParameters = ( ): T & ClientResolvedEndpointParameters => { return { ...options, - useDualstackEndpoint: options.useDualstackEndpoint ?? false, useFipsEndpoint: options.useFipsEndpoint ?? false, + useDualstackEndpoint: options.useDualstackEndpoint ?? false, defaultSigningName: "ecr-public", }; }; export const commonParams = { UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, - Endpoint: { type: "builtInParams", name: "endpoint" }, Region: { type: "builtInParams", name: "region" }, UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { Region?: string; - UseDualStack?: boolean; UseFIPS?: boolean; - Endpoint?: string; + UseDualStack?: boolean; } diff --git a/clients/client-ecr-public/src/endpoint/endpointResolver.ts b/clients/client-ecr-public/src/endpoint/endpointResolver.ts index ccee107f30d6..003b7c8a2b91 100644 --- a/clients/client-ecr-public/src/endpoint/endpointResolver.ts +++ b/clients/client-ecr-public/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], + params: ["Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/clients/client-ecr-public/src/endpoint/ruleset.ts b/clients/client-ecr-public/src/endpoint/ruleset.ts index 3eeb1339574c..40759fdd1ad9 100644 --- a/clients/client-ecr-public/src/endpoint/ruleset.ts +++ b/clients/client-ecr-public/src/endpoint/ruleset.ts @@ -6,27 +6,14 @@ import { RuleSetObject } from "@smithy/types"; or see "smithy.rules#endpointRuleSet" in codegen/sdk-codegen/aws-models/ecr-public.json */ -const s="required", -t="fn", -u="argv", -v="ref"; -const a=true, -b="isSet", -c="booleanEquals", -d="error", -e="endpoint", -f="tree", -g="PartitionResult", -h={[s]:false,"type":"String"}, -i={[s]:true,"default":false,"type":"Boolean"}, -j={[v]:"Endpoint"}, -k={[t]:c,[u]:[{[v]:"UseFIPS"},true]}, -l={[t]:c,[u]:[{[v]:"UseDualStack"},true]}, -m={}, -n={[t]:"getAttr",[u]:[{[v]:g},"supportsFIPS"]}, -o={[t]:c,[u]:[true,{[t]:"getAttr",[u]:[{[v]:g},"supportsDualStack"]}]}, -p=[k], -q=[l], -r=[{[v]:"Region"}]; -const _data={version:"1.0",parameters:{Region:h,UseDualStack:i,UseFIPS:i,Endpoint:h},rules:[{conditions:[{[t]:b,[u]:[j]}],rules:[{conditions:p,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:d},{conditions:q,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:d},{endpoint:{url:j,properties:m,headers:m},type:e}],type:f},{conditions:[{[t]:b,[u]:r}],rules:[{conditions:[{[t]:"aws.partition",[u]:r,assign:g}],rules:[{conditions:[k,l],rules:[{conditions:[{[t]:c,[u]:[a,n]},o],rules:[{endpoint:{url:"https://api.ecr-public-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:m,headers:m},type:e}],type:f},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:d}],type:f},{conditions:p,rules:[{conditions:[{[t]:c,[u]:[n,a]}],rules:[{endpoint:{url:"https://api.ecr-public-fips.{Region}.{PartitionResult#dnsSuffix}",properties:m,headers:m},type:e}],type:f},{error:"FIPS is enabled but this partition does not support FIPS",type:d}],type:f},{conditions:q,rules:[{conditions:[o],rules:[{endpoint:{url:"https://api.ecr-public.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:m,headers:m},type:e}],type:f},{error:"DualStack is enabled but this partition does not support DualStack",type:d}],type:f},{endpoint:{url:"https://api.ecr-public.{Region}.{PartitionResult#dnsSuffix}",properties:m,headers:m},type:e}],type:f}],type:f},{error:"Invalid Configuration: Missing Region",type:d}]}; +const a=false, +b=true, +c="PartitionResult", +d="booleanEquals", +e="error", +f="endpoint", +g="tree", +h={"required":true,"default":false,"type":"Boolean"}, +i=[{"ref":"Region"}]; +const _data={version:"1.0",parameters:{Region:{required:a,type:"String"},UseFIPS:h,UseDualStack:h},rules:[{conditions:[{fn:"isSet",argv:i},{fn:"aws.partition",argv:i,assign:c}],rules:[{conditions:[{fn:d,argv:[{ref:"UseFIPS"},b]}],error:"ECR Public does not support FIPS",type:e},{conditions:[{fn:d,argv:[{ref:"UseDualStack"},b]}],rules:[{conditions:[{fn:d,argv:[b,{fn:"getAttr",argv:[{ref:c},"supportsDualStack"]}]}],rules:[{endpoint:{url:"https://ecr-public.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:{},headers:{}},type:f}],type:g},{error:"Dualstack is enabled but this partition does not support dualstack",type:e}],type:g},{endpoint:{url:"https://api.ecr-public.{Region}.{PartitionResult#dnsSuffix}",properties:{},headers:{}},type:f}],type:g}]}; export const ruleSet: RuleSetObject = _data; diff --git a/codegen/sdk-codegen/aws-models/ecr-public.json b/codegen/sdk-codegen/aws-models/ecr-public.json index 7e51222e3c65..d81862cfbafb 100644 --- a/codegen/sdk-codegen/aws-models/ecr-public.json +++ b/codegen/sdk-codegen/aws-models/ecr-public.json @@ -2868,13 +2868,6 @@ "documentation": "The AWS region used to dispatch the request.", "type": "String" }, - "UseDualStack": { - "builtIn": "AWS::UseDualStack", - "required": true, - "default": false, - "documentation": "When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.", - "type": "Boolean" - }, "UseFIPS": { "builtIn": "AWS::UseFIPS", "required": true, @@ -2882,11 +2875,12 @@ "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.", "type": "Boolean" }, - "Endpoint": { - "builtIn": "SDK::Endpoint", - "required": false, - "documentation": "Override the endpoint used to send this request", - "type": "String" + "UseDualStack": { + "builtIn": "AWS::UseDualStack", + "required": true, + "default": false, + "documentation": "When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.", + "type": "Boolean" } }, "rules": [ @@ -2896,9 +2890,18 @@ "fn": "isSet", "argv": [ { - "ref": "Endpoint" + "ref": "Region" } ] + }, + { + "fn": "aws.partition", + "argv": [ + { + "ref": "Region" + } + ], + "assign": "PartitionResult" } ], "rules": [ @@ -2914,7 +2917,7 @@ ] } ], - "error": "Invalid Configuration: FIPS and custom endpoint are not supported", + "error": "ECR Public does not support FIPS", "type": "error" }, { @@ -2929,559 +2932,126 @@ ] } ], - "error": "Invalid Configuration: Dualstack and custom endpoint are not supported", - "type": "error" - }, - { - "conditions": [], - "endpoint": { - "url": { - "ref": "Endpoint" - }, - "properties": {}, - "headers": {} - }, - "type": "endpoint" - } - ], - "type": "tree" - }, - { - "conditions": [ - { - "fn": "isSet", - "argv": [ - { - "ref": "Region" - } - ] - } - ], - "rules": [ - { - "conditions": [ - { - "fn": "aws.partition", - "argv": [ - { - "ref": "Region" - } - ], - "assign": "PartitionResult" - } - ], "rules": [ { "conditions": [ { "fn": "booleanEquals", "argv": [ + true, { - "ref": "UseFIPS" - }, - true - ] - }, - { - "fn": "booleanEquals", - "argv": [ - { - "ref": "UseDualStack" - }, - true - ] - } - ], - "rules": [ - { - "conditions": [ - { - "fn": "booleanEquals", - "argv": [ - true, - { - "fn": "getAttr", - "argv": [ - { - "ref": "PartitionResult" - }, - "supportsFIPS" - ] - } - ] - }, - { - "fn": "booleanEquals", - "argv": [ - true, - { - "fn": "getAttr", - "argv": [ - { - "ref": "PartitionResult" - }, - "supportsDualStack" - ] - } - ] - } - ], - "rules": [ - { - "conditions": [], - "endpoint": { - "url": "https://api.ecr-public-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", - "properties": {}, - "headers": {} - }, - "type": "endpoint" - } - ], - "type": "tree" - }, - { - "conditions": [], - "error": "FIPS and DualStack are enabled, but this partition does not support one or both", - "type": "error" - } - ], - "type": "tree" - }, - { - "conditions": [ - { - "fn": "booleanEquals", - "argv": [ - { - "ref": "UseFIPS" - }, - true - ] - } - ], - "rules": [ - { - "conditions": [ - { - "fn": "booleanEquals", + "fn": "getAttr", "argv": [ { - "fn": "getAttr", - "argv": [ - { - "ref": "PartitionResult" - }, - "supportsFIPS" - ] + "ref": "PartitionResult" }, - true + "supportsDualStack" ] } - ], - "rules": [ - { - "conditions": [], - "endpoint": { - "url": "https://api.ecr-public-fips.{Region}.{PartitionResult#dnsSuffix}", - "properties": {}, - "headers": {} - }, - "type": "endpoint" - } - ], - "type": "tree" - }, - { - "conditions": [], - "error": "FIPS is enabled but this partition does not support FIPS", - "type": "error" - } - ], - "type": "tree" - }, - { - "conditions": [ - { - "fn": "booleanEquals", - "argv": [ - { - "ref": "UseDualStack" - }, - true ] } ], "rules": [ - { - "conditions": [ - { - "fn": "booleanEquals", - "argv": [ - true, - { - "fn": "getAttr", - "argv": [ - { - "ref": "PartitionResult" - }, - "supportsDualStack" - ] - } - ] - } - ], - "rules": [ - { - "conditions": [], - "endpoint": { - "url": "https://api.ecr-public.{Region}.{PartitionResult#dualStackDnsSuffix}", - "properties": {}, - "headers": {} - }, - "type": "endpoint" - } - ], - "type": "tree" - }, { "conditions": [], - "error": "DualStack is enabled but this partition does not support DualStack", - "type": "error" + "endpoint": { + "url": "https://ecr-public.{Region}.{PartitionResult#dualStackDnsSuffix}", + "properties": {}, + "headers": {} + }, + "type": "endpoint" } ], "type": "tree" }, { "conditions": [], - "endpoint": { - "url": "https://api.ecr-public.{Region}.{PartitionResult#dnsSuffix}", - "properties": {}, - "headers": {} - }, - "type": "endpoint" + "error": "Dualstack is enabled but this partition does not support dualstack", + "type": "error" } ], "type": "tree" + }, + { + "conditions": [], + "endpoint": { + "url": "https://api.ecr-public.{Region}.{PartitionResult#dnsSuffix}", + "properties": {}, + "headers": {} + }, + "type": "endpoint" } ], "type": "tree" - }, - { - "conditions": [], - "error": "Invalid Configuration: Missing Region", - "type": "error" } ] }, "smithy.rules#endpointTests": { "testCases": [ { - "documentation": "For region us-east-1 with FIPS enabled and DualStack enabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public-fips.us-east-1.api.aws" - } - }, - "params": { - "Region": "us-east-1", - "UseFIPS": true, - "UseDualStack": true - } - }, - { - "documentation": "For region us-east-1 with FIPS enabled and DualStack disabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public-fips.us-east-1.amazonaws.com" - } - }, - "params": { - "Region": "us-east-1", - "UseFIPS": true, - "UseDualStack": false - } - }, - { - "documentation": "For region us-east-1 with FIPS disabled and DualStack enabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public.us-east-1.api.aws" - } - }, - "params": { - "Region": "us-east-1", - "UseFIPS": false, - "UseDualStack": true - } - }, - { - "documentation": "For region us-east-1 with FIPS disabled and DualStack disabled", + "documentation": "Valid with dualstack and FIPS disabled. i.e, IPv4 Only stack with no FIPS, with special prefix", "expect": { "endpoint": { "url": "https://api.ecr-public.us-east-1.amazonaws.com" } }, - "params": { - "Region": "us-east-1", - "UseFIPS": false, - "UseDualStack": false - } - }, - { - "documentation": "For region cn-north-1 with FIPS enabled and DualStack enabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public-fips.cn-north-1.api.amazonwebservices.com.cn" - } - }, - "params": { - "Region": "cn-north-1", - "UseFIPS": true, - "UseDualStack": true - } - }, - { - "documentation": "For region cn-north-1 with FIPS enabled and DualStack disabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public-fips.cn-north-1.amazonaws.com.cn" - } - }, - "params": { - "Region": "cn-north-1", - "UseFIPS": true, - "UseDualStack": false - } - }, - { - "documentation": "For region cn-north-1 with FIPS disabled and DualStack enabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public.cn-north-1.api.amazonwebservices.com.cn" - } - }, - "params": { - "Region": "cn-north-1", - "UseFIPS": false, - "UseDualStack": true - } - }, - { - "documentation": "For region cn-north-1 with FIPS disabled and DualStack disabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public.cn-north-1.amazonaws.com.cn" - } - }, - "params": { - "Region": "cn-north-1", - "UseFIPS": false, - "UseDualStack": false - } - }, - { - "documentation": "For region us-gov-east-1 with FIPS enabled and DualStack enabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public-fips.us-gov-east-1.api.aws" - } - }, - "params": { - "Region": "us-gov-east-1", - "UseFIPS": true, - "UseDualStack": true - } - }, - { - "documentation": "For region us-gov-east-1 with FIPS enabled and DualStack disabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public-fips.us-gov-east-1.amazonaws.com" - } - }, - "params": { - "Region": "us-gov-east-1", - "UseFIPS": true, - "UseDualStack": false - } - }, - { - "documentation": "For region us-gov-east-1 with FIPS disabled and DualStack enabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public.us-gov-east-1.api.aws" - } - }, - "params": { - "Region": "us-gov-east-1", - "UseFIPS": false, - "UseDualStack": true - } - }, - { - "documentation": "For region us-gov-east-1 with FIPS disabled and DualStack disabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public.us-gov-east-1.amazonaws.com" - } - }, - "params": { - "Region": "us-gov-east-1", - "UseFIPS": false, - "UseDualStack": false - } - }, - { - "documentation": "For region us-iso-east-1 with FIPS enabled and DualStack enabled", - "expect": { - "error": "FIPS and DualStack are enabled, but this partition does not support one or both" - }, - "params": { - "Region": "us-iso-east-1", - "UseFIPS": true, - "UseDualStack": true - } - }, - { - "documentation": "For region us-iso-east-1 with FIPS enabled and DualStack disabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public-fips.us-iso-east-1.c2s.ic.gov" - } - }, - "params": { - "Region": "us-iso-east-1", - "UseFIPS": true, - "UseDualStack": false - } - }, - { - "documentation": "For region us-iso-east-1 with FIPS disabled and DualStack enabled", - "expect": { - "error": "DualStack is enabled but this partition does not support DualStack" - }, - "params": { - "Region": "us-iso-east-1", - "UseFIPS": false, - "UseDualStack": true - } - }, - { - "documentation": "For region us-iso-east-1 with FIPS disabled and DualStack disabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public.us-iso-east-1.c2s.ic.gov" - } - }, - "params": { - "Region": "us-iso-east-1", - "UseFIPS": false, - "UseDualStack": false - } - }, - { - "documentation": "For region us-isob-east-1 with FIPS enabled and DualStack enabled", - "expect": { - "error": "FIPS and DualStack are enabled, but this partition does not support one or both" - }, - "params": { - "Region": "us-isob-east-1", - "UseFIPS": true, - "UseDualStack": true - } - }, - { - "documentation": "For region us-isob-east-1 with FIPS enabled and DualStack disabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public-fips.us-isob-east-1.sc2s.sgov.gov" - } - }, - "params": { - "Region": "us-isob-east-1", - "UseFIPS": true, - "UseDualStack": false - } - }, - { - "documentation": "For region us-isob-east-1 with FIPS disabled and DualStack enabled", - "expect": { - "error": "DualStack is enabled but this partition does not support DualStack" - }, - "params": { - "Region": "us-isob-east-1", - "UseFIPS": false, - "UseDualStack": true - } - }, - { - "documentation": "For region us-isob-east-1 with FIPS disabled and DualStack disabled", - "expect": { - "endpoint": { - "url": "https://api.ecr-public.us-isob-east-1.sc2s.sgov.gov" + "operationInputs": [ + { + "builtInParams": { + "AWS::Region": "us-east-1" + }, + "operationName": "DescribeRegistries" } - }, + ], "params": { - "Region": "us-isob-east-1", + "UseDualStack": false, "UseFIPS": false, - "UseDualStack": false + "Region": "us-east-1" } }, { - "documentation": "For custom endpoint with region set and fips disabled and dualstack disabled", + "documentation": "Valid with dualstack enabled", "expect": { "endpoint": { - "url": "https://example.com" + "url": "https://ecr-public.us-east-1.api.aws" } }, "params": { - "Region": "us-east-1", + "UseDualStack": true, "UseFIPS": false, - "UseDualStack": false, - "Endpoint": "https://example.com" + "Region": "us-east-1" } }, { - "documentation": "For custom endpoint with region not set and fips disabled and dualstack disabled", + "documentation": "Invalid with FIPS set, dualstack disabled", "expect": { - "endpoint": { - "url": "https://example.com" - } + "error": "ECR Public does not support FIPS" }, "params": { - "UseFIPS": false, "UseDualStack": false, - "Endpoint": "https://example.com" + "UseFIPS": true, + "Region": "us-east-1" } }, { - "documentation": "For custom endpoint with fips enabled and dualstack disabled", + "documentation": "Invalid with both dualstack and FIPS enabled", "expect": { - "error": "Invalid Configuration: FIPS and custom endpoint are not supported" + "error": "ECR Public does not support FIPS" }, "params": { - "Region": "us-east-1", + "UseDualStack": true, "UseFIPS": true, - "UseDualStack": false, - "Endpoint": "https://example.com" + "Region": "us-east-1" } }, { - "documentation": "For custom endpoint with fips disabled and dualstack enabled", + "documentation": "Invalid with DualStack enabled and partition does not support Dualstack", "expect": { - "error": "Invalid Configuration: Dualstack and custom endpoint are not supported" + "error": "Dualstack is enabled but this partition does not support dualstack" }, "params": { - "Region": "us-east-1", - "UseFIPS": false, "UseDualStack": true, - "Endpoint": "https://example.com" - } - }, - { - "documentation": "Missing region", - "expect": { - "error": "Invalid Configuration: Missing Region" + "Region": "us-isob-east-1" } } ],