

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 建立 Amazon SQS 佇列 CloudFormation
<a name="create-queue-cloudformation"></a>

使用 CloudFormation 主控台搭配 JSON 或 YAML 範本來建立 Amazon SQS 佇列。如需詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sqs-queue.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sqs-queue.html)》中的[使用 CloudFormation 範本](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-guide.html)和資源。

**使用 CloudFormation 建立 Amazon SQS 佇列。**

1. 將下列 JSON 程式碼複製到名為 `MyQueue.json` 的檔案。若要建立標準佇列，請省略 `FifoQueue` 和 `ContentBasedDeduplication` 屬性。如需內容型重複資料刪除功能的相關資訊，請參閱[Amazon SQS 中的精確一次處理](FIFO-queues-exactly-once-processing.md)。
**注意**  
FIFO 佇列名稱結尾必須是 `.fifo` 尾碼。

   ```
   {
      "AWSTemplateFormatVersion": "2010-09-09",
      "Resources": {
         "MyQueue": {
            "Properties": {
               "QueueName": "MyQueue.fifo",
               "FifoQueue": true,
               "ContentBasedDeduplication": true
                },
            "Type": "AWS::SQS::Queue"
            }
         },
      "Outputs": {
         "QueueName": {
            "Description": "The name of the queue",
            "Value": {
               "Fn::GetAtt": [
                  "MyQueue",
                  "QueueName"
               ]
            }
         },
         "QueueURL": {
            "Description": "The URL of the queue",
            "Value": {
               "Ref": "MyQueue"
            }
         },
         "QueueARN": {
            "Description": "The ARN of the queue",
            "Value": {
               "Fn::GetAtt": [
                  "MyQueue",
                  "Arn"
               ]
            }
         }
      }
   }
   ```

1. 登入 [CloudFormation 主控台](https://console.aws.amazon.com/cloudformation)，然後選擇 **Create Stack (建立堆疊)**。

1. 在 **Specify Template (指定範本)** 面板中，選擇 **Upload a template file (上傳範本檔案)​**、選擇您的 `MyQueue.json` 檔案，然後選擇 **Next (下一步)**。

1. 在 **Specify Details** (指定詳細資訊) 頁面，為 `MyQueue`Stack Name** (堆疊名稱) 輸入 **，然後選擇 **Next** (下一步)。

1. 在 **Options** (選項) 頁面上，選擇 **Next** (下一步)。

1. 在 **Review** (檢閱) 頁面上，選擇 **Create** (建立)。

   CloudFormation 開始建立`MyQueue`堆疊，並顯示 **CREATE\$1IN\$1PROGRESS** 狀態。程序完成後， CloudFormation 會顯示 **CREATE\$1COMPLETE** 狀態。  
![\[顯示 CREATE_COMPLETE 狀態的 CloudFormation 主控台。\]](http://docs.aws.amazon.com/zh_tw/AWSSimpleQueueService/latest/SQSDeveloperGuide/images/sqs-tutorials-creating-queue-cfn-create-complete.png)

1. (選用) 如果要顯示佇列的名稱、URL 和 ARN，請選擇堆疊的名稱，然後在下一頁展開 **Outputs** (輸出) 部分。