Deploying the stack without updating Lambda functions?

Hi. I am using serverless for a year now with many projects in production. There are some times i have a such need which I cannot find any related question.

As Infrastructure as Code pattern I keep every configuration on yml file. There are times I wanna change the configuration, like removing GSI or adding GSI for dynamodb table or IAM permissions, without updating the lambda functions. But deploying stack updates them all unnecessarily.

Has any have idea on this or feedback? I wanna change my stack without updating lambda functions.

Hi, I have a monorepo project, some packages have their internal resources but they use common resources as well (sqs, sns…). So I’ve decided to create an additional package just for this purpose. I have a folder with a serverless.yml file which contains just common resources descriptions. In this way, I can change these resources without redeploying lamdas. So maybe you can create an additional folder and put a serverless.yml with your descriptions there, it will create an extra stack, so you will need to use Outputs: + !ImportValue.

Ok. I kinda understand. Do you have any examples of how to use Outputs and !ImportValue.

Like a code snippet ? It would help to understand better. Thanks


common resources (common-package serverless.yml)

        Type: AWS::SQS::Queue
            QueueName: ${self:custom.incomingEventSqsQueue}

// export arn + url
        Value: !Ref IncomingEventSqsQueue
            Name: ${self:provider.stage}-IncomingEventSqsQueueUrl

        Value: !GetAtt IncomingEventSqsQueue.Arn
            Name: ${self:provider.stage}-IncomingEventSqsQueueArn

in a different package where I want to use this queue

     incomingEventSqsQueueArn: !ImportValue ${self:provider.stage}-IncomingEventSqsQueueArn
     incomingEventSqsQueueUrl: !ImportValue ${self:provider.stage}-IncomingEventSqsQueueUrl
        handler: services/events-store-handler/index.handler
            - sqs:
                  batchSize: 1
                  arn: ${self:custom.incomingEventSqsQueueArn}

So you just need to import value by name.

1 Like