티스토리 뷰

Cloud Platform/AWS

sam build 에러

구티맨 2021. 2. 15. 10:16

AWS SAM 개발자 가이드 문서에 따라서 샘플 앱을 받아서 빌드와 로컬 호출 테스트를 해보려고 하는데,

 

시작부터 문제가 생겼습니다.

 

그냥 가이드대로 따라 했을 뿐인데, sam build 에서 아래와 같이 엄청나게 긴 에러 메시지들이 발생.

 

이래 저래 검색을 해보다가, 마지막에 keychain 을 중점으로 검색...하다 해결에 실마리가 되는 답변을 찾았습니다.

( stackoverflow.com/questions/56267890/docker-compose-unable-to-start/57025492#57025492 )

➜  goatee-IntelliJ git:(main) ✗ sam build
Building codeuri: . runtime: None metadata: {'DockerTag': 'java11-gradle-v1', 'DockerContext': './HelloWorldFunction', 'Dockerfile': 'Dockerfile'} functions: ['HelloWorldFunction']
Building image for HelloWorldFunction function
Setting DockerBuildArgs: {} for HelloWorldFunction function
Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/docker/credentials/store.py", line 79, in _execute
    output = subprocess.check_output(
  File "/usr/local/Cellar/python@3.8/3.8.7_2/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/Cellar/python@3.8/3.8.7_2/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/bin/docker-credential-osxkeychain', 'list']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/sam", line 33, in <module>
    sys.exit(load_entry_point('aws-sam-cli==1.17.0', 'console_scripts', 'sam')())
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py", line 152, in wrapped
    raise exception  # pylint: disable=raising-bad-type
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py", line 121, in wrapped
    return_value = func(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/lib/utils/version_checker.py", line 42, in wrapped
    actual_result = func(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/commands/build/command.py", line 160, in cli
    do_cli(
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/commands/build/command.py", line 250, in do_cli
    artifacts = builder.build()
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/lib/build/app_builder.py", line 160, in build
    return build_strategy.build()
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/lib/build/build_strategy.py", line 41, in build
    result.update(self._build_functions(self._build_graph))
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/lib/build/build_strategy.py", line 52, in _build_functions
    function_build_results.update(self.build_single_function_definition(build_definition))
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/lib/build/build_strategy.py", line 116, in build_single_function_definition
    result = self._build_function(
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/lib/build/app_builder.py", line 407, in _build_function
    return self._build_lambda_image(function_name=function_name, metadata=metadata)  # type: ignore
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/samcli/lib/build/app_builder.py", line 286, in _build_lambda_image
    build_logs = self._docker_client.api.build(
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/docker/api/build.py", line 261, in build
    self._set_auth_headers(headers)
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/docker/api/build.py", line 308, in _set_auth_headers
    auth_data = self._auth_configs.get_all_credentials()
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/docker/auth.py", line 302, in get_all_credentials
    for k in store.list().keys():
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/docker/credentials/store.py", line 71, in list
    data = self._execute('list', None)
  File "/usr/local/Cellar/aws-sam-cli/1.17.0/libexec/lib/python3.8/site-packages/docker/credentials/store.py", line 93, in _execute
    raise errors.process_store_error(e, self.program)
docker.credentials.errors.StoreError: Credentials store docker-credential-osxkeychain exited with "The specified item could not be found in the keychain.".

 

기존에 있던 아래의 ~/.docker/config.json 파일을 날려버리고( 혹시 문제가 생길수도 있으니 백업은 해두었습니다. )

{
  "credSstore" : "osxkeychain",
  "stackOrchestrator" : "swarm",
  "HttpHeaders" : {
    "User-Agent" : "Docker-Client/18.09.1 (darwin)"
  },
  "credsStore" : "osxkeychain"
}

 

docker login으로, config.json 파일을 생성하고 sam build 를 해봤더니 다행히 잘 되었습니다.

➜  goatee-IntelliJ git:(main) ✗ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: xxx
Password: 
Login Succeeded


➜  goatee-IntelliJ git:(main) ✗ ls ~/.docker
config.json daemon.json trust


➜  goatee-IntelliJ git:(main) ✗ cat ~/.docker/config.json 
{
        "auths": {
                "https://index.docker.io/v1/": {}
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/18.09.1 (darwin)"
        },
        "credsStore": "osxkeychain"
}

➜  goatee-IntelliJ git:(main) ✗ sam build
Building codeuri: . runtime: None metadata: {'DockerTag': 'java11-gradle-v1', 'DockerContext': './HelloWorldFunction', 'Dockerfile': 'Dockerfile'} functions: ['HelloWorldFunction']

.....

Build Succeeded

Built Artifacts  : .aws-sam/build
Built Template   : .aws-sam/build/template.yaml

Commands you can use next
=========================
[*] Invoke Function: sam local invoke
[*] Deploy: sam deploy --guided

 

시간이 되면, config 에 해당되는 내용을 좀 찾아봐야겠습니다.

 

신기한건 Dockerfile이 있는 폴더에서 docker build 명령어는 정상적으로 되던데,

 

sam build 만 수행하면 에러가 발생하는 상황이라... 이래저래 혼란스럽네요.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함