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

Security Hub throws ResourceConflictException for "master" accounts #110

Closed
gws opened this issue May 29, 2020 · 4 comments · Fixed by #111
Closed

Security Hub throws ResourceConflictException for "master" accounts #110

gws opened this issue May 29, 2020 · 4 comments · Fixed by #111
Labels
bug Something isn't working question Further information is requested

Comments

@gws
Copy link

gws commented May 29, 2020

Hi there,

Upgrading to 0.18.0, I had an issue with my account set up in the following way (some variables redacted, let me know if they are important):

module "secure_baseline" {
  source  = "nozaq/secure-baseline/aws"
  version = "0.18.0"

  aws_account_id                         = "..."
  region                                 = "..."
  account_type                           = "master"
  audit_log_bucket_name                  = "..."
  config_sns_topic_name                  = "..."
  cloudwatch_logs_retention_in_days      = "7"
  cloudtrail_name                        = "multi-region"
  cloudtrail_iam_role_name               = "..."
  cloudtrail_iam_role_policy_name        = "..."
  cloudtrail_key_deletion_window_in_days = "7"
  support_iam_role_principal_arns        = [...]

  target_regions = ["us-west-2"]
}

I received an exception like the following for each region even though I only had a single region in target_regions:

Error: Error enabling Security Hub for account: ResourceConflictException: Account is already subscribed to Security Hub
{
  Code_: "ResourceConflictException",
  Message_: "Account is already subscribed to Security Hub"
}

  on .terraform/modules/secure_baseline/terraform-aws-secure-baseline-0.18.0/modules/securityhub-baseline/main.tf line 4, in resource "aws_securityhub_account" "main":
   4: resource "aws_securityhub_account" "main" {



Error: Error enabling Security Hub for account: ResourceConflictException: Account is already subscribed to Security Hub
{
  Code_: "ResourceConflictException",
  Message_: "Account is already subscribed to Security Hub"
}

  on .terraform/modules/secure_baseline/terraform-aws-secure-baseline-0.18.0/modules/securityhub-baseline/main.tf line 4, in resource "aws_securityhub_account" "main":
   4: resource "aws_securityhub_account" "main" {

...

It appears to be related to #105.

@nozaq nozaq added question Further information is requested bug Something isn't working labels May 31, 2020
nozaq added a commit that referenced this issue May 31, 2020
@nozaq
Copy link
Owner

nozaq commented May 31, 2020

Hi @gws, thank you for reporting this issue.
It seems the problem is that the module tried to enable SecurityHub in regions not in target_regions.
The ResourceConflictException happened because the AWS providers for excluded regions all fall back to the default one, so multiple SecurityHub activation calls went to the same default region.

I'm trying to fix it in #111, and hopefully will publish 0.18.1 soon!

@nozaq nozaq reopened this May 31, 2020
@nozaq
Copy link
Owner

nozaq commented May 31, 2020

Just published a fix.

@gws Could you try check if 0.18.1 does not produce errors on your side? 🙏

@gws
Copy link
Author

gws commented May 31, 2020

@nozaq Works great with 0.18.1, thank you!

@nozaq
Copy link
Owner

nozaq commented May 31, 2020

@gws You're welcome, thanks for your report 👍

@nozaq nozaq closed this as completed May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants