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
asked 9 months ago653 views
3 Answers
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
EXPERT
answered 9 months ago
profile picture
EXPERT
reviewed 9 months ago
  • 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
EXPERT
answered 9 months ago
profile pictureAWS
EXPERT
reviewed 9 months ago
  • 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.

answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions