Skip to content

Commit 26005ea

Browse files
pvitalGSVarsha
authored andcommitted
style: format build_and_publish_lambda_layer.py
Used ruff (vscode) to: - Black-compatible code formatting. - fix all auto-fixable violations, like unused imports. - isort-compatible import sorting. Signed-off-by: Paulo Vital <[email protected]>
1 parent 55062fb commit 26005ea

File tree

1 file changed

+85
-45
lines changed

1 file changed

+85
-45
lines changed

bin/aws-lambda/build_and_publish_lambda_layer.py

Lines changed: 85 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# (c) Copyright IBM Corp. 2021
44
# (c) Copyright Instana Inc. 2020
55

6-
import os
7-
import sys
86
import json
7+
import os
98
import shutil
9+
import sys
1010
import time
11-
from subprocess import call, check_call, check_output, CalledProcessError, DEVNULL
11+
from subprocess import DEVNULL, CalledProcessError, call, check_call, check_output
1212

1313
for profile in ("china", "non-china"):
1414
try:
@@ -60,7 +60,18 @@
6060
os.makedirs(build_directory, exist_ok=True)
6161

6262
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+
)
6475

6576
print("===> Manually copying in local dev code")
6677
shutil.rmtree(build_directory + "/instana")
@@ -71,7 +82,20 @@
7182
zip_filename = f"instana-py-layer-{timestamp}.zip"
7283

7384
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+
)
7599

76100
fq_zip_filename = os.getcwd() + "/" + zip_filename
77101
aws_zip_filename = f"fileb://{fq_zip_filename}"
@@ -87,39 +111,39 @@
87111
LAYER_NAME = "instana-py-dev"
88112
else:
89113
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",
123147
]
124148
LAYER_NAME = "instana-python"
125149

@@ -164,13 +188,29 @@
164188

165189
if dev_mode is False:
166190
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+
)
174214

175215
published[region] = json_data["LayerVersionArn"]
176216

0 commit comments

Comments
 (0)