localstack 4.13.2.dev36__py3-none-any.whl → 4.14.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: localstack
3
- Version: 4.13.2.dev36
3
+ Version: 4.14.0
4
4
  Summary: The LocalStack Command Line Interface
5
5
  Author-email: LocalStack Contributors <info@localstack.cloud>
6
6
  License-Expression: Apache-2.0
@@ -1,7 +1,7 @@
1
1
  localstack_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  localstack_cli/config.py,sha256=kjt-tEH5TG3EPtHReLr23DzAw5XI_hZF5d8GEzCfuns,67164
3
3
  localstack_cli/constants.py,sha256=Z65z7evTRQGRf1buYMMvLwKZOI0XfzlUsNmeUGcONzQ,6304
4
- localstack_cli/version.py,sha256=_k0PeE2hOTa9Js-fKU0W3zMv3bsPCnUfZpmlsqzwa5Q,721
4
+ localstack_cli/version.py,sha256=HK99J01s1g57btZFIWMu5zC8IUJbQB-DbpgMyQ_kkgE,706
5
5
  localstack_cli/cli/__init__.py,sha256=S0u4eNluwhhLkiCC8UZNjhh27Pk-W7jeUiEv4k3VrXo,176
6
6
  localstack_cli/cli/console.py,sha256=eMz2PfQRDG493uzXFqQZTbYTC4NhO6UOpx4ZricsGLI,346
7
7
  localstack_cli/cli/core_plugin.py,sha256=bVbkbhIOegsfQvD3BF_T477K6v6yjK0lRn4eE5PpnSI,382
@@ -53,12 +53,14 @@ localstack_cli/pro/core/cli/extensions.py,sha256=8TBDd02J1VnUag-x7ppVxC9N0tgMP0O
53
53
  localstack_cli/pro/core/cli/iam.py,sha256=iTRztn5Q01Q1kpcAE1RUyJWAuHe2iRK5mUO2JnOGjjw,6352
54
54
  localstack_cli/pro/core/cli/license.py,sha256=kdtATn3j6HnpzUpj48ozKj0IRbbYCdVTG1FJgdZ9y8Q,2780
55
55
  localstack_cli/pro/core/cli/localstack.py,sha256=Z3_7W7UgUGoNgh3m9NS6JjX9nFU1o9O8LbmV17S1Hu0,3620
56
- localstack_cli/pro/core/cli/replicator.py,sha256=sreAt9hSSDyAHj2wLM2EYClVTLK97pWybAiAu4_veuA,11189
56
+ localstack_cli/pro/core/cli/replicator.py,sha256=GKA-PqluhaJzcu9sTGf4cbnqN-rfh4GXZx3o1mnGhPE,12824
57
57
  localstack_cli/pro/core/cli/state.py,sha256=iS8_qSqoxUlQj21nrVToazqjfM7PfBs-3RqoiwpIKn0,6696
58
58
  localstack_cli/pro/core/cli/tree_view.py,sha256=K443WkwIxNRDi_rzPiQW5wBTq3dCgzfTiGbVNpeIJ68,7254
59
59
  localstack_cli/runtime/__init__.py,sha256=sdfCHRYcw9uvUZsUNzRPh1vEh9kx8w1v1wgOORYnfZs,231
60
60
  localstack_cli/runtime/exceptions.py,sha256=qDUqgzcBIxKP8ts0MlGJXskK5w1QWnOyuuZu1yUPzjM,228
61
- localstack_cli/runtime/hooks.py,sha256=GuTjeBpEGa1RO1NKT37XxIopt4yFgLAmZb8Oe4PdiFk,2280
61
+ localstack_cli/runtime/hooks.py,sha256=peE2r7BtbVNiiI_YcrDzVZm7CnzVER_EybcZsv0HBh8,2288
62
+ localstack_cli/testing/__init__.py,sha256=2Bk9bgTCK00hAmxbIuHCt7x50RRB9q_ciciIwCpPfGQ,48
63
+ localstack_cli/testing/config.py,sha256=xDm8m4iizy3C2bhZ9Ls-XV9RQcDhHW-33f8Yimj6GEM,151
62
64
  localstack_cli/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
65
  localstack_cli/utils/archives.py,sha256=JHiMWmVhxxEruylj1LoUwJdruQmGbLPNORPTlTFBwek,9825
64
66
  localstack_cli/utils/batching.py,sha256=pPRrbb9Ty5pHUMQHjS0tagIxBMPVUdzDaZz-iZPk8Is,8636
@@ -103,8 +105,8 @@ localstack_cli/utils/container_utils/docker_cmd_client.py,sha256=4UPKOZTyu2TgPlE
103
105
  localstack_cli/utils/container_utils/docker_sdk_client.py,sha256=6lnBhjT03otVGBm15WDq3LAfZnxLc4Q1lyjHAyFHsbM,40460
104
106
  localstack_cli/utils/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
105
107
  localstack_cli/utils/server/tcp_proxy.py,sha256=0ehOD5muo2cBCg0boXzKhzF14KfwlJ7VUtM5i8X7M5A,4006
106
- localstack-4.13.2.dev36.dist-info/METADATA,sha256=ihio85lcuNhBMiyPB4heEWvJ0GkZ6-O4_Yc1_eMt2GQ,2709
107
- localstack-4.13.2.dev36.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
108
- localstack-4.13.2.dev36.dist-info/entry_points.txt,sha256=imiZvRSv761-PoZ0ztDCfKYL2gP7lHdlVunrm21wx_k,925
109
- localstack-4.13.2.dev36.dist-info/top_level.txt,sha256=02blzxjv7TnyriE5gkWIM_UqKTSBiCFPgRG5ZBO5R0Y,15
110
- localstack-4.13.2.dev36.dist-info/RECORD,,
108
+ localstack-4.14.0.dist-info/METADATA,sha256=-P-9fsQsX_XqJl2dG7JbKvz3T-XvpQE2CpE-8xeMLS0,2703
109
+ localstack-4.14.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
110
+ localstack-4.14.0.dist-info/entry_points.txt,sha256=ogxbxjXC9xK1eksf9CUvOEl09SY2qpUt19SVya0WYAY,933
111
+ localstack-4.14.0.dist-info/top_level.txt,sha256=02blzxjv7TnyriE5gkWIM_UqKTSBiCFPgRG5ZBO5R0Y,15
112
+ localstack-4.14.0.dist-info/RECORD,,
@@ -1,12 +1,12 @@
1
1
  [console_scripts]
2
2
  localstack = localstack_cli.cli.main:main
3
3
 
4
- [localstack.hooks.configure_localstack_container]
4
+ [localstack_cli.hooks.configure_localstack_container]
5
5
  configure_extensions_dev_container = localstack_cli.pro.core.plugins:configure_extensions_dev_container
6
6
  configure_pro_container = localstack_cli.pro.core.plugins:configure_pro_container
7
7
  set_analytics_header = localstack_cli.utils.analytics.metadata:set_analytics_header
8
8
 
9
- [localstack.hooks.prepare_host]
9
+ [localstack_cli.hooks.prepare_host]
10
10
  activate_pro_key_on_host = localstack_cli.pro.core.plugins:activate_pro_key_on_host
11
11
  configure_extensions_dev_host = localstack_cli.pro.core.plugins:configure_extensions_dev_host
12
12
  patch_community_pro_detection = localstack_cli.pro.core.plugins:patch_community_pro_detection
@@ -1,5 +1,6 @@
1
1
  import json
2
2
  import os
3
+ import re
3
4
  import subprocess as sp
4
5
  import sys
5
6
  import time
@@ -40,6 +41,10 @@ The replicator command group allows you to replicate AWS resources into LocalSta
40
41
  )
41
42
 
42
43
 
44
+ def run_check_output(cmd) -> str:
45
+ return sp.check_output(cmd, stderr=sp.PIPE, env=os.environ).decode("utf-8").strip()
46
+
47
+
43
48
  class ProfileLoadError(RuntimeError):
44
49
  def __init__(self, profile_name: str):
45
50
  super().__init__(f"Could not find profile '{profile_name}'")
@@ -96,49 +101,58 @@ def get_awscli_config() -> AWSConfig | None:
96
101
  try:
97
102
  # get credentials values
98
103
  cmd = ["aws", "configure", "export-credentials"]
99
- output = sp.check_output(cmd, stderr=sp.PIPE)
100
- credentials = json.loads(output.decode("utf8"))
104
+ credentials = json.loads(run_check_output(cmd))
101
105
  except sp.CalledProcessError as exc:
102
106
  if b"AWS CLI version 2" in exc.stderr:
103
107
  print(
104
108
  "Warning: awscli v1 installed. Please use v2 for auto detection of credentials",
105
109
  file=sys.stderr,
106
110
  )
107
- return None
111
+ return None
108
112
 
109
113
  try:
110
114
  # try to get the endpoint url
111
115
  cmd = ["aws", "configure", "get", "endpoint_url"]
112
- endpoint_url = sp.check_output(cmd, stderr=sp.PIPE).decode("utf8")
116
+ endpoint_url = run_check_output(cmd)
113
117
  except sp.CalledProcessError:
114
118
  # If there are no endpoint configured an exception is raised we do a last
115
119
  # check in the environment to find the endpoint url
116
120
  endpoint_url = os.getenv("AWS_ENDPOINT_URL")
117
121
 
118
122
  try:
119
- # get default region
120
- cmd = ["aws", "configure", "list"]
121
- output = sp.check_output(cmd, stderr=sp.PIPE)
122
- for line in output.decode().splitlines():
123
- if "region" not in line:
124
- continue
125
-
126
- words = line.split()
127
- try:
128
- region = words[1]
129
- return AWSConfig(
130
- aws_access_key_id=credentials["AccessKeyId"],
131
- aws_secret_access_key=credentials["SecretAccessKey"],
132
- aws_session_token=credentials.get("SessionToken"),
133
- region_name=region,
134
- endpoint_url=endpoint_url,
135
- )
136
-
137
- except IndexError:
138
- return None
139
-
140
- except (sp.CalledProcessError, FileNotFoundError):
141
- return None
123
+ # try to get the region from configure
124
+ cmd = ["aws", "configure", "get", "region"]
125
+ region_name = run_check_output(cmd)
126
+ except sp.CalledProcessError:
127
+ # If there are no default configured an exception is raised we do a last
128
+ # check in the environment to find the region
129
+ region_name = os.getenv("AWS_DEFAULT_REGION")
130
+
131
+ if not region_name:
132
+ try:
133
+ # older awscli versions do not return the region to the command `aws configure get region`.
134
+ # We need to rely on the configure list in this case
135
+ cmd = ["aws", "configure", "list"]
136
+ for line in run_check_output(cmd).splitlines():
137
+ if "region" not in line:
138
+ continue
139
+ # aws changed the format of configure and added `:` in delimiters
140
+ words = re.split(r"[:\s]+", line)
141
+ try:
142
+ region_name = words[1]
143
+ break
144
+ except IndexError:
145
+ return None
146
+ except (sp.CalledProcessError, FileNotFoundError):
147
+ return None
148
+
149
+ return AWSConfig(
150
+ aws_access_key_id=credentials["AccessKeyId"],
151
+ aws_secret_access_key=credentials["SecretAccessKey"],
152
+ aws_session_token=credentials.get("SessionToken"),
153
+ region_name=region_name,
154
+ endpoint_url=endpoint_url,
155
+ )
142
156
 
143
157
 
144
158
  def get_source_config(profile_dir: Path | None = None) -> AWSConfig:
@@ -148,13 +162,36 @@ def get_source_config(profile_dir: Path | None = None) -> AWSConfig:
148
162
  return awscli_source_config
149
163
 
150
164
  source_config = get_aws_env_config("AWS")
165
+ profile_name = source_config.get("profile_name")
166
+
167
+ if source_config.get("aws_access_key_id") and not source_config.get("aws_secret_access_key"):
168
+ raise CLIError(
169
+ "Unable to retrieve credentials: Partial credentials found in env."
170
+ " Need both 'AWS_ACCESS_KEY_ID' and 'AWS_SECRET_ACCESS_KEY'"
171
+ )
172
+
173
+ if profile_name:
174
+ config_file_source_config = get_config_from_profile(
175
+ profile_name=profile_name, profile_dir=profile_dir
176
+ )
177
+ if source_config.get("aws_secret_access_key"):
178
+ # before merging, if the secret access key is in the env vars we need to ensure the session token from the
179
+ # config file isn't carried along
180
+ config_file_source_config.pop("aws_session_token", None)
181
+ config_file_source_config.update(source_config)
182
+ source_config = config_file_source_config
183
+
184
+ errors = []
151
185
 
152
186
  if not source_config.get("region_name"):
153
- raise CLIError("'AWS_DEFAULT_REGION' must bet set in environment.")
187
+ errors.append("'AWS_DEFAULT_REGION' must bet set in environment or in profile.")
154
188
  if not source_config.get("aws_access_key_id"):
155
- raise CLIError("'AWS_ACCESS_KEY_ID' must bet set in environment.")
189
+ errors.append("'AWS_ACCESS_KEY_ID' must bet set in environment or in profile.")
156
190
  if not source_config.get("aws_secret_access_key"):
157
- raise CLIError("'AWS_SECRET_ACCESS_KEY' must bet set in environment.")
191
+ errors.append("'AWS_SECRET_ACCESS_KEY' must bet set in environment or in profile.")
192
+
193
+ if errors:
194
+ raise CLIError("\n".join(errors))
158
195
 
159
196
  return source_config
160
197
 
@@ -3,8 +3,8 @@ import functools
3
3
  from plux import PluginManager, plugin
4
4
 
5
5
  # plugin namespace constants
6
- HOOKS_CONFIGURE_LOCALSTACK_CONTAINER = "localstack.hooks.configure_localstack_container"
7
- HOOKS_PREPARE_HOST = "localstack.hooks.prepare_host"
6
+ HOOKS_CONFIGURE_LOCALSTACK_CONTAINER = "localstack_cli.hooks.configure_localstack_container"
7
+ HOOKS_PREPARE_HOST = "localstack_cli.hooks.prepare_host"
8
8
 
9
9
 
10
10
  def hook(namespace: str, priority: int = 0, **kwargs):
@@ -0,0 +1 @@
1
+ """Testing utilities for the LocalStack CLI."""
@@ -0,0 +1,4 @@
1
+ """Testing configuration constants."""
2
+
3
+ # Secondary test account ID for multi-account testing scenarios
4
+ SECONDARY_TEST_AWS_ACCOUNT_ID = "886468871268"
localstack_cli/version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '4.13.2.dev36'
32
- __version_tuple__ = version_tuple = (4, 13, 2, 'dev36')
31
+ __version__ = version = '4.14.0'
32
+ __version_tuple__ = version_tuple = (4, 14, 0)
33
33
 
34
34
  __commit_id__ = commit_id = None