Skip to content

Commit 7b569ec

Browse files
committed
feat: changing the logic for the account target
1 parent 7e1ddd4 commit 7b569ec

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ This module provides a simple way to deploy a CloudFormation stack to multiple a
2929
| <a name="input_name"></a> [name](#input\_name) | The name of the cloudformation stack | `string` | n/a | yes |
3030
| <a name="input_tags"></a> [tags](#input\_tags) | The tags to apply to the cloudformation stack | `map(string)` | n/a | yes |
3131
| <a name="input_template"></a> [template](#input\_template) | The body of the cloudformation template to deploy | `string` | n/a | yes |
32+
| <a name="input_accounts"></a> [accounts](#input\_accounts) | A list of account IDs used as a target | `list(string)` | `null` | no |
3233
| <a name="input_call_as"></a> [call\_as](#input\_call\_as) | Specifies whether you are acting as an account administrator in the organization's management account or as a delegated administrator in a member account | `string` | `"SELF"` | no |
3334
| <a name="input_capabilities"></a> [capabilities](#input\_capabilities) | The capabilities required to deploy the cloudformation template | `list(string)` | <pre>[<br/> "CAPABILITY_NAMED_IAM",<br/> "CAPABILITY_AUTO_EXPAND",<br/> "CAPABILITY_IAM"<br/>]</pre> | no |
35+
| <a name="input_enable_exclude"></a> [enable\_exclude](#input\_enable\_exclude) | Indicates the accounts list will be used as an exclusion list | `bool` | `false` | no |
3436
| <a name="input_enabled_regions"></a> [enabled\_regions](#input\_enabled\_regions) | The regions to deploy the cloudformation stack to (if empty, deploys to current region) | `list(string)` | `null` | no |
35-
| <a name="input_exclude_accounts"></a> [exclude\_accounts](#input\_exclude\_accounts) | A list of account IDs to exclude from the deployment | `list(string)` | `null` | no |
3637
| <a name="input_failure_tolerance_count"></a> [failure\_tolerance\_count](#input\_failure\_tolerance\_count) | The number of failures that are tolerated before the stack operation is stopped | `number` | `0` | no |
3738
| <a name="input_max_concurrent_count"></a> [max\_concurrent\_count](#input\_max\_concurrent\_count) | The maximum number of concurrent deployments | `number` | `10` | no |
3839
| <a name="input_organizational_units"></a> [organizational\_units](#input\_organizational\_units) | The organizational units to deploy the stackset to | `list(string)` | `[]` | no |

main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ resource "aws_cloudformation_stack_set_instance" "ou" {
4040
stack_set_name = aws_cloudformation_stack_set.stackset.name
4141

4242
deployment_targets {
43-
accounts = var.exclude_accounts
44-
account_filter_type = var.exclude_accounts != null ? "DIFFERENCE" : null
43+
accounts = var.accounts
44+
account_filter_type = var.accounts != null && var.enable_exclude ? "DIFFERENCE" : null
4545
organizational_unit_ids = [each.value.organization_unit]
4646
}
4747

tests/module.tftest.hcl

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ run "exclude_accounts" {
3333
tags = {}
3434
template = ""
3535
parameters = {}
36-
exclude_accounts = [
36+
accounts = [
3737
"123456789012",
3838
"123456789013"
3939
]
40+
enable_exclude = true
4041
}
4142
}
4243

variables.tf

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@ variable "enabled_regions" {
2727
default = null
2828
}
2929

30-
variable "exclude_accounts" {
31-
description = "A list of account IDs to exclude from the deployment"
30+
variable "accounts" {
31+
description = "A list of account IDs used as a target"
3232
type = list(string)
3333
default = null
3434
}
3535

36+
variable "enable_exclude" {
37+
description = "Indicates the accounts list will be used as an exclusion list"
38+
type = bool
39+
default = false
40+
}
41+
3642
variable "description" {
3743
description = "The description of the cloudformation stack"
3844
type = string

0 commit comments

Comments
 (0)