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

Disable an aws_securityhub_standards_control and then enable it #31168

Closed
humiaochao opened this issue Jun 1, 2022 · 2 comments
Closed

Disable an aws_securityhub_standards_control and then enable it #31168

humiaochao opened this issue Jun 1, 2022 · 2 comments
Labels
bug new new issue not yet triaged

Comments

@humiaochao
Copy link

humiaochao commented Jun 1, 2022

Update:

I find similar issue here: hashicorp/terraform-provider-aws#20434

Currently my workaround solution is to use terraform apply -replace="aws_securityhub_standards_control.disable_instances_managed_by_amazon_systems_manager" instead of terraform apply

I think this issue can be closed since https://github.com/hashicorp/terraform-provider-aws/ might be more suitable for this kind of issue.


Terraform Version

Terraform v1.1.2
on windows_amd64

  • provider registry.terraform.io/hashicorp/aws v4.9.0

Terraform Configuration Files

Step 1: Execute following code first to disable a specific standard control in Security Hub (here I take SSM.1 as example):

resource "aws_securityhub_standards_control" "disable_instances_managed_by_amazon_systems_manager" {
standards_control_arn = "arn:aws:securityhub:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:control/aws-foundational-security-best-practices/v/1.0.0/SSM.1"
control_status = "DISABLED"
disabled_reason = "XXXXX"
}

Step 2: Then modify the above code as follows (control_status -> Enabled , remove disabled_reason):

resource "aws_securityhub_standards_control" "disable_instances_managed_by_amazon_systems_manager" {
standards_control_arn = "arn:aws:securityhub:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:control/aws-foundational-security-best-practices/v/1.0.0/SSM.1"
control_status = "ENABLED"
}

Expected Behavior

I expect the specific standard control should be enabled after executing Step 2

Actual Behavior

When executing Step 2, it return a error:

error updating Security Hub Standards Control (arn:aws:securityhub:ap-northeast-2:111111111111:control/aws-foundational-security-best-practices/v/1.0.0/SSM.1): InvalidInputException: DisabledReason should not be given for action other than disabling control: arn:aws:securityhub:ap-northeast-2:111111111111:control/aws-foundational-security-best-practices/v/1.0.0/SSM.1

Steps to Reproduce

Step 1: Execute following codes to disable a specific standard control in SecurityHub (here I take SSM.1 as example):

resource "aws_securityhub_standards_control" "disable_instances_managed_by_amazon_systems_manager" {
standards_control_arn = "arn:aws:securityhub:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:control/aws-foundational-security-best-practices/v/1.0.0/SSM.1"
control_status = "DISABLED"
disabled_reason = "XXXXX"
}

Step 2: After executing codes in Step 1, modify the code as follows (control_status -> Enabled , remove disabled_reason)

resource "aws_securityhub_standards_control" "disable_instances_managed_by_amazon_systems_manager" {
standards_control_arn = "arn:aws:securityhub:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:control/aws-foundational-security-best-practices/v/1.0.0/SSM.1"
control_status = "ENABLED"
}

When executing Step 2, it return a error:

error updating Security Hub Standards Control (arn:aws:securityhub:ap-northeast-2:111111111111:control/aws-foundational-security-best-practices/v/1.0.0/SSM.1): InvalidInputException: DisabledReason should not be given for action other than disabling control: arn:aws:securityhub:ap-northeast-2:111111111111:control/aws-foundational-security-best-practices/v/1.0.0/SSM.1

@humiaochao humiaochao added bug new new issue not yet triaged labels Jun 1, 2022
@humiaochao
Copy link
Author

Update:

I find similar issue here: hashicorp/terraform-provider-aws#20434

Currently my workaround solution is to use terraform apply -replace="aws_securityhub_standards_control.disable_instances_managed_by_amazon_systems_manager" instead of terraform apply

I think this issue can be closed since https://github.com/hashicorp/terraform-provider-aws/ might be more suitable for this kind of issue.

@github-actions
Copy link

github-actions bot commented Jul 2, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

1 participant