diff --git a/samcli/lib/providers/provider.py b/samcli/lib/providers/provider.py index 27838a80a7..af0fc4ecb0 100644 --- a/samcli/lib/providers/provider.py +++ b/samcli/lib/providers/provider.py @@ -7,6 +7,7 @@ import os import posixpath from collections import namedtuple +from platform import machine from typing import Any, Set, NamedTuple, Optional, List, Dict, Tuple, Union, cast, Iterator, TYPE_CHECKING from samcli.commands.local.cli_common.user_exceptions import ( @@ -20,7 +21,7 @@ SAM_METADATA_SKIP_BUILD_KEY, SAM_RESOURCE_ID_KEY, ) -from samcli.lib.utils.architecture import X86_64 +from samcli.lib.utils.architecture import X86_64, ARM64 if TYPE_CHECKING: # pragma: no cover # avoid circular import, https://docs.python.org/3/library/typing.html#typing.TYPE_CHECKING @@ -129,7 +130,7 @@ def architecture(self) -> str: If the architectures value is invalid """ if not self.architectures: - return X86_64 + return ARM64 if machine() in ("arm64", "aarch64") else X86_64 arch_list = cast(list, self.architectures) if len(arch_list) != 1: diff --git a/tests/unit/commands/local/lib/test_provider.py b/tests/unit/commands/local/lib/test_provider.py index 98e4a8099b..8aa09abca4 100644 --- a/tests/unit/commands/local/lib/test_provider.py +++ b/tests/unit/commands/local/lib/test_provider.py @@ -1,5 +1,6 @@ import os import posixpath +from platform import machine from unittest import TestCase from unittest.mock import MagicMock, Mock, patch @@ -300,7 +301,7 @@ def setUp(self) -> None: @parameterized.expand( [ ([ARM64], ARM64), - ([], X86_64), + ([], ARM64 if machine() in ("arm64", "aarch64") else X86_64), ([X86_64], X86_64), ] )