Skip to content

Commit

Permalink
[datadog_integration_aws_account] Fix panic when resources_config is …
Browse files Browse the repository at this point in the history
…omitted (#2749)
  • Loading branch information
ktmq authored Jan 3, 2025
1 parent 83b31f6 commit cc1920f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions datadog/fwprovider/resource_datadog_integration_aws_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var (
authConfigRolePath = authConfigPath.AtName("aws_auth_config_role")
xrayServicesConfigPath = path.MatchRoot("traces_config").AtName("xray_services")
lambdaForwarderPath = path.MatchRoot("logs_config").AtName("lambda_forwarder")
resourcesConfigPath = path.MatchRoot("resources_config")
)

type integrationAwsAccountResource struct {
Expand Down Expand Up @@ -176,6 +177,9 @@ func (r *integrationAwsAccountResource) ConfigValidators(ctx context.Context) []
xrayServicesConfigPath.AtName("include_all"),
xrayServicesConfigPath.AtName("include_only"),
),
resourcevalidator.ExactlyOneOf(
resourcesConfigPath,
),
}
}

Expand Down Expand Up @@ -859,11 +863,13 @@ func buildRequestMetricsConfig(ctx context.Context, state *integrationAwsAccount
func buildRequestResourcesConfig(state *integrationAwsAccountModel) datadogV2.AWSResourcesConfig {
var resourcesConfig datadogV2.AWSResourcesConfig

if !state.ResourcesConfig.CloudSecurityPostureManagementCollection.IsNull() {
resourcesConfig.SetCloudSecurityPostureManagementCollection(state.ResourcesConfig.CloudSecurityPostureManagementCollection.ValueBool())
}
if !state.ResourcesConfig.ExtendedCollection.IsNull() {
resourcesConfig.SetExtendedCollection(state.ResourcesConfig.ExtendedCollection.ValueBool())
if state.ResourcesConfig != nil {
if !state.ResourcesConfig.CloudSecurityPostureManagementCollection.IsNull() {
resourcesConfig.SetCloudSecurityPostureManagementCollection(state.ResourcesConfig.CloudSecurityPostureManagementCollection.ValueBool())
}
if !state.ResourcesConfig.ExtendedCollection.IsNull() {
resourcesConfig.SetExtendedCollection(state.ResourcesConfig.ExtendedCollection.ValueBool())
}
}

return resourcesConfig
Expand Down

0 comments on commit cc1920f

Please sign in to comment.