Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Config Rules Just Apply in One Region #116

Open
HarleyB123 opened this issue Aug 27, 2021 · 0 comments
Open

AWS Config Rules Just Apply in One Region #116

HarleyB123 opened this issue Aug 27, 2021 · 0 comments

Comments

@HarleyB123
Copy link

When creating Config rules in this Terraform solution - they only deploy and monitor resources for compliance in the region of the AWS Provider you've specified. (Can test this by creating a non-compliant resource in another Region and checking the aggregator rules).

Indeed, this is stipulated in the docs here.

The API call to deploy rules and conformance packs across accounts is region specific. At the organization level, you need to change the context of your API call to a different region if you want to deploy rules in other regions. For example, to deploy a rule in US East (N. Virginia), change the region to US East (N. Virginia) and then call PutOrganizationConfigRule.

My suggestion is a null_resource and local-exec provisioner, like this:

resource "null_resource" "test" {
  triggers = {
    REGIONS = join(" ", [for s in var.aws_config_regions : format("%q", s)])
    RULES = join(" ", [for s in local.aws_config_rules : format("%q", s)])
  }
  provisioner "local-exec" {
    command = "for rule in $RULES; do for region in $REGIONS; do aws configservice put-organization-config-rule --organization-config-rule-name $(echo $rule | xargs) --organization-managed-rule-metadata  RuleIdentifier=$rule --region $(echo $region | xargs); done; done"
    environment = {
      REGIONS = join(" ", [for s in var.aws_config_regions : format("%q", s)])
      RULES = join(" ", [for s in local.aws_config_rules : format("%q", s)])
    }
}

but this was a quick hack, rather than a well-thought out design - so open to opinions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant