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
已提问 10 个月前706 查看次数
3 回答
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
专家
已回答 10 个月前
profile picture
专家
已审核 10 个月前
  • 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
专家
已回答 10 个月前
profile pictureAWS
专家
已审核 10 个月前
  • 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.

已回答 8 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则