Skip to content

Commit

Permalink
feat: added ability to use more than one account for adding sqs subsc… (
Browse files Browse the repository at this point in the history
#15)

…riptions

## Description
<!--- Describe your changes in detail -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## Breaking Changes
<!-- Does this break backwards compatibility with the current major
version? -->
<!-- If so, please provide an explanation why it is necessary. -->

## How Has This Been Tested?
- [ ] I have updated at least one of the `examples/*` to demonstrate and
validate my change(s)
- [ ] I have tested and validated these changes using one or more of the
provided `examples/*` projects
<!--- Users should start with an existing example as its written, deploy
it, then check their changes against it -->
<!--- This will highlight breaking/disruptive changes. Once you have
checked, deploy your changes to verify -->
<!--- Please describe how you tested your changes -->
- [ ] I have executed `pre-commit run -a` on my pull request
<!--- Please see
https://github.com/antonbabenko/pre-commit-terraform#how-to-install for
how to install -->
  • Loading branch information
applike-ss authored Aug 9, 2023
1 parent 8fe75fe commit f661c25
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Terraform module which creates a sqs queue
| <a name="input_organizational_unit"></a> [organizational\_unit](#input\_organizational\_unit) | Usually used to indicate the AWS organizational unit, e.g. 'prod', 'sdlc' | `string` | `null` | no |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
| <a name="input_subscription"></a> [subscription](#input\_subscription) | The subscription details such as topic name and filter policy. | <pre>map(object({<br> topic_name = string<br> filter_policy = optional(string)<br> }))</pre> | `{}` | no |
| <a name="input_subscription"></a> [subscription](#input\_subscription) | The subscription details such as topic name and filter policy. | <pre>map(object({<br> aws_account_id = optional(string)<br> topic_name = string<br> filter_policy = optional(string)<br> }))</pre> | `{}` | no |
| <a name="input_subscription_aws_account_id"></a> [subscription\_aws\_account\_id](#input\_subscription\_aws\_account\_id) | The AWS account ID for the subscription. | `string` | `null` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module "sqs" {

resource "aws_sns_topic_subscription" "default" {
for_each = var.subscription
topic_arn = "arn:aws:sns:${module.this.aws_region}:${var.subscription_aws_account_id}:${each.value.topic_name}"
topic_arn = "arn:aws:sns:${module.this.aws_region}:${each.value.aws_account_id != null ? each.value.aws_account_id : var.subscription_aws_account_id}:${each.value.topic_name}"
confirmation_timeout_in_minutes = "1"
endpoint_auto_confirms = "false"
protocol = "sqs"
Expand Down
5 changes: 3 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ variable "message_retention_seconds" {

variable "subscription" {
type = map(object({
topic_name = string
filter_policy = optional(string)
aws_account_id = optional(string)
topic_name = string
filter_policy = optional(string)
}))
description = "The subscription details such as topic name and filter policy."
default = {}
Expand Down

0 comments on commit f661c25

Please sign in to comment.