I have a Gitlab CI pipeline which triggers AWS SAM template. This created a lambda layer. But though I do not make any change to lambda layer and re-trigger the Gitlab CI pipeline, a new version of AWS lambda layer gets created again. I need to stop creation of new version of lambda layer when there is no change made to lambda layer. Any suggestion would be appreciated.
Below are my files (just included relevant sections)
my SAM template:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
MemorySize: 128
Timeout: 15
Resources:
MyLambdaLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: 'my-lambda-layer'
ContentUri: layers/my-lambda-layer-code
CompatibleRuntimes:
- python3.7
Metadata:
BuildMethod: python3.7
MyLambda:
Type: AWS::Serverless::Function
Properties:
FunctionName: 'my-aws-lambda'
CodeUri: my-aws-lambda/
Handler: lambda_function.lambda_handler
Runtime: python3.7
MemorySize: 128
Timeout: 300
EventInvokeConfig:
MaximumRetryAttempts: 0
MaximumEventAgeInSeconds: 100
Layers:
- !Ref MyLambdaLayer
Gitlab-ci file:
- echo "creating services"
- sam build --template-file samtemplate.yaml
- sam package --template-file samtemplate.yaml --output-template-file output.yaml --s3-bucket $S3REPOBUCKET
- sam deploy --template-file output.yaml --stack-name $STACKNAME --capabilities CAPABILITY_NAMED_IAM --no-confirm-changeset --no-fail-on-empty-changeset --on-failure ROLLBACK