AWS cloudformation template for sqs queue

This tutorial explains how to create AWS SQS queue using CloudFormation template.

See Also

AWS SQS queue using cloudformation

The resource type AWS::SQS::Queue creates an AWS SQS standard or FIFO queue. Let's perform below steps to deploy standard SQS queue with default settings using cloudformation template.

1. Create a file SQSTemplate.yaml.

2. Copy the below YAML template in SQSTemplate.yaml.

   
  AWSTemplateFormatVersion: "2010-09-09"
  Description: "This example template shows how to create an Amazon SQS queue with cfn template."
  
  Resources:
    MyQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: "MySampleQueue"
   

3. To deploy this stack using console, open the AWS CloudFormation directly with the URL https://console.aws.amazon.com/cloudformation/ .

4. Navigate to Stacks, Click on Create stack and click on With new resources (standard).

aws sqs cfn template

5. Select Template is ready . Select Upload a template file. Click on Choose file to select SQSTemplate.yaml from and click on Next.

aws sqs cfn template

6. Enter Stack name and click on Next.

aws sqs cfn template

7. In Configure stack options page click on Next.

8. In Review template click on Submit.

9. Check Stack Events section, on completion you should see CREATE_COMPLETE for the stack.

aws sqs cfn template

With the above basic cfn template we deployed a standard SQS queue in AWS account. Let's update the template to apply the tags on previously created SQS queue.

AWS cfn template to apply tags on SQS

10. Copy and paste the below template in SQSTemplate.yaml

   
  AWSTemplateFormatVersion: "2010-09-09"
  Description: "This example template shows how to create an Amazon SQS queue with cfn template."
  
  Resources:
    MyQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: "MySampleQueue"
        Tags:
          - Key: "Name"
            Value: "MySampleQueue"
          - Key: "Project"
            Value: "Learning"
   

11. Navigate to stack created in Step 9 and click on Update.

aws sqs cfn template

12. Select Replace current template. Select Upload a template file. Click on Choose file to select SQSTemplate.yaml and click on Next.

aws sqs cfn template

13. In Stack details and Configure stack options pages click on Next.

14. In Review template page click on Next.

15. Check Stack Events section, on completion you should see UPDATE_COMPLETE for the stack.


Category: AWS