Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metadata.json Permission problems when doing sam deploy #3717

Closed
jsep925 opened this issue Mar 7, 2022 · 3 comments
Closed

metadata.json Permission problems when doing sam deploy #3717

jsep925 opened this issue Mar 7, 2022 · 3 comments
Labels
blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. stage/bug-repro The issue/bug needs to be reproduced

Comments

@jsep925
Copy link

jsep925 commented Mar 7, 2022

Description:

I'm getting permission errors for metadata.json file when using sam deploy:
Traceback (most recent call last):
File "/usr/bin/sam", line 8, in
sys.exit(cli())
File "/usr/lib/python3.9/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/samcli/lib/cli_validation/image_repository_validation.py", line 92, in wrapped
return func(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/samcli/lib/telemetry/metric.py", line 151, in wrapped
metric = Metric(metric_name)
File "/usr/lib/python3.9/site-packages/samcli/lib/telemetry/metric.py", line 318, in init
self._add_common_metric_attributes()
File "/usr/lib/python3.9/site-packages/samcli/lib/telemetry/metric.py", line 341, in _add_common_metric_attributes
self._data["installationId"] = self._gc.installation_id
File "/usr/lib/python3.9/site-packages/samcli/cli/global_config.py", line 351, in installation_id
self.set_value(DefaultEntry.INSTALLATION_ID, value)
File "/usr/lib/python3.9/site-packages/samcli/cli/global_config.py", line 273, in set_value
self._set_value(config_entry, value, is_flag, flush)
File "/usr/lib/python3.9/site-packages/samcli/cli/global_config.py", line 294, in _set_value
self._write_config()
File "/usr/lib/python3.9/site-packages/samcli/cli/global_config.py", line 325, in _write_config
self.config_path.write_text(json_str)
File "/usr/lib/python3.9/pathlib.py", line 1275, in write_text
with self.open(mode='w', encoding=encoding, errors=errors) as f:
File "/usr/lib/python3.9/pathlib.py", line 1242, in open
return io.open(self, mode, buffering, encoding, errors, newline,
File "/usr/lib/python3.9/pathlib.py", line 1110, in _opener
return self._accessor.open(self, flags, mode)
PermissionError: [Errno 13] Permission denied: '/home/samdeploy/.aws-sam/metadata.json'

Steps to reproduce:

we have dotnet core 3.1 lambda function, docker file use alphine 3.13, It is not happen if we aws-sam-cli 1.33.0.
But if we update to aws-sam-cli >= 1.34, it failed with same error:
PermissionError: [Errno 13] Permission denied: '/home/samdeploy/.aws-sam/metadata.json'

For workaround, we force to use aws-sam-cli==1.33.0 for dotnetcore3.1

Recently, we are update dotnetcore3.1 to dotnet 6. In order to build and deploy dotnet 6 lambda function, we must update sam cli to 1.40.1(Alphine updated to 3.14), but not able to deploy due to permission error for metadata.json

Observed result:

Expected result:

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS:
  2. sam --version: 1.40.1
  3. AWS region: us-east

Add --debug flag to command you are running

@torresxb1
Copy link
Contributor

torresxb1 commented Mar 10, 2022

Hi @jsep925, thanks for submitting an issue! Could you submit some more info or sample code to reproduce? I tried with SAM CLI version 1.40.1, dotnet 3.1 Hello World Quick Start example (from sam init), and modified the Dockerfile to use Alpine like so:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine as build-image

ARG FUNCTION_DIR="/build"
ARG SAM_BUILD_MODE="run"
ENV PATH="/root/.dotnet/tools:${PATH}"

RUN apk update && apk add zip

RUN mkdir $FUNCTION_DIR
WORKDIR $FUNCTION_DIR
COPY Function.cs HelloWorld.csproj aws-lambda-tools-defaults.json $FUNCTION_DIR/
RUN dotnet tool install -g Amazon.Lambda.Tools

# Build and Copy artifacts depending on build mode.
RUN mkdir -p build_artifacts
RUN if [ "$SAM_BUILD_MODE" = "debug" ]; then dotnet lambda package --configuration Debug; else dotnet lambda package --configuration Release; fi
RUN if [ "$SAM_BUILD_MODE" = "debug" ]; then cp -r /build/bin/Debug/netcoreapp3.1/publish/* /build/build_artifacts; else cp -r /build/bin/Release/netcoreapp3.1/publish/* /build/build_artifacts; fi

FROM public.ecr.aws/lambda/dotnet:core3.1

COPY --from=build-image /build/build_artifacts/ /var/task/
# Command can be overwritten by providing a different command in the template directly.
CMD ["HelloWorld::HelloWorld.Function::FunctionHandler"]

but I was unable to reproduce.

@torresxb1 torresxb1 added blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. stage/bug-repro The issue/bug needs to be reproduced and removed maintainer/need-response labels Mar 10, 2022
@sriram-mv
Copy link
Contributor

Going to close this issue, please feel free to comment here and we can re-open if this is still an issue.

@sg9211
Copy link

sg9211 commented Apr 20, 2023

Error: [WinError 5] Access is denied: '.aws-sam\build\GTAnnotationConsolidationLambdaFunction\constants'

Seeing this error when trying by running the following makefile.

[https://github.com/aws-samples/amazon-comprehend-semi-structured-documents-annotation-tools/blob/main/Makefile]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. stage/bug-repro The issue/bug needs to be reproduced
Projects
None yet
Development

No branches or pull requests

5 participants