|
| 1 | + |
| 2 | + |
| 3 | +# [terraform-aws-arc-sqs](https://github.com/sourcefuse/terraform-aws-arc-sqs) |
| 4 | + |
| 5 | +<a href="https://github.com/sourcefuse/terraform-aws-arc-sqs/releases/latest"><img src="https://img.shields.io/github/release/sourcefuse/terraform-aws-arc-sqs.svg?style=for-the-badge" alt="Latest Release"/></a> <a href="https://github.com/sourcefuse/terraform-aws-arc-sqs/commits"><img src="https://img.shields.io/github/last-commit/sourcefuse/terraform-aws-arc-sqs.svg?style=for-the-badge" alt="Last Updated"/></a>   |
| 6 | + |
| 7 | +[](https://sonarcloud.io/summary/new_code?id=sourcefuse_terraform-aws-arc-sqs) |
| 8 | + |
| 9 | +## Overview |
| 10 | + |
| 11 | +SourceFuse AWS Reference Architecture (ARC) Terraform module for managing Amazon SQS queues with enterprise-grade features and security best practices. |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- **Multiple Queue Types**: Support for both Standard and FIFO queues with comprehensive configuration options |
| 16 | +- **Dead Letter Queue Support**: Automatic DLQ provisioning with configurable retry policies for reliable message handling |
| 17 | +- **Flexible Encryption**: Choice between SQS-managed SSE or customer-managed KMS encryption with automatic key rotation |
| 18 | +- **Message Configuration**: Fine-grained control over retention, visibility timeouts, delays, and long polling |
| 19 | +- **Queue Policies**: Integrated IAM policy management with support for cross-account and service access patterns |
| 20 | +- **High Throughput FIFO**: Advanced FIFO configurations with per-message-group throughput and deduplication scopes |
| 21 | +- **Modular Design**: Integrates seamlessly with other SourceFuse ARC modules (SNS, KMS, Tags) |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +See the [examples](./examples/) directory for full examples. |
| 26 | + |
| 27 | +```hcl |
| 28 | +module "sqs" { |
| 29 | + source = "sourcefuse/arc-sqs/aws" |
| 30 | + version = "0.0.1" |
| 31 | +
|
| 32 | + name = "my-application-queue" |
| 33 | +
|
| 34 | + # Enable Dead Letter Queue for reliability |
| 35 | + dlq_config = { |
| 36 | + enabled = true |
| 37 | + max_receive_count = 5 |
| 38 | + } |
| 39 | +
|
| 40 | + # Configure long polling for cost optimization |
| 41 | + message_config = { |
| 42 | + receive_wait_time_seconds = 20 |
| 43 | + visibility_timeout = 300 |
| 44 | + retention_seconds = 345600 # 4 days |
| 45 | + } |
| 46 | +
|
| 47 | + tags = module.tags.tags |
| 48 | +
|
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +## Examples |
| 53 | + |
| 54 | +- [basic-standard-queue](./examples/basic-standard-queue/) - Simple SQS queue with minimal configuration |
| 55 | +- [standard-queue-with-dlq](./examples/standard-queue-with-dlq/) - Queue with Dead Letter Queue for message failure handling |
| 56 | +- [fifo-queue](./examples/fifo-queue/) - FIFO queue with message ordering and deduplication |
| 57 | +- [encrypted-queue](./examples/encrypted-queue/) - Queue with customer-managed KMS encryption |
| 58 | +- [sns-fanout-queue](./examples/sns-fanout-queue/) - SQS queue configured for SNS topic subscriptions |
| 59 | + |
| 60 | +For detailed usage instructions, see the [Module Usage Guide](./docs/module-usage-guide/README.md). |
| 61 | + |
| 62 | +## Versioning |
| 63 | + |
| 64 | +This project uses a `.version` file at the root. Increment this version before committing to `main`. The pipeline will automatically tag the commit. |
| 65 | + |
| 66 | +## Development |
| 67 | + |
| 68 | +### Prerequisites |
| 69 | + |
| 70 | +- [terraform](https://learn.hashicorp.com/terraform/getting-started/install#installing-terraform) |
| 71 | +- [terraform-docs](https://github.com/segmentio/terraform-docs) |
| 72 | +- [pre-commit](https://pre-commit.com/#install) |
| 73 | +- [golang](https://golang.org/doc/install#install) |
| 74 | +- [golint](https://github.com/golang/lint#installation) |
| 75 | + |
| 76 | +### Configurations |
| 77 | + |
| 78 | +- Configure pre-commit hooks |
| 79 | + ```sh |
| 80 | + pre-commit install |
| 81 | + ``` |
| 82 | + |
| 83 | +### Versioning |
| 84 | + |
| 85 | +Specify the version bump in commit messages using `#major`, `#minor`, or `#patch`. |
| 86 | + |
| 87 | +Example: |
| 88 | + |
| 89 | +```sh |
| 90 | +git commit -m "your commit message #major" |
| 91 | +``` |
| 92 | + |
| 93 | +Default: `#patch` |
| 94 | + |
| 95 | +### Tests |
| 96 | +- Tests are available in `test` directory |
| 97 | +- Configure the dependencies |
| 98 | + ```sh |
| 99 | + cd test/ |
| 100 | + go mod init github.com/sourcefuse/terraform-aws-arc-sqs |
| 101 | + go get github.com/gruntwork-io/terratest/modules/terraform |
| 102 | + ``` |
| 103 | +- Now execute the test |
| 104 | + ```sh |
| 105 | + go test -timeout 30m |
| 106 | + ``` |
| 107 | + |
| 108 | +## Authors |
| 109 | + |
| 110 | +This project is authored by: |
| 111 | +- SourceFuse ARC Team |
| 112 | + |
| 113 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 114 | +## Requirements |
| 115 | + |
| 116 | +| Name | Version | |
| 117 | +|------|---------| |
| 118 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3, < 2.0.0 | |
| 119 | +| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0, < 7.0 | |
| 120 | + |
| 121 | +## Providers |
| 122 | + |
| 123 | +| Name | Version | |
| 124 | +|------|---------| |
| 125 | +| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.16.0 | |
| 126 | + |
| 127 | +## Modules |
| 128 | + |
| 129 | +| Name | Source | Version | |
| 130 | +|------|--------|---------| |
| 131 | +| <a name="module_kms"></a> [kms](#module\_kms) | sourcefuse/arc-kms/aws | 1.0.11 | |
| 132 | + |
| 133 | +## Resources |
| 134 | + |
| 135 | +| Name | Type | |
| 136 | +|------|------| |
| 137 | +| [aws_sqs_queue.dlq](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource | |
| 138 | +| [aws_sqs_queue.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource | |
| 139 | +| [aws_sqs_queue_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue_policy) | resource | |
| 140 | +| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | |
| 141 | +| [aws_iam_policy_document.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | |
| 142 | + |
| 143 | +## Inputs |
| 144 | + |
| 145 | +| Name | Description | Type | Default | Required | |
| 146 | +|------|-------------|------|---------|:--------:| |
| 147 | +| <a name="input_custom_redrive_policy"></a> [custom\_redrive\_policy](#input\_custom\_redrive\_policy) | JSON policy to specify an external dead-letter queue (instead of using dlq\_config) | `string` | `null` | no | |
| 148 | +| <a name="input_dlq_config"></a> [dlq\_config](#input\_dlq\_config) | Dead Letter Queue configuration. Set enabled=true to create DLQ | <pre>object({<br/> enabled = optional(bool, false)<br/> name = optional(string, null)<br/> max_receive_count = optional(number, 3)<br/> message_retention_seconds = optional(number, 1209600)<br/> delay_seconds = optional(number, 0)<br/> max_message_size = optional(number, 262144)<br/> receive_wait_time_seconds = optional(number, 0)<br/> visibility_timeout = optional(number, 30)<br/> content_based_deduplication = optional(bool, false)<br/> deduplication_scope = optional(string, null)<br/> throughput_limit = optional(string, null)<br/> redrive_allow_policy = optional(string, null)<br/> })</pre> | <pre>{<br/> "enabled": false<br/>}</pre> | no | |
| 149 | +| <a name="input_fifo_config"></a> [fifo\_config](#input\_fifo\_config) | FIFO queue configuration. Set enabled=true for FIFO queue. deduplication\_scope valid values: messageGroup, queue. throughput\_limit valid values: perQueue, perMessageGroupId | <pre>object({<br/> enabled = optional(bool, false)<br/> content_based_deduplication = optional(bool, false)<br/> deduplication_scope = optional(string, null)<br/> throughput_limit = optional(string, null)<br/> })</pre> | <pre>{<br/> "enabled": false<br/>}</pre> | no | |
| 150 | +| <a name="input_kms_config"></a> [kms\_config](#input\_kms\_config) | KMS encryption configuration. If null, uses AWS managed SSE-SQS encryption | <pre>object({<br/> key_arn = optional(string, null)<br/> create_key = optional(bool, false)<br/> data_key_reuse_period = optional(number, 300)<br/> deletion_window_days = optional(number, 7)<br/> rotation_enabled = optional(bool, true)<br/> alias = optional(string, null)<br/> policy = optional(string, null)<br/> })</pre> | `null` | no | |
| 151 | +| <a name="input_message_config"></a> [message\_config](#input\_message\_config) | Message handling configuration | <pre>object({<br/> delay_seconds = optional(number, 0)<br/> max_message_size = optional(number, 262144)<br/> retention_seconds = optional(number, 345600)<br/> receive_wait_time_seconds = optional(number, 0)<br/> visibility_timeout = optional(number, 30)<br/> })</pre> | `{}` | no | |
| 152 | +| <a name="input_name"></a> [name](#input\_name) | Name of the SQS queue. If fifo\_queue is set to true, the name must end with .fifo | `string` | n/a | yes | |
| 153 | +| <a name="input_policy_config"></a> [policy\_config](#input\_policy\_config) | Queue policy configuration | <pre>object({<br/> create = optional(bool, false)<br/> policy_json = optional(string, null)<br/> source_policy_documents = optional(list(string), [])<br/> override_policy_documents = optional(list(string), [])<br/> })</pre> | <pre>{<br/> "create": false<br/>}</pre> | no | |
| 154 | +| <a name="input_redrive_allow_policy"></a> [redrive\_allow\_policy](#input\_redrive\_allow\_policy) | JSON policy to control which source queues can specify this queue as their dead-letter queue | `string` | `null` | no | |
| 155 | +| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to all resources | `map(string)` | `{}` | no | |
| 156 | + |
| 157 | +## Outputs |
| 158 | + |
| 159 | +| Name | Description | |
| 160 | +|------|-------------| |
| 161 | +| <a name="output_dlq_arn"></a> [dlq\_arn](#output\_dlq\_arn) | The ARN of the SQS dead letter queue | |
| 162 | +| <a name="output_dlq_id"></a> [dlq\_id](#output\_dlq\_id) | The URL for the created Amazon SQS dead letter queue | |
| 163 | +| <a name="output_dlq_name"></a> [dlq\_name](#output\_dlq\_name) | The name of the SQS dead letter queue | |
| 164 | +| <a name="output_dlq_url"></a> [dlq\_url](#output\_dlq\_url) | Same as `dlq_id`: The URL for the created Amazon SQS dead letter queue | |
| 165 | +| <a name="output_kms_alias_arn"></a> [kms\_alias\_arn](#output\_kms\_alias\_arn) | The Amazon Resource Name (ARN) of the KMS alias | |
| 166 | +| <a name="output_kms_alias_name"></a> [kms\_alias\_name](#output\_kms\_alias\_name) | The display name of the KMS alias | |
| 167 | +| <a name="output_kms_key_arn"></a> [kms\_key\_arn](#output\_kms\_key\_arn) | The Amazon Resource Name (ARN) of the KMS key used for encryption | |
| 168 | +| <a name="output_kms_key_id"></a> [kms\_key\_id](#output\_kms\_key\_id) | The globally unique identifier for the KMS key | |
| 169 | +| <a name="output_queue_arn"></a> [queue\_arn](#output\_queue\_arn) | The ARN of the SQS queue | |
| 170 | +| <a name="output_queue_id"></a> [queue\_id](#output\_queue\_id) | The URL for the created Amazon SQS queue | |
| 171 | +| <a name="output_queue_name"></a> [queue\_name](#output\_queue\_name) | The name of the SQS queue | |
| 172 | +| <a name="output_queue_policy"></a> [queue\_policy](#output\_queue\_policy) | The JSON policy of the SQS queue | |
| 173 | +| <a name="output_queue_url"></a> [queue\_url](#output\_queue\_url) | Same as `queue_id`: The URL for the created Amazon SQS queue | |
| 174 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
0 commit comments