Search code examples
amazon-web-serviceslambdaaws-sam-cli

Set static name of lambda deployed with sam local


I'm following the helloworld example from the sam local repo:

aws-sam-local\samples\hello-world\python

But here is my template.yaml:

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Serverless Specification template describing your function
Resources:
  MyLambda:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: lambda_function.lambda_handler
      Runtime: python3.6
      CodeUri: .
      Description: ''
      MemorySize: 128
      Timeout: 3
      Role: 'arn:aws:iam::123345:role/myrole'

I package it up:

sam package --template-file template.yaml --s3-bucket BUCKET --output-template-file packaged-template.yaml

And deploy!

sam deploy --template-file packaged-template.yaml --stack-name test-sam-local --capabilities CAPABILITY_IAM --region REGION

And it works, so that's great, but here is the name of the lambda it created:

test-sam-local-MyLambda-SOME_GUID

Do I have control over that name? I want the name of the function to be statically defined and clobbered whenever this is redeployed (to a function with that same name).


Solution

  • Use: FunctionName: MyLambda under properties. Reference (Here)