I'm trying to Setting up CI/CD for Lambda Functions using AWS CodePipeline+GitHub+CloudFormation
but I'm facing CodeUri error between Default artifact store bucket and cloudFormation.
I have created lambda function locally and cloned it with github repository. Then I created code pipeline and in deploy stage I have configured the stack with template file function.yml with syntax:
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Resources:
SampleLambdaFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
# Directory where the source file is located
FunctionName: cicd_testing_by_ahmad
Handler: index.handler
Runtime: nodejs 14.x
but I'm facing an error
-
"Stack:arn:aws:cloudformation:us-east-1:747******** stack/CiCdByAhmed/a27c5c50-97e8-************ is in ROLLBACK_COMPLETE state and can not be updated. (Service: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError; Request ID: d9ea93a1-9aff-4e74-9e9a-*********; Proxy: null)".
-
I searched on this error in cloudFormation and find the reason "Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [SampleLam
bdaFunction] is invalid. 'CodeUri' is not a valid S3 Uri of the form 's3://bucket/key' with optional versionId query parameter.. Rollback requested by user."
But I cannot set CodeUri manually to 's3://bucket/key' because when we push our code new object file created in S3 automatically and CodeUri is updated itself. And we have multiple objects(files) and we have to pick up the latest one but in my case it's not working correct.
Explain how can I resolve this issue.