Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a parameter store configuration value with Serverless Framework?

I have the following queue that is getting created with the serverless.yml file of Serverless Framework project:

resources:
  Resources:
    myAppSQSQueue:
      Type: "AWS::SQS::Queue"
      Properties:
        QueueName: "my-app-sqs-queue-${opt:stage, self:provider.stage}"

How do I take URL of the queue that gets created and store it as a parameter in AWS Systems Manager? I need to store it there so other applications outside of this one know how to access it.

like image 908
David Derman Avatar asked May 03 '26 17:05

David Derman


1 Answers

I figured it out. Since serverless framework extends CloudFormation, I found the answer in the Cloud Formation documenation here:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ssm-parameter.html

It can be done as follows:

resources:
  Resources:
    myAppSQSQueue:
      Type: "AWS::SQS::Queue"
      Properties:
        QueueName: "my-app-sqs-queue-${opt:stage, self:provider.stage}"
    myAppSSMParameterQueueName:
      Type: AWS::SSM::Parameter
      Properties:
        Name: /${opt:stage, self:provider.stage}/sqs/my-app-param-name
        Type: String
        Value: 
          Fn::GetAtt:
            - myAppSQSQueue
            - Arn
        Tags:
          Environment: ${opt:stage, self:provider.stage}

This stores the ARN of the queue in the parameter store. I'm not sure if getting the url is possible, but the ARN is fine for my use case.

like image 189
David Derman Avatar answered May 07 '26 11:05

David Derman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!