Skip to content

Commit

Permalink
fix(alternate_contacts): refactoring and removal of unneeded datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
Claus-Theodor Riegg authored and crigertg committed Mar 29, 2023
1 parent 623b58f commit 01a9ece
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion modules/alternate_contacts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ No modules.
| [aws_account_alternate_contact.operations_member_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/account_alternate_contact) | resource |
| [aws_account_alternate_contact.security](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/account_alternate_contact) | resource |
| [aws_account_alternate_contact.security_member_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/account_alternate_contact) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_organizations_organization.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/organizations_organization) | data source |

## Inputs
Expand Down
4 changes: 0 additions & 4 deletions modules/alternate_contacts/data.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
data "aws_organizations_organization" "this" {
count = var.assign_contacts_to_all_accounts ? 1 : 0
}

data "aws_caller_identity" "current" {
count = var.assign_contacts_to_all_accounts ? 0 : 1
}
6 changes: 3 additions & 3 deletions modules/alternate_contacts/locals.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
operations_contact = var.operations_contact != null ? var.operations_contact : var.default_alternate_contact
billing_contact = var.billing_contact != null ? var.billing_contact : var.default_alternate_contact
security_contact = var.security_contact != null ? var.security_contact : var.default_alternate_contact
operations_contact = merge(var.default_alternate_contact, var.operations_contact)
billing_contact = merge(var.default_alternate_contact, var.billing_contact)
security_contact = merge(var.default_alternate_contact, var.security_contact)

list_of_active_account_ids = var.assign_contacts_to_all_accounts ? [for account in data.aws_organizations_organization.this[0].non_master_accounts : account.id if account.status == "ACTIVE"] : null

Expand Down

0 comments on commit 01a9ece

Please sign in to comment.