Skip to content

Commit e96bf6b

Browse files
committed
chore: make regions more maintainable
Signed-off-by: Arjun Rajappa <Arjun.Rajappa@ibm.com>
1 parent f6cddbc commit e96bf6b

4 files changed

Lines changed: 43 additions & 77 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cn-north-1
2+
cn-northwest-1
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
af-south-1
2+
ap-east-1
3+
ap-east-2
4+
ap-northeast-1
5+
ap-northeast-2
6+
ap-northeast-3
7+
ap-south-1
8+
ap-south-2
9+
ap-southeast-1
10+
ap-southeast-2
11+
ap-southeast-3
12+
ap-southeast-4
13+
ap-southeast-5
14+
ap-southeast-7
15+
ca-central-1
16+
ca-west-1
17+
eu-central-1
18+
eu-central-2
19+
eu-north-1
20+
eu-south-1
21+
eu-south-2
22+
eu-west-1
23+
eu-west-2
24+
eu-west-3
25+
il-central-1
26+
me-central-1
27+
me-south-1
28+
sa-east-1
29+
us-east-1
30+
us-east-2
31+
us-west-1
32+
us-west-2

bin/aws-lambda/create_lambda_release_gh.rb

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
require 'json'
99
require 'open3'
1010

11+
CHINA_REGIONS = File.readlines(File.join(File.dirname(__FILE__), 'aws-regions/cn-regions.txt')).map(&:chomp)
12+
OTHER_REGIONS = File.readlines(File.join(File.dirname(__FILE__), 'aws-regions/other_regions.txt')).map(&:chomp)
13+
1114
if ARGV.length != 1
1215
raise ArgumentError, 'Please specify the layer version to release. e.g. "1"'
1316
end
@@ -30,40 +33,7 @@
3033
end
3134
end
3235

33-
regions = %w[
34-
af-south-1
35-
ap-east-1
36-
ap-northeast-1
37-
ap-northeast-2
38-
ap-northeast-3
39-
ap-south-1
40-
ap-south-2
41-
ap-southeast-1
42-
ap-southeast-2
43-
ap-southeast-3
44-
ap-southeast-4
45-
ca-central-1
46-
ca-west-1
47-
cn-north-1
48-
cn-northwest-1
49-
eu-central-1
50-
eu-central-2
51-
eu-north-1
52-
eu-south-1
53-
eu-south-2
54-
eu-west-1
55-
eu-west-2
56-
eu-west-3
57-
il-central-1
58-
me-central-1
59-
me-south-1
60-
sa-east-1
61-
us-east-1
62-
us-east-2
63-
us-west-1
64-
us-west-2
65-
]
66-
36+
regions = CHINA_REGIONS + OTHER_REGIONS
6737
version = ARGV[0]
6838
semantic_version = "v#{version}"
6939
title = "AWS Lambda Layer #{semantic_version}"
@@ -83,7 +53,7 @@
8353

8454
if status.success?
8555
json_data = JSON.parse(stdout)
86-
puts "If there weren't any failures, the release is available at:"
56+
puts "The release is available at:"
8757
puts json_data["html_url"]
8858
else
8959
puts "Error creating release: #{stderr}"

bin/aws-lambda/publish_lambda_layer.rb

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
require 'time'
88
require 'aws-sdk-lambda'
99

10+
CHINA_REGIONS = File.readlines(File.join(File.dirname(__FILE__), 'aws-regions/cn-regions.txt')).map(&:chomp)
11+
OTHER_REGIONS = File.readlines(File.join(File.dirname(__FILE__), 'aws-regions/other_regions.txt')).map(&:chomp)
1012
# Check AWS profiles
1113
["china", "non-china"].each do |profile|
1214
# Test if we can initialize a client with this profile
@@ -31,51 +33,11 @@
3133

3234
zip_filename = "layer"
3335

34-
cn_regions = [
35-
"cn-north-1",
36-
"cn-northwest-1"
37-
]
38-
3936
if dev_mode
4037
target_regions = ["us-east-1"]
4138
layer_name_prefix = "instana-ruby-dev"
4239
else
43-
target_regions = %w[
44-
af-south-1
45-
ap-east-1
46-
ap-east-2
47-
ap-northeast-1
48-
ap-northeast-2
49-
ap-northeast-3
50-
ap-south-1
51-
ap-south-2
52-
ap-southeast-1
53-
ap-southeast-2
54-
ap-southeast-3
55-
ap-southeast-4
56-
ap-southeast-5
57-
ap-southeast-7
58-
ca-central-1
59-
ca-west-1
60-
cn-north-1
61-
cn-northwest-1
62-
eu-central-1
63-
eu-central-2
64-
eu-north-1
65-
eu-south-1
66-
eu-south-2
67-
eu-west-1
68-
eu-west-2
69-
eu-west-3
70-
il-central-1
71-
me-central-1
72-
me-south-1
73-
sa-east-1
74-
us-east-1
75-
us-east-2
76-
us-west-1
77-
us-west-2
78-
]
40+
target_regions = CHINA_REGIONS + OTHER_REGIONS
7941
layer_name_prefix = "instana-ruby"
8042
end
8143

@@ -86,7 +48,7 @@
8648
regional_publish = {}
8749
target_regions.each do |region| # rubocop:disable Metrics/BlockLength
8850
puts "===> Uploading layer for Ruby to AWS #{region}"
89-
profile = cn_regions.include?(region) ? "china" : "non-china"
51+
profile = CHINA_REGIONS.include?(region) ? "china" : "non-china"
9052

9153
# Initialize AWS Lambda client for this region and profile
9254
lambda_client = Aws::Lambda::Client.new(

0 commit comments

Comments
 (0)