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

fix: add enabled_standard_arns if service_enabled is true in aws_securityhub_configuration_policy #36740

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/36740.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_securityhub_configuration_policy: Mark `configuration_policy.enabled_standard_arns` as Optional, fixing `InvalidInputException: Invalid semantics: Enabled standards and security control configurations must be configured when Security Hub is enabled` errors
```
12 changes: 7 additions & 5 deletions internal/service/securityhub/configuration_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func resourceConfigurationPolicy() *schema.Resource {
Schema: map[string]*schema.Schema{
"enabled_standard_arns": {
Type: schema.TypeSet,
Required: true,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: verify.ValidARN,
Expand Down Expand Up @@ -432,12 +432,14 @@ func expandPolicyMemberSecurityHub(tfMap map[string]interface{}) *types.PolicyMe
SecurityControlsConfiguration: expandSecurityControlsConfiguration(tfMap["security_controls_configuration"]),
}

if v, ok := tfMap["enabled_standard_arns"].(*schema.Set); ok && v.Len() > 0 {
apiObject.EnabledStandardIdentifiers = flex.ExpandStringValueSet(v)
}

if v, ok := tfMap["service_enabled"].(bool); ok {
apiObject.ServiceEnabled = aws.Bool(v)

if v {
if v, ok := tfMap["enabled_standard_arns"].(*schema.Set); ok {
apiObject.EnabledStandardIdentifiers = flex.ExpandStringValueSet(v)
}
}
}

return &types.PolicyMemberSecurityHub{
Expand Down
3 changes: 1 addition & 2 deletions internal/service/securityhub/configuration_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ resource "aws_securityhub_configuration_policy" "test" {
description = %[2]q

configuration_policy {
service_enabled = false
enabled_standard_arns = []
service_enabled = false
}

depends_on = [aws_securityhub_organization_configuration.test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ resource "aws_securityhub_configuration_policy" "disabled" {
description = "This is an example of disabled configuration policy"

configuration_policy {
service_enabled = false
enabled_standard_arns = []
service_enabled = false
}

depends_on = [aws_securityhub_organization_configuration.example]
Expand Down Expand Up @@ -130,7 +129,7 @@ This resource supports the following arguments:

The `configuration_policy` block supports the following:

* `enabled_standard_arns` - (Required) A list that defines which security standards are enabled in the configuration policy.
* `enabled_standard_arns` - (Optional) A list that defines which security standards are enabled in the configuration policy. It must be defined if `service_enabled` is set to true.
* `security_controls_configuration` - (Optional) Defines which security controls are enabled in the configuration policy and any customizations to parameters affecting them. See [below](#security_controls_configuration).
* `service_enabled` - (Required) Indicates whether Security Hub is enabled in the policy.

Expand Down
Loading