Skip to content

Commit

Permalink
create nothing if len(statements) == 0 (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocode authored May 18, 2021
1 parent e9fd1de commit de13762
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ Like this project? Please give it a ★ on [our GitHub](https://github.com/cloud
Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =)



## Related Projects

Check out these related projects.
Expand All @@ -234,8 +235,6 @@ Check out these related projects.
- [terraform-yaml-config](https://github.com/cloudposse/terraform-yaml-config) - Terraform module to convert local and remote YAML configuration templates into Terraform lists and maps.




## References

For additional context, refer to some of these links.
Expand Down
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ data "aws_iam_policy_document" "this" {
}

resource "aws_organizations_policy" "this" {
count = module.this.enabled ? 1 : 0
count = module.this.enabled && length(local.statements) > 0 ? 1 : 0
name = module.this.id
description = var.service_control_policy_description
content = local.service_control_policy_json
tags = module.this.tags
}

resource "aws_organizations_policy_attachment" "this" {
count = module.this.enabled ? 1 : 0
count = module.this.enabled && length(local.statements) > 0 ? 1 : 0
policy_id = join("", aws_organizations_policy.this.*.id)
target_id = var.target_id
}

0 comments on commit de13762

Please sign in to comment.