

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

# 反射-反射-反射
<a name="aws-sns-sqs"></a>

![](https://docs.aws.amazon.com/zh_tw/solutions/latest/constructs/images/experimental.png)


 所有類都在積極開發中，並且在任何未來版本中都會受到非向後兼容的更改或刪除。這些不受[語義版本](https://semver.org/)模型。這意味著，雖然您可以使用它們，但在升級到此軟件包的較新版本時，您可能需要更新源代碼。

**請注意：** 為了確保功能正確，專案中的 AWS 解決方案建構套件和 AWS CDK 套件必須是相同的版本。


|  **語言**  |  **套件**  | 
| --- | --- | 
|  ![](https://docs.aws.amazon.com/zh_tw/solutions/latest/constructs/images/python.png) Python  |  aws\_solutions\_constructs.aws\_sns\_sqs  | 
|  ![](https://docs.aws.amazon.com/zh_tw/solutions/latest/constructs/images/typescript.png) 打字稿  |  @aws-solutions-constructs/aws-sns-sqs  | 
|  ![](https://docs.aws.amazon.com/zh_tw/solutions/latest/constructs/images/java.png) Java  |  software.amazon.awsconstructs.services.snssqs  | 

## Overview
<a name="overview-28"></a>

 此 AWS 解決方案建構實作連接到 Amazon SQS 佇列的 Amazon SNS 主題。

 下面是 TypeScript 中的最小可部署模式定義：

```
import { SnsToSqs, SnsToSqsProps } from "@aws-solutions-constructs/aws-sns-sqs";
import * as iam from '@aws-cdk/aws-iam';

const snsToSqsStack = new SnsToSqs(this, 'SnsToSqsPattern', {});

// Grant yourself permissions to use the Customer Managed KMS Key
const policyStatement = new iam.PolicyStatement({
    actions: ["kms:Encrypt", "kms:Decrypt"],
    effect: iam.Effect.ALLOW,
    principals: [ new iam.AccountRootPrincipal() ],
    resources: [ "*" ]
});

snsToSqsStack.encryptionKey?.addToResourcePolicy(policyStatement);
```

## Initializer
<a name="initializer-28"></a>

```
new SnsToSqs(scope: Construct, id: string, props: SnsToSqsProps);
```

 *參數* 
+  scope[`Construct`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Construct.html) 
+  id`string` 
+  提案[`SnsToSqsProps`](#pattern-construct-props-28) 

## 模式建立道具
<a name="pattern-construct-props-28"></a>


|  **名稱**  |  **類型**  |  **描述**  | 
| --- | --- | --- | 
|  現在的托比科比？  |  [`sns.Topic`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sns.Topic.html)  |  SNS 主題對象的現有實例，提供這個和topicProps會導致錯誤。 | 
|  主題道具？  |  [`sns.TopicProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sns.TopicProps.html)  |  選用的使用者提供的屬性，可覆寫 SNS 主題的預設屬性。忽略existingTopicObj提供。 | 
|  是否存在佇列中？  |  [`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.Queue.html)  |  選擇性的現有 SQS 佇列，而不是預設佇列。同時提供這個和queueProps會導致錯誤。 | 
|  佇列道具？  |  [`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.QueueProps.html)  |  選擇性的使用者提供的特性來覆寫 SQS 佇列的預設特性。忽略existingQueueObj提供。 | 
|  部署死亡佇列？  |  boolean  |  無論建立次要佇列做為無效字母佇列。預設為 true。 | 
|  死亡排隊道具？  |  [`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.QueueProps.html)  |  可選的使用者提供的道具來覆寫死信佇列的預設道具。只有在deployDeadLetterQueue屬性會設為 true。 | 
|  maxReceiveCount？  |  number  |  訊息移到無效字母佇列之前，需交付佇列的次數。預設為 15。 | 
|  使用客戶管理的金鑰啟用加密？  |  boolean  |  是否使用由此 CDK 應用程式管理或匯入的客戶管理的加密金鑰。如果匯入加密金鑰，則必須在encryptionKey屬性為此建構。 | 
|  encryptionKey  |  [`kms.Key`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-kms.Key.html)  |  選用的現有加密金鑰，而非預設加密金鑰。 | 
|  加密密鑰道具？  |  [`kms.KeyProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-kms.KeyProps.html)  |  選用的使用者提供的屬性，可覆寫加密金鑰的預設屬性。 | 

## 模式性質
<a name="pattern-properties-28"></a>


|  **名稱**  |  **類型**  |  **描述**  | 
| --- | --- | --- | 
|  snsTopic  |  [`sns.Topic`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sns.Topic.html)  |  傳回由模式建立的 SNS 主題的實例。 | 
|  encryptionKey  |  [`kms.Key`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-kms.Key.html)  |  返回由模式創建的加密密鑰的實例。 | 
|  平方  |  [`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.Queue.html)  |  返回由模式創建的 SQS 隊列的實例。 | 
|  死機隊列？  |  [`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.Queue.html)  |  返回由模式創建的死信隊列的實例，如果一個被部署。 | 

## 預設設定
<a name="default-settings-28"></a>

 此模式的開箱即用實現沒有任何覆蓋將設置以下默認值：

### Amazon SNS 主題
<a name="amazon-sns-topic-28"></a>
+  設定 SNS 主題的最低權限存取權限。
+  使用 AWS 受管 KMS 金鑰啟用伺服器端加密。
+  強制加密傳輸中的資料。

### Amazon SQS 佇列
<a name="aws-lambda-function-28"></a>
+  設定 SQS 佇列的最低權限存取權限。
+  為來源 SQS 佇列建立無效字母佇列。
+  使用客戶管理的 KMS 金鑰啟用 SQS 佇列的伺服器端加密。
+  強制加密傳輸中的資料。

## Architecture
<a name="architecture-28"></a>

![](https://docs.aws.amazon.com/zh_tw/solutions/latest/constructs/images/aws-sns-sqs.png)


## GitHub
<a name="github-28"></a>


<table>
<thead>
  <tr><th colspan="2"> <b>要查看此模式的代碼，創建/查看問題和提取請求，以及更多：</b> </th></tr>
</thead>
<tbody>
  <tr><td> <img src="https://docs.aws.amazon.com/zh_tw/solutions/latest/constructs/images/GitHub-Mark-32px.png" alt="" /> </td><td> <a href="https://github.com/awslabs/aws-solutions-constructs/tree/master/source/patterns/%40aws-solutions-constructs/aws-sns-sqs">@aws-解決方案-結構/awssssss-</a> </td></tr>
</tbody>
</table>
