|
1 | 1 | #!/usr/bin/env python |
2 | 2 |
|
3 | 3 | import os |
| 4 | +import sys |
4 | 5 | import json |
5 | 6 | import shutil |
6 | 7 | import time |
7 | 8 | import distutils.spawn |
8 | 9 | from subprocess import call, check_output |
9 | 10 |
|
| 11 | +# Either -dev or -prod must be specified (and nothing else) |
| 12 | +if len(sys.argv) != 2 or (('-dev' not in sys.argv) and ('-prod' not in sys.argv)): |
| 13 | + raise ValueError('Please specify -dev or -prod to indicate which type of layer to build.') |
| 14 | + |
| 15 | +dev_mode = '-dev' in sys.argv |
| 16 | + |
10 | 17 | # Disable aws CLI pagination |
11 | 18 | os.environ["AWS_PAGER"] = "" |
12 | 19 |
|
|
57 | 64 | aws_zip_filename = "fileb://%s" % fq_zip_filename |
58 | 65 | print("Zipfile should be at: ", fq_zip_filename) |
59 | 66 |
|
60 | | -regions = ['ap-northeast-1', 'ap-northeast-2', 'ap-south-1', 'ap-southeast-1', 'ap-southeast-2', 'ca-central-1', |
61 | | - 'eu-central-1', 'eu-north-1', 'eu-west-1', 'eu-west-2', 'eu-west-3', 'sa-east-1', 'us-east-1', |
62 | | - 'us-east-2', 'us-west-1', 'us-west-2'] |
63 | | - |
64 | | -# regions = ['us-west-1'] |
65 | | - |
66 | | -# LAYER_NAME = "instana-py-test" |
67 | | -LAYER_NAME = "instana-python" |
| 67 | +if dev_mode: |
| 68 | + regions = ['us-west-1'] |
| 69 | + LAYER_NAME = "instana-py-dev" |
| 70 | +else: |
| 71 | + regions = ['ap-northeast-1', 'ap-northeast-2', 'ap-south-1', 'ap-southeast-1', 'ap-southeast-2', 'ca-central-1', |
| 72 | + 'eu-central-1', 'eu-north-1', 'eu-west-1', 'eu-west-2', 'eu-west-3', 'sa-east-1', 'us-east-1', |
| 73 | + 'us-east-2', 'us-west-1', 'us-west-2'] |
| 74 | + LAYER_NAME = "instana-python" |
68 | 75 |
|
69 | 76 | published = dict() |
70 | 77 |
|
|
81 | 88 | version = json_data['Version'] |
82 | 89 | print("===> Uploaded version is %s" % version) |
83 | 90 |
|
84 | | - print("===> Making layer public...") |
85 | | - response = check_output(["aws", "--region", region, "lambda", "add-layer-version-permission", |
86 | | - "--layer-name", LAYER_NAME, "--version-number", str(version), |
87 | | - "--statement-id", "public-permission-all-accounts", |
88 | | - "--principal", "*", |
89 | | - "--action", "lambda:GetLayerVersion", |
90 | | - "--output", "text"]) |
| 91 | + if dev_mode is False: |
| 92 | + print("===> Making layer public...") |
| 93 | + response = check_output(["aws", "--region", region, "lambda", "add-layer-version-permission", |
| 94 | + "--layer-name", LAYER_NAME, "--version-number", str(version), |
| 95 | + "--statement-id", "public-permission-all-accounts", |
| 96 | + "--principal", "*", |
| 97 | + "--action", "lambda:GetLayerVersion", |
| 98 | + "--output", "text"]) |
91 | 99 |
|
92 | 100 | published[region] = json_data['LayerVersionArn'] |
93 | 101 |
|
|
0 commit comments