github.com/gravitational/teleport/api@v0.0.0-20240507183017-3110591cbafc/utils/aws/partition.go (about) 1 /* 2 Copyright 2022 Gravitational, Inc. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package aws 18 19 // GetPartitionFromRegion get aws partition from region 20 // example, region "us-east-1" corresponds to partition "aws" 21 // region "cn-north-1" corresponds to partition "aws-cn" 22 func GetPartitionFromRegion(region string) string { 23 var partition string 24 switch { 25 case IsCNRegion(region): 26 partition = CNPartition 27 case IsUSGovRegion(region): 28 partition = USGovPartition 29 default: 30 partition = StandardPartition 31 } 32 return partition 33 } 34 35 const ( 36 // StandardPartition is the partition ID of the AWS Standard partition. 37 StandardPartition = "aws" 38 39 // CNPartition is the partition ID of the AWS China partition. 40 CNPartition = "aws-cn" 41 42 // USGovPartition is the partition ID of the AWS GovCloud partition. 43 USGovPartition = "aws-us-gov" 44 )