CloudFormation: error during deployment

0

I am developing AWS Lambda as NET 6 Web Service. and use Github Action for build and deployment.

During the deployment step I have an error:

Run aws cloudformation deploy --template-file ./aws/cfn/pm2customers-lambda.yml --stack-name pm2customers-lambda-apigw --parameter-overrides \

Waiting for changeset to be created.. Waiting for stack create/update to complete

Failed to create/update the stack. Run the following command to fetch the list of events leading up to the failure aws cloudformation describe-stack-events --stack-name pm2customers-lambda-apigw Error: Process completed with exit code 255.

How to fixt it?

Upd. I have got the log

aws cloudformation describe-stack-events --stack-name pm2customers-lambda-apigw >c:\myaws\cf.log

And found:

"ResourceStatus": "CREATE_FAILED", "ResourceStatusReason": "Resource handler returned message: "Uploaded file must be a non-empty zip (Service: Lambda, Status Code: 400, Request ID: be2da973-058a-4d92-b477-f48c0752b1da)" (RequestToken: 1aba761f-cf60-e04c-c777-ed563241b2b4, HandlerErrorCode: InvalidRequest)", "ResourceProperties": "{"Role": "arn:aws:iam::074745971345:role/pm2customers-lambda-apigw-LambdaExecutionRole-1I8I18GU0B8TV", "FunctionName":"pm2customer-lambda-apigw-dev-lambda","MemorySize":"512","Runtime":"dotnet6", "Timeout":"60","Handler":"MinimalApiSample","Code": {"S3Bucket":"pm2customer-lambda-apigw-bucket","S3Key": "pm2customerlambda-f7e2816b94b6fea8f3975580a38dd04a9be4f4a7.zip"},"Architectures":["arm64"]}"

But the previous step completed OK, the app was built and zipped. What else can I check?

Oleg
gefragt vor 10 Monaten707 Aufrufe
3 Antworten
1

The problem is due to this resource pm2customer-lambda-apigw-dev-lambda stating that the zip file is empty. You need to check the file pm2customerlambda-f7e2816b94b6fea8f3975580a38dd04a9be4f4a7.zip located in Bucket pm2customer-lambda-apigw-bucket if the zip file doesn't contain you compiled Lambda function code you need to validate your build step.

profile picture
EXPERTE
beantwortet vor 10 Monaten
profile picture
EXPERTE
überprüft vor 10 Monaten
  • Yes, it has size=22B, but why? I do zip

    • name: Zip artifact run: | zip -jr ${{ env.APPLICATION_PACKAGE }}-${{ github.sha }}.zip . -i ./bin/Release/net6.0/publish/ without any errors

    Originally the zip command was

    zip -jr ${{ env.APPLICATION_PACKAGE }}-${{ github.sha }}.zip ./MinimalApiSample/bin/Release/net6.0/publish/*

    I have changed to zip -jr ${{ env.APPLICATION_PACKAGE }}-${{ github.sha }}.zip . -i ./bin/Release/net6.0/publish/ because it executed with error. May be it is the reason that zip file is 22 B = empty?

0

Hi,

you will need to check the individual events in CloudFormation to understand what happened. In order to do so, you can either run the mentioned command

aws cloudformation describe-stack-events --stack-name pm2customers-lambda-apigw

on the CLI or check the stack in the CloudFormation console. Please refer to https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html as well.

profile pictureAWS
EXPERTE
beantwortet vor 10 Monaten
profile pictureAWS
EXPERTE
überprüft vor 10 Monaten
  • Hi, alternative to Be's proposal if you prefer interactive mode: check on the console to see if your stack still exists: you'd get your events directly from there. If stack was terminated, you will have to obtain events with Stack-Id instead of stack name via CLI or by displaying all stacks in the AWS console (default: only non-terminated ones)

    When you have the events, please, update your question with the 1st failing stack event to obtain further assistance on the issue itself.

  • I have updated my question, please see it.

0

I did run into similar issue. It turns out the code is not saved in visual studio. The code uploaded into the S3 bucket is empty. After I save the code and re-do the process, it works out.

beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen