6

I have some lambda functions that have been created before moving to AWS SAM. I would like to update my existing lambda function using AWS SAM. What would be the process of referencing the lambda function in AWS SAM. I have a lambda function already created called: hello.

How would I update the lambda function using AWS SAM? below is my sam template.yaml file

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: CD Demo Lambda
Resources:
  hello:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: lambda_function.lambda_handler
      Runtime: python3.7
      CodeUri: ./s3lambda
      FunctionName: hello
      MemorySize: 128
      Timeout: 03       

3 Answers 3

-1

As AWS SAM uses Cloudformation for deploying resources.

You need to import the lambdas Importing existing resources into a stack in the cloudformation stack.

Sign up to request clarification or add additional context in comments.

3 Comments

thank you for your response. just one question: how would I reference the stack in the template.yaml file?
as per the documentation, you start with the template. >During this import, you need to provide a template that describes the entire stack, including the target resources. If existing stack resources are modified in the prepared template, the import fails.
That's for importing existing lambda into an existing stack. How do you reference an existing lambda into a new stack when creating with sam deploy from a template file?
-1

The documentation states that you cannot import resources to AWS SAM Templates.

Comments

-1

The answers here are not so useful for beginners.

If you want to update your AWS Lambda function using SAM-CLI, I guess that you already deployed a function with sam deploy --guided command. SAM helped you to deploy your app with CloudFormation and saved the configuration in the samconfig.toml file.

Next time you can deploy your app just by giving the stack-name and (at least in my case) the S3 Bucket where your Lambda Function is placed.

sam deploy --stack-name YOUR-APP-NAME --s3-bucket YOUR-BUCKET-NAME

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.