-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathAWSRegion.swift
116 lines (102 loc) · 4.8 KB
/
AWSRegion.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftAWSLambdaRuntime open source project
//
// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
// list all available regions using aws cli:
// $ aws ssm get-parameters-by-path --path /aws/service/global-infrastructure/services/lambda/regions --output json
/// Enumeration of the AWS Regions.
public struct AWSRegion: RawRepresentable, Equatable, Sendable {
public typealias RawValue = String
public let rawValue: String
public init?(rawValue: String) {
self.rawValue = rawValue
}
static let all: [AWSRegion] = [
Self.af_south_1,
Self.ap_northeast_1,
Self.ap_northeast_2,
Self.ap_northeast_3,
Self.ap_east_1,
Self.ap_southeast_1,
Self.ap_southeast_2,
Self.ap_southeast_3,
Self.ap_southeast_4,
Self.ap_south_1,
Self.ap_south_2,
Self.cn_north_1,
Self.cn_northwest_1,
Self.eu_north_1,
Self.eu_south_1,
Self.eu_south_2,
Self.eu_west_1,
Self.eu_west_2,
Self.eu_west_3,
Self.eu_central_1,
Self.eu_central_2,
Self.us_east_1,
Self.us_east_2,
Self.us_west_1,
Self.us_west_2,
Self.us_gov_east_1,
Self.us_gov_west_1,
Self.ca_central_1,
Self.ca_west_1,
Self.sa_east_1,
Self.me_central_1,
Self.me_south_1,
Self.il_central_1,
]
public static var af_south_1: Self { AWSRegion(rawValue: "af-south-1")! }
public static var ap_northeast_1: Self { AWSRegion(rawValue: "ap-northeast-1")! }
public static var ap_northeast_2: Self { AWSRegion(rawValue: "ap-northeast-2")! }
public static var ap_northeast_3: Self { AWSRegion(rawValue: "ap-northeast-3")! }
public static var ap_east_1: Self { AWSRegion(rawValue: "ap-east-1")! }
public static var ap_southeast_1: Self { AWSRegion(rawValue: "ap-southeast-1")! }
public static var ap_southeast_2: Self { AWSRegion(rawValue: "ap-southeast-2")! }
public static var ap_southeast_3: Self { AWSRegion(rawValue: "ap-southeast-3")! }
public static var ap_southeast_4: Self { AWSRegion(rawValue: "ap-southeast-4")! }
public static var ap_south_1: Self { AWSRegion(rawValue: "ap-south-1")! }
public static var ap_south_2: Self { AWSRegion(rawValue: "ap-south-2")! }
public static var cn_north_1: Self { AWSRegion(rawValue: "cn-north-1")! }
public static var cn_northwest_1: Self { AWSRegion(rawValue: "cn-northwest-1")! }
public static var eu_north_1: Self { AWSRegion(rawValue: "eu-north-1")! }
public static var eu_south_1: Self { AWSRegion(rawValue: "eu-south-1")! }
public static var eu_south_2: Self { AWSRegion(rawValue: "eu-south-2")! }
public static var eu_west_1: Self { AWSRegion(rawValue: "eu-west-1")! }
public static var eu_west_2: Self { AWSRegion(rawValue: "eu-west-2")! }
public static var eu_west_3: Self { AWSRegion(rawValue: "eu-west-3")! }
public static var eu_central_1: Self { AWSRegion(rawValue: "eu-central-1")! }
public static var eu_central_2: Self { AWSRegion(rawValue: "eu-central-2")! }
public static var us_east_1: Self { AWSRegion(rawValue: "us-east-1")! }
public static var us_east_2: Self { AWSRegion(rawValue: "us-east-2")! }
public static var us_west_1: Self { AWSRegion(rawValue: "us-west-1")! }
public static var us_west_2: Self { AWSRegion(rawValue: "us-west-2")! }
public static var us_gov_east_1: Self { AWSRegion(rawValue: "us-gov-east-1")! }
public static var us_gov_west_1: Self { AWSRegion(rawValue: "us-gov-west-1")! }
public static var ca_central_1: Self { AWSRegion(rawValue: "ca-central-1")! }
public static var ca_west_1: Self { AWSRegion(rawValue: "ca-west-1")! }
public static var sa_east_1: Self { AWSRegion(rawValue: "sa-east-1")! }
public static var me_central_1: Self { AWSRegion(rawValue: "me-central-1")! }
public static var me_south_1: Self { AWSRegion(rawValue: "me-south-1")! }
public static var il_central_1: Self { AWSRegion(rawValue: "il-central-1")! }
}
extension AWSRegion: Codable {
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let region = try container.decode(String.self)
self.init(rawValue: region)!
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(self.rawValue)
}
}