Skip to content

Commit 91c2171

Browse files
authored
Merge branch 'develop' into dependabot/pip/develop/cfn-lint-c84561e6cb
2 parents 65c27e1 + aaad3ea commit 91c2171

35 files changed

Lines changed: 869 additions & 281 deletions

.github/workflows/integration-tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@ jobs:
202202

203203
- name: Install Terraform
204204
if: contains(fromJSON('["terraform-build", "terraform-start-api", "terraform-invoke-start-lambda", "cloud-based-tests", "tier1-finch", "tier1-windows-build-1", "tier1-windows-build-2", "tier1-windows-build-3", "tier1-windows-other"]'), matrix.test_suite)
205-
shell: bash
206-
run: bash tests/install-terraform.sh
205+
uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4.0.0
206+
with:
207+
terraform_wrapper: false
207208

208209
- name: Setup Finch runtime
209210
if: matrix.test_suite == 'tier1-finch'

.github/workflows/validate_pyinstaller.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ jobs:
2121
run: chmod +x ./installer/pyinstaller/build-linux.sh
2222
- name: Build PyInstaller in manylinux container
2323
run: |
24-
docker run --rm -v .:/samcli -w /samcli -e CI_OVERRIDE='1' \
25-
quay.io/pypa/manylinux2014_x86_64:latest /samcli/installer/pyinstaller/build-linux.sh aws-sam-cli-linux-x86_64.zip
24+
for i in 1 2 3; do
25+
docker run --rm -v .:/samcli -w /samcli -e CI_OVERRIDE='1' \
26+
quay.io/pypa/manylinux2014_x86_64:latest /samcli/installer/pyinstaller/build-linux.sh aws-sam-cli-linux-x86_64.zip && break
27+
echo "Attempt $i failed, retrying..."
28+
sleep 10
29+
done
2630
- uses: actions/setup-python@v6
2731
with:
2832
python-version: 3.11

samcli/commands/local/cli_common/durable_context.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,24 @@ class DurableContext:
1818
Automatically reuses existing running containers when possible.
1919
"""
2020

21-
def __init__(self):
21+
def __init__(self, skip_pull_image=False):
2222
"""
2323
Initialize the durable context.
24+
25+
Parameters
26+
----------
27+
skip_pull_image : bool
28+
If True, skip pulling the emulator container image
2429
"""
2530
self._emulator: Optional[DurableFunctionsEmulatorContainer] = None
2631
self._reused_container = False
32+
self._skip_pull_image = skip_pull_image
2733

2834
def __enter__(self) -> "DurableContext":
2935
"""
3036
Start the emulator container or attach to an already running one
3137
"""
32-
self._emulator = DurableFunctionsEmulatorContainer()
38+
self._emulator = DurableFunctionsEmulatorContainer(skip_pull_image=self._skip_pull_image)
3339
self._reused_container = self._emulator.start_or_attach()
3440
return self
3541

samcli/commands/local/cli_common/invoke_context.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def __init__(
101101
invoke_images: Optional[str] = None,
102102
mount_symlinks: Optional[bool] = False,
103103
no_mem_limit: Optional[bool] = False,
104+
container_dns: Optional[Tuple[str]] = None,
104105
function_logical_ids: Optional[Tuple[str, ...]] = None,
105106
) -> None:
106107
"""
@@ -158,6 +159,8 @@ def __init__(
158159
Optional. A dictionary that defines the custom invoke image URI of each function
159160
mount_symlinks bool
160161
Optional. Indicates if symlinks should be mounted inside the container
162+
container_dns tuple
163+
Optional. Tuple of DNS server IP addresses for the container
161164
function_logical_ids tuple(str)
162165
Optional. Tuple of function logical IDs to filter and make available for local execution.
163166
Used by 'sam local start-api' and 'sam local start-lambda' commands to limit which
@@ -188,6 +191,7 @@ def __init__(
188191
self._debug_args = debug_args
189192
self._debugger_path = debugger_path
190193
self._container_env_vars_file = container_env_vars_file
194+
self._container_dns = container_dns
191195

192196
self._parameter_overrides = parameter_overrides
193197
# Override certain CloudFormation pseudo-parameters based on values provided by customer
@@ -356,6 +360,7 @@ def initialize_function_container(function: Function) -> None:
356360
container_host=self._container_host,
357361
container_host_interface=self._container_host_interface,
358362
extra_hosts=self._extra_hosts,
363+
container_dns=self._container_dns,
359364
)
360365

361366
# Collect container ID in a thread-safe way
@@ -610,6 +615,7 @@ def local_lambda_runner(self) -> LocalLambdaRunner:
610615
container_host=self._container_host,
611616
container_host_interface=self._container_host_interface,
612617
extra_hosts=self._extra_hosts,
618+
container_dns=self._container_dns,
613619
)
614620
return self._local_lambda_runner
615621

samcli/commands/local/cli_common/options.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ def local_common_options(f):
8484
"Example:"
8585
"--add-host example.com:127.0.0.1",
8686
),
87+
click.option(
88+
"--container-dns",
89+
multiple=True,
90+
help="Set custom DNS servers for the Lambda container. "
91+
"This parameter can be passed multiple times to specify multiple DNS servers. "
92+
"Example: --container-dns 8.8.8.8 --container-dns 1.1.1.1",
93+
),
8794
click.option(
8895
"--invoke-image",
8996
"-ii",

samcli/commands/local/invoke/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def cli(
139139
runtime,
140140
mount_symlinks,
141141
no_memory_limit,
142+
container_dns,
142143
tenant_id,
143144
durable_execution_name,
144145
):
@@ -174,6 +175,7 @@ def cli(
174175
runtime,
175176
mount_symlinks,
176177
no_memory_limit,
178+
container_dns,
177179
tenant_id,
178180
durable_execution_name,
179181
) # pragma: no cover
@@ -206,6 +208,7 @@ def do_cli( # pylint: disable=R0914
206208
runtime,
207209
mount_symlinks,
208210
no_mem_limit,
211+
container_dns,
209212
tenant_id,
210213
durable_execution_name,
211214
):
@@ -259,6 +262,7 @@ def do_cli( # pylint: disable=R0914
259262
invoke_images=processed_invoke_images,
260263
mount_symlinks=mount_symlinks,
261264
no_mem_limit=no_mem_limit,
265+
container_dns=container_dns,
262266
) as context:
263267
# Invoke the function
264268
context.local_lambda_runner.invoke(

samcli/commands/local/invoke/core/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"container_host",
3939
"container_host_interface",
4040
"add_host",
41+
"container_dns",
4142
"invoke_image",
4243
"runtime",
4344
"tenant_id",

samcli/commands/local/lib/local_lambda.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
import os
77
import platform
8-
from typing import Any, Dict, Optional, cast
8+
from typing import Any, Dict, Optional, Tuple, cast
99

1010
import boto3
1111
import click
@@ -65,6 +65,7 @@ def __init__(
6565
container_host: Optional[str] = None,
6666
container_host_interface: Optional[str] = None,
6767
extra_hosts: Optional[dict] = None,
68+
container_dns: Optional[Tuple[str]] = None,
6869
) -> None:
6970
"""
7071
Initializes the class
@@ -80,6 +81,7 @@ def __init__(
8081
:param string container_host: Optional. Host of locally emulated Lambda container
8182
:param string container_host_interface: Optional. Interface that Docker host binds ports to
8283
:param dict extra_hosts: Optional. Dict of hostname to IP resolutions
84+
:param tuple container_dns: Optional. Tuple of DNS server IP addresses for the container
8385
"""
8486

8587
self.local_runtime = local_runtime
@@ -95,6 +97,7 @@ def __init__(
9597
self.container_host = container_host
9698
self.container_host_interface = container_host_interface
9799
self.extra_hosts = extra_hosts
100+
self.container_dns = container_dns
98101

99102
def get_function(self, function_identifier: str, tenant_id: Optional[str] = None) -> Function:
100103
"""
@@ -245,6 +248,7 @@ def invoke(
245248
container_host=self.container_host,
246249
container_host_interface=self.container_host_interface,
247250
extra_hosts=self.extra_hosts,
251+
container_dns=self.container_dns,
248252
)
249253
except ContainerResponseException:
250254
# NOTE(sriram-mv): This should still result in a exit code zero to avoid regressions.

samcli/commands/local/start_api/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def cli(
146146
ssl_cert_file,
147147
ssl_key_file,
148148
no_memory_limit,
149+
container_dns,
149150
):
150151
"""
151152
`sam local start-api` command entry point
@@ -182,6 +183,7 @@ def cli(
182183
ssl_cert_file,
183184
ssl_key_file,
184185
no_memory_limit,
186+
container_dns,
185187
) # pragma: no cover
186188

187189

@@ -215,6 +217,7 @@ def do_cli( # pylint: disable=R0914
215217
ssl_cert_file,
216218
ssl_key_file,
217219
no_mem_limit,
220+
container_dns,
218221
):
219222
"""
220223
Implementation of the ``cli`` method, just separated out for unit testing purposes
@@ -261,6 +264,7 @@ def do_cli( # pylint: disable=R0914
261264
invoke_images=processed_invoke_images,
262265
add_host=add_host,
263266
no_mem_limit=no_mem_limit,
267+
container_dns=container_dns,
264268
) as invoke_context:
265269
ssl_context = (ssl_cert_file, ssl_key_file) if ssl_cert_file else None
266270
service = LocalApiService(

samcli/commands/local/start_api/core/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"container_host",
4242
"container_host_interface",
4343
"add_host",
44+
"container_dns",
4445
"invoke_image",
4546
"disable_authorizer",
4647
]

0 commit comments

Comments
 (0)