mirror of
https://github.com/gravitational/teleport.git
synced 2026-11-02 06:08:23 +08:00
Co-authored-by: waylen <waylen.guo@gmail.com> Co-authored-by: Jianghui Guo <89057156+waylenguo@users.noreply.github.com> Co-authored-by: STeve (Xin) Huang <huangin52@gmail.com>
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
/*
|
|
Copyright 2022 Gravitational, Inc.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package aws
|
|
|
|
// GetPartitionFromRegion get aws partition from region
|
|
// example, region "us-east-1" corresponds to partition "aws"
|
|
// region "cn-north-1" corresponds to partition "aws-cn"
|
|
func GetPartitionFromRegion(region string) string {
|
|
var partition string
|
|
switch {
|
|
case IsCNRegion(region):
|
|
partition = CNPartition
|
|
case IsUSGovRegion(region):
|
|
partition = USGovPartition
|
|
default:
|
|
partition = StandardPartition
|
|
}
|
|
return partition
|
|
}
|
|
|
|
const (
|
|
// StandardPartition is the partition ID of the AWS Standard partition.
|
|
StandardPartition = "aws"
|
|
|
|
// CNPartition is the partition ID of the AWS China partition.
|
|
CNPartition = "aws-cn"
|
|
|
|
// USGovPartition is the partition ID of the AWS GovCloud partition.
|
|
USGovPartition = "aws-us-gov"
|
|
)
|