简体   繁体   中英

Error while executing command: sam build --use-container --template ${SAM_TEMPLATE}. Reason: exit status 1

I was trying to run sam build --use-container --template ${SAM_TEMPLATE} but it failed and showed Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: sam build --use-container --template ${SAM_TEMPLATE}. Reason: exit status 1

Observed result:

247 | \[Container\] 2023/01/02 09:00:13 Phase context status code: Message:
248 | \[Container\] 2023/01/02 09:00:13 Entering phase PRE_BUILD
249 | \[Container\] 2023/01/02 09:00:13 Phase complete: PRE_BUILD State: SUCCEEDED
250 | \[Container\] 2023/01/02 09:00:13 Phase context status code: Message:
251 | \[Container\] 2023/01/02 09:00:13 Entering phase BUILD
252 | \[Container\] 2023/01/02 09:00:13 Running command sam build --use-container --template ${SAM_TEMPLATE}
253 | Traceback (most recent call last):
254 | File "/root/.pyenv/versions/3.8.13/bin/sam", line 8, in
255 | sys.exit(cli())
256 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/click/core.py", line 1130, in call
257 | return self.main(\*args, \*kwargs)
258 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/click/core.py", line 1055, in main
259 | rv = self.invoke(ctx)
260 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/click/core.py", line 1651, in invoke
261 | cmd_name, cmd, args = self.resolve_command(ctx, args)
262 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/click/core.py", line 1698, in resolve_command
263 | cmd = self.get_command(ctx, cmd_name)
264 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/samcli/cli/command.py", line 133, in get_command
265 | mod = importlib.import_module(pkg_name)
266 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/importlib/init.py", line 127, in import_module
267 | return \_bootstrap.\_gcd_import(name\[level:\], package, level)
268 | File "", line 1014, in \_gcd_import
269 | File "", line 991, in \_find_and_load
270 | File "", line 975, in \_find_and_load_unlocked
271 | File "", line 671, in \_load_unlocked
272 | File "", line 843, in exec_module
273 | File "", line 219, in \_call_with_frames_removed
274 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/samcli/commands/build/init.py", line 6, in
275 | from .command import cli # noqa
276 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/samcli/commands/build/command.py", line 12, in
277 | from samcli.commands.\_utils.options import (
278 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/samcli/commands/\_utils/options.py", line 21, in
279 | from samcli.commands.\_utils.template import get_template_data, TemplateNotFoundException
280 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/samcli/commands/\_utils/template.py", line 10, in
281 | from botocore.utils import set_value_from_jmespath
282 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/botocore/utils.py", line 37, in
283 | import botocore.httpsession
284 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/botocore/httpsession.py", line 46, in
285 | from urllib3.contrib.pyopenssl import (
286 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/urllib3/contrib/pyopenssl.py", line 50, in
287 | import OpenSSL.SSL
288 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/OpenSSL/init.py", line 8, in
289 | from OpenSSL import crypto, SSL
290 | File "/root/.pyenv/versions/3.8.13/lib/python3.8/site-packages/OpenSSL/crypto.py", line 3268, in
291 | \_lib.OpenSSL_add_all_algorithms()
292 | AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'
293 |  
294 | \[Container\] 2023/01/02 09:00:14 Command did not exit successfully sam build --use-container --template ${SAM_TEMPLATE} exit status 1
295 | \[Container\] 2023/01/02 09:00:14 Phase complete: BUILD State: FAILED
296 | \[Container\] 2023/01/02 09:00:14 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: sam build --use-container --template ${SAM_TEMPLATE}. Reason: exit status 1
297 | \[Container\] 2023/01/02 09:00:14 Entering phase POST_BUILD
298 | \[Container\] 2023/01/02 09:00:14 Phase complete: POST_BUILD State: SUCCEEDED
299 | \[Container\] 2023/01/02 09:00:14 Phase context status code: Message:
300 | \[Container\] 2023/01/02 09:00:14 exiting execCommands
301 | \[Container\] 2023/01/02 09:00:14 Expanding base directory path: .
302 | \[Container\] 2023/01/02 09:00:14 Assembling file list
303 | \[Container\] 2023/01/02 09:00:14 Expanding .
304 | \[Container\] 2023/01/02 09:00:14 Expanding file paths for base directory .
305 | \[Container\] 2023/01/02 09:00:14 Assembling file list
306 | \[Container\] 2023/01/02 09:00:14 Expanding packaged-test.yaml
307 | \[Container\] 2023/01/02 09:00:14 Skipping invalid file path packaged-test.yaml
308 | \[Container\] 2023/01/02 09:00:14 Expanding assume-role.sh
309 | \[Container\] 2023/01/02 09:00:14 Expanding pipeline/
310 | \[Container\] 2023/01/02 09:00:14 Found 8 file(s)
311 | \[Container\] 2023/01/02 09:00:14 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
312 | \[Container\] 2023/01/02 09:00:14 Phase context status code: Message:

Expected Result:- Build successful

I was getting same error while running codepipeline in aws, following worked for me.

- pip install --upgrade pyOpenSSL

Hope it will help someone too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM