|
3 | 3 | # (c) Copyright IBM Corp. 2021 |
4 | 4 | # (c) Copyright Instana Inc. 2020 |
5 | 5 |
|
6 | | -import os |
7 | | -import sys |
8 | 6 | import json |
| 7 | +import os |
9 | 8 | import shutil |
| 9 | +import sys |
10 | 10 | import time |
11 | | -from subprocess import call, check_call, check_output, CalledProcessError, DEVNULL |
| 11 | +from subprocess import DEVNULL, CalledProcessError, call, check_call, check_output |
12 | 12 |
|
13 | 13 | for profile in ("china", "non-china"): |
14 | 14 | try: |
|
60 | 60 | os.makedirs(build_directory, exist_ok=True) |
61 | 61 |
|
62 | 62 | print("===> Installing Instana and dependencies into build directory") |
63 | | -call(["pip", "install", "-q", "-U", "-t", os.getcwd() + "/build/lambda/python", "instana"], env=local_env) |
| 63 | +call( |
| 64 | + [ |
| 65 | + "pip", |
| 66 | + "install", |
| 67 | + "-q", |
| 68 | + "-U", |
| 69 | + "-t", |
| 70 | + os.getcwd() + "/build/lambda/python", |
| 71 | + "instana", |
| 72 | + ], |
| 73 | + env=local_env, |
| 74 | +) |
64 | 75 |
|
65 | 76 | print("===> Manually copying in local dev code") |
66 | 77 | shutil.rmtree(build_directory + "/instana") |
|
71 | 82 | zip_filename = f"instana-py-layer-{timestamp}.zip" |
72 | 83 |
|
73 | 84 | os.chdir(os.getcwd() + "/build/lambda/") |
74 | | -call(["zip", "-q", "-r", zip_filename, "./python", "-x", "*.pyc", "./python/pip*", "./python/setuptools*", "./python/wheel*"]) |
| 85 | +call( |
| 86 | + [ |
| 87 | + "zip", |
| 88 | + "-q", |
| 89 | + "-r", |
| 90 | + zip_filename, |
| 91 | + "./python", |
| 92 | + "-x", |
| 93 | + "*.pyc", |
| 94 | + "./python/pip*", |
| 95 | + "./python/setuptools*", |
| 96 | + "./python/wheel*", |
| 97 | + ] |
| 98 | +) |
75 | 99 |
|
76 | 100 | fq_zip_filename = os.getcwd() + "/" + zip_filename |
77 | 101 | aws_zip_filename = f"fileb://{fq_zip_filename}" |
|
87 | 111 | LAYER_NAME = "instana-py-dev" |
88 | 112 | else: |
89 | 113 | target_regions = [ |
90 | | - 'af-south-1', |
91 | | - 'ap-east-1', |
92 | | - 'ap-northeast-1', |
93 | | - 'ap-northeast-2', |
94 | | - 'ap-northeast-3', |
95 | | - 'ap-south-1', |
96 | | - 'ap-south-2', |
97 | | - 'ap-southeast-1', |
98 | | - 'ap-southeast-2', |
99 | | - 'ap-southeast-3', |
100 | | - 'ap-southeast-4', |
101 | | - 'ap-southeast-5', |
102 | | - 'ap-southeast-7', |
103 | | - 'ca-central-1', |
104 | | - 'ca-west-1', |
105 | | - 'cn-north-1', |
106 | | - 'cn-northwest-1', |
107 | | - 'eu-central-1', |
108 | | - 'eu-central-2', |
109 | | - 'eu-north-1', |
110 | | - 'eu-south-1', |
111 | | - 'eu-south-2', |
112 | | - 'eu-west-1', |
113 | | - 'eu-west-2', |
114 | | - 'eu-west-3', |
115 | | - 'il-central-1', |
116 | | - 'me-central-1', |
117 | | - 'me-south-1', |
118 | | - 'sa-east-1', |
119 | | - 'us-east-1', |
120 | | - 'us-east-2', |
121 | | - 'us-west-1', |
122 | | - 'us-west-2' |
| 114 | + "af-south-1", |
| 115 | + "ap-east-1", |
| 116 | + "ap-northeast-1", |
| 117 | + "ap-northeast-2", |
| 118 | + "ap-northeast-3", |
| 119 | + "ap-south-1", |
| 120 | + "ap-south-2", |
| 121 | + "ap-southeast-1", |
| 122 | + "ap-southeast-2", |
| 123 | + "ap-southeast-3", |
| 124 | + "ap-southeast-4", |
| 125 | + "ap-southeast-5", |
| 126 | + "ap-southeast-7", |
| 127 | + "ca-central-1", |
| 128 | + "ca-west-1", |
| 129 | + "cn-north-1", |
| 130 | + "cn-northwest-1", |
| 131 | + "eu-central-1", |
| 132 | + "eu-central-2", |
| 133 | + "eu-north-1", |
| 134 | + "eu-south-1", |
| 135 | + "eu-south-2", |
| 136 | + "eu-west-1", |
| 137 | + "eu-west-2", |
| 138 | + "eu-west-3", |
| 139 | + "il-central-1", |
| 140 | + "me-central-1", |
| 141 | + "me-south-1", |
| 142 | + "sa-east-1", |
| 143 | + "us-east-1", |
| 144 | + "us-east-2", |
| 145 | + "us-west-1", |
| 146 | + "us-west-2", |
123 | 147 | ] |
124 | 148 | LAYER_NAME = "instana-python" |
125 | 149 |
|
|
164 | 188 |
|
165 | 189 | if dev_mode is False: |
166 | 190 | print("===> Making layer public...") |
167 | | - response = check_output(["aws", "--region", region, "lambda", "add-layer-version-permission", |
168 | | - "--layer-name", LAYER_NAME, "--version-number", str(version), |
169 | | - "--statement-id", "public-permission-all-accounts", |
170 | | - "--principal", "*", |
171 | | - "--action", "lambda:GetLayerVersion", |
172 | | - "--output", "text", |
173 | | - "--profile", profile]) |
| 191 | + response = check_output( |
| 192 | + [ |
| 193 | + "aws", |
| 194 | + "--region", |
| 195 | + region, |
| 196 | + "lambda", |
| 197 | + "add-layer-version-permission", |
| 198 | + "--layer-name", |
| 199 | + LAYER_NAME, |
| 200 | + "--version-number", |
| 201 | + str(version), |
| 202 | + "--statement-id", |
| 203 | + "public-permission-all-accounts", |
| 204 | + "--principal", |
| 205 | + "*", |
| 206 | + "--action", |
| 207 | + "lambda:GetLayerVersion", |
| 208 | + "--output", |
| 209 | + "text", |
| 210 | + "--profile", |
| 211 | + profile, |
| 212 | + ] |
| 213 | + ) |
174 | 214 |
|
175 | 215 | published[region] = json_data["LayerVersionArn"] |
176 | 216 |
|
|
0 commit comments