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_configuration_recorder recording_mode (Periodic recording) #35527

Conversation

chlunde
Copy link
Contributor

@chlunde chlunde commented Jan 28, 2024

Description

This PR adds recording_mode and all available properties below that, to aws_config_configuration_recorder (AWS Config), to support periodic recording.

Relations

Closes #34577

References

https://docs.aws.amazon.com/config/latest/APIReference/API_RecordingMode.html
https://docs.aws.amazon.com/config/latest/APIReference/API_RecordingModeOverride.html

Questions

The default value is recording_mode { recording_frequency = "CONTINUOUS" }. Is it correct to set recording_mode as computed to support this?

diff --git a/internal/service/configservice/configuration_recorder.go b/internal/service/configservice/configuration_recorder.go
index 5142041b99..700a6b9b4c 100644
--- a/internal/service/configservice/configuration_recorder.go
+++ b/internal/service/configservice/configuration_recorder.go
@@ -102,11 +102,13 @@ func ResourceConfigurationRecorder() *schema.Resource {
                        "recording_mode": {
                                Type:     schema.TypeList,
                                Optional: true,
+                               Computed: true,
                                MaxItems: 1,
                                Elem: &schema.Resource{
                                        Schema: map[string]*schema.Schema{
                                                "recording_frequency": {
                                                        Type:         schema.TypeString,
+                                                       Default:      configservice.RecordingFrequencyContinuous,
                                                        Optional:     true,
                                                        ValidateFunc: validation.StringInSlice(configservice.RecordingFrequency_Values(), false),
                                                },

Output from Acceptance Testing

Originally, I had issues with flaky tests, even before making any changes:

% make testacc TESTS=TestAccConfigService_serial PKG=configservice

=== RUN   TestAccConfigService_serial/RemediationConfiguration/disappears
    testing_new.go:91: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: deleting AWS Config Remediation Configuration (original-tf-acc-test-4078218256533696153): NoSuchRemediationConfigurationException: No RemediationConfiguration for rule original-tf-acc-test-4078218256533696153 exists

...

I've "fixed" it by calling delete twice as I found another test did. If you know a proper fix, please tell me. The races are there on the master branch too.

Here's a subset of the acceptance tests with this change.

$ TF_ACC=1 go test -skip '.*rgani.*' -run '.*' -v ./internal/service/configservice/
=== RUN   TestAccConfigService_serial
=== PAUSE TestAccConfigService_serial
=== RUN   TestAccConfigServiceConfigurationAggregator_account
=== PAUSE TestAccConfigServiceConfigurationAggregator_account
=== RUN   TestAccConfigServiceConfigurationAggregator_switch
    acctest.go:995: skipping tests; this AWS account must not be an existing member of an AWS Organization
--- SKIP: TestAccConfigServiceConfigurationAggregator_switch (1.54s)
=== RUN   TestAccConfigServiceConfigurationAggregator_tags
=== PAUSE TestAccConfigServiceConfigurationAggregator_tags
=== RUN   TestAccConfigServiceConfigurationAggregator_disappears
=== PAUSE TestAccConfigServiceConfigurationAggregator_disappears
=== RUN   TestEndpointConfiguration
=== RUN   TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_base_config_file
=== RUN   TestEndpointConfiguration/service_aws_envvar_overrides_service_config_file
=== RUN   TestEndpointConfiguration/base_endpoint_envvar
=== RUN   TestEndpointConfiguration/base_endpoint_config_file
=== RUN   TestEndpointConfiguration/package_name_endpoint_config_overrides_alias_name_0_config
=== RUN   TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_base_envvar
=== RUN   TestEndpointConfiguration/service_aws_envvar_overrides_base_envvar
=== RUN   TestEndpointConfiguration/service_aws_envvar_overrides_base_config_file
=== RUN   TestEndpointConfiguration/base_endpoint_envvar_overrides_service_config_file
=== RUN   TestEndpointConfiguration/base_endpoint_envvar_overrides_base_config_file
=== RUN   TestEndpointConfiguration/service_config_file_overrides_base_config_file
=== RUN   TestEndpointConfiguration/package_name_endpoint_config_overrides_service_config_file
=== RUN   TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_aws_service_envvar
=== RUN   TestEndpointConfiguration/package_name_endpoint_config_overrides_aws_service_envvar
=== RUN   TestEndpointConfiguration/package_name_endpoint_config_overrides_base_envvar
=== RUN   TestEndpointConfiguration/service_config_file
=== RUN   TestEndpointConfiguration/no_config
=== RUN   TestEndpointConfiguration/package_name_endpoint_config
=== RUN   TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_service_config_file
=== RUN   TestEndpointConfiguration/service_aws_envvar
=== RUN   TestEndpointConfiguration/package_name_endpoint_config_overrides_base_config_file
=== RUN   TestEndpointConfiguration/alias_name_0_endpoint_config
--- PASS: TestEndpointConfiguration (0.60s)
    --- PASS: TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_base_config_file (0.04s)
    --- PASS: TestEndpointConfiguration/service_aws_envvar_overrides_service_config_file (0.02s)
    --- PASS: TestEndpointConfiguration/base_endpoint_envvar (0.02s)
    --- PASS: TestEndpointConfiguration/base_endpoint_config_file (0.02s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_alias_name_0_config (0.03s)
    --- PASS: TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_base_envvar (0.03s)
    --- PASS: TestEndpointConfiguration/service_aws_envvar_overrides_base_envvar (0.02s)
    --- PASS: TestEndpointConfiguration/service_aws_envvar_overrides_base_config_file (0.02s)
    --- PASS: TestEndpointConfiguration/base_endpoint_envvar_overrides_service_config_file (0.02s)
    --- PASS: TestEndpointConfiguration/base_endpoint_envvar_overrides_base_config_file (0.02s)
    --- PASS: TestEndpointConfiguration/service_config_file_overrides_base_config_file (0.02s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_service_config_file (0.03s)
    --- PASS: TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_aws_service_envvar (0.03s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_aws_service_envvar (0.03s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_base_envvar (0.03s)
    --- PASS: TestEndpointConfiguration/service_config_file (0.02s)
    --- PASS: TestEndpointConfiguration/no_config (0.02s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config (0.03s)
    --- PASS: TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_service_config_file (0.03s)
    --- PASS: TestEndpointConfiguration/service_aws_envvar (0.02s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_base_config_file (0.03s)
    --- PASS: TestEndpointConfiguration/alias_name_0_endpoint_config (0.03s)
=== CONT  TestAccConfigService_serial
=== CONT  TestAccConfigServiceConfigurationAggregator_tags
=== RUN   TestAccConfigService_serial/ConfigurationRecorder
=== CONT  TestAccConfigServiceConfigurationAggregator_disappears
=== RUN   TestAccConfigService_serial/ConfigurationRecorder/recordStrategy
=== CONT  TestAccConfigServiceConfigurationAggregator_account
--- PASS: TestAccConfigServiceConfigurationAggregator_disappears (20.99s)
--- PASS: TestAccConfigServiceConfigurationAggregator_account (23.92s)
=== RUN   TestAccConfigService_serial/ConfigurationRecorder/disappears
--- PASS: TestAccConfigServiceConfigurationAggregator_tags (50.78s)
=== RUN   TestAccConfigService_serial/ConfigurationRecorder/basic
=== RUN   TestAccConfigService_serial/ConfigurationRecorder/allParams
--- PASS: TestAccConfigService_serial (141.55s)
    --- PASS: TestAccConfigService_serial/ConfigurationRecorder (141.55s)
        --- PASS: TestAccConfigService_serial/ConfigurationRecorder/recordStrategy (36.65s)
        --- PASS: TestAccConfigService_serial/ConfigurationRecorder/disappears (36.09s)
        --- PASS: TestAccConfigService_serial/ConfigurationRecorder/basic (35.80s)
        --- PASS: TestAccConfigService_serial/ConfigurationRecorder/allParams (33.01s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/configservice	149.387s

Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/configservice Issues and PRs that pertain to the configservice service. labels Jan 28, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 28, 2024
@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Jan 29, 2024
@chlunde chlunde force-pushed the f_aws_config_configuration_recorder_recording_mode branch from 43c2884 to 85806e7 Compare February 16, 2024 21:54
…handle default

Default value is

	recording_mode { recording_frequency = "CONTINUOUS" }
Tests sometimes fail with:

	=== RUN   TestAccConfigService_serial/ConfigRule/disappears
	    testing_new.go:91: Error running post-test destroy, there may be dangling resources: exit status 1

		Error: deleting AWS Config Config Rule (tf-acc-test-115006365829579325): NoSuchConfigRuleException: The ConfigRule 'tf-acc-test-115006365829579325' provided in the request is invalid. Please check the configRule name.
Test recording_mode_overrides in testAccConfigurationRecorder_allParams.

Call acctest.CheckResourceDisappears twice as some other tests do to prevent flaky tests.

Fix lint issue.
@chlunde chlunde force-pushed the f_aws_config_configuration_recorder_recording_mode branch from 85806e7 to 23afa70 Compare February 16, 2024 22:29
@chlunde chlunde marked this pull request as ready for review February 17, 2024 08:37
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccConfigService_serial/ConfigurationRecorder$$' PKG=configservice
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/configservice/... -v -count 1 -parallel 20  -run=TestAccConfigService_serial/ConfigurationRecorder$ -timeout 360m
=== RUN   TestAccConfigService_serial
=== PAUSE TestAccConfigService_serial
=== CONT  TestAccConfigService_serial
=== RUN   TestAccConfigService_serial/ConfigurationRecorder
=== RUN   TestAccConfigService_serial/ConfigurationRecorder/basic
=== RUN   TestAccConfigService_serial/ConfigurationRecorder/allParams
=== RUN   TestAccConfigService_serial/ConfigurationRecorder/recordStrategy
=== RUN   TestAccConfigService_serial/ConfigurationRecorder/disappears
--- PASS: TestAccConfigService_serial (114.05s)
    --- PASS: TestAccConfigService_serial/ConfigurationRecorder (114.05s)
        --- PASS: TestAccConfigService_serial/ConfigurationRecorder/basic (31.14s)
        --- PASS: TestAccConfigService_serial/ConfigurationRecorder/allParams (25.90s)
        --- PASS: TestAccConfigService_serial/ConfigurationRecorder/recordStrategy (30.54s)
        --- PASS: TestAccConfigService_serial/ConfigurationRecorder/disappears (26.47s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/configservice	125.311s

@ewbankkit
Copy link
Contributor

@chlunde Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit ac2a5b5 into hashicorp:main Feb 20, 2024
43 checks passed
@github-actions github-actions bot added this to the v5.38.0 milestone Feb 20, 2024
@chlunde chlunde deleted the f_aws_config_configuration_recorder_recording_mode branch February 20, 2024 18:29
Copy link

This functionality has been released in v5.38.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this pull request 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 related to this change, 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 Mar 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/configservice Issues and PRs that pertain to the configservice service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: Config recorder - Periodic recording
4 participants