Visitar URL original
test: Add required cloud tags to AWS resources in acceptance tests by marcabreracast · Pull Request #4763 · mongodb/terraform-provider-mongodbatlas · GitHub
Skip to content

test: Add required cloud tags to AWS resources in acceptance tests - #4763

Open
marcabreracast wants to merge 5 commits into
masterfrom
CLOUDP-441536-tag-test-cloud-resources
Open

marcabreracast wants to merge 5 commits into
masterfrom
CLOUDP-441536-tag-test-cloud-resources

Conversation

@marcabreracast

@marcabreracast marcabreracast commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The upcoming Cloud Tag Policy requires mongodb-owner and mongodb-env tags on AWS resources. Our acceptance tests create AWS resources (IAM roles, S3 buckets, VPCs, etc.), so these tests would start failing once enforcement begins.

This PR tags all AWS resources created by acceptance tests by adding a provider "aws" block with default_tags to the test configs that don't already define one. Tag values come from the MONGODB_TAG_OWNER / MONGODB_TAG_ENV env vars, defaulting to the team email and test for local runs.

Link to any related issue(s): CLOUDP-441536

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fix and verified my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

TestAccEncryptionAtRest_basicAWS is skipped in CI, and was executed locally to verify it's working as expected:

=== RUN   TestAccEncryptionAtRest_basicAWS
    resource_test.go:30: Creating execution project (1): test-acc-tf-p-5804668935439766599
--- PASS: TestAccEncryptionAtRest_basicAWS (82.61s)
PASS

The mongodbatlas_log_integration S3 bucket case (ignore_changes = [tags, tags_all]) was verified with a live repro: default tags are applied at bucket creation and follow-up plans show no drift. Additionally, acceptance tests are also passing locally:

--- PASS: TestAccLogIntegration_basicS3 (97.31s)
PASS

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The shared configuration is valid and consistently covers all acceptance-test AWS resource definitions.

Review effort: Balanced
Findings: None

What changed in this PR

Adds mandatory AWS cloud tags to acceptance-test resources through shared provider configuration helpers.

Changes:

  • Adds configurable mongodb-owner and mongodb-env default tags.
  • Applies tagged AWS provider configuration across affected acceptance tests.
  • Preserves existing provider settings such as regions and credentials.
File Description
internal/​testutil/​acc/​provider.go Adds shared AWS default-tag helpers.
internal/​testutil/​acc/​encryption_at_rest.go Tags AWS IAM resources.
internal/​serviceapi/​pushbasedlogexportapi/​resource_test.go Tags IAM and S3 resources.
internal/​serviceapi/​logintegration/​resource_test.go Tags IAM and S3 resources.
internal/​service/​streamconnection/​resource_stream_connection_test.go Tags AWS access roles.
internal/​service/​pushbasedlogexport/​resource_test.go Tags IAM and S3 resources.
internal/​service/​privatelinkendpointservice/​resource_test.go Adds tags to the existing AWS provider.
internal/​service/​privateendpointregionalmode/​resource_private_endpoint_regional_mode_test.go Tags networking resources.
internal/​service/​federatedquerylimit/​resource_federated_query_limit_test.go Tags AWS IAM resources.
internal/​service/​federateddatabaseinstance/​resource_federated_database_instance_test.go Tags IAM, VPC, subnet, and endpoint resources.
internal/​service/​federateddatabaseinstance/​data_source_federated_database_instances_test.go Tags plural data-source test resources.
internal/​service/​federateddatabaseinstance/​data_source_federated_database_instance_test.go Tags singular data-source test resources.
internal/​service/​cluster/​resource_cluster_test.go Adds tags to existing AWS provider configurations.
internal/​service/​cloudprovideraccess/​resource_cloud_provider_access_authorization_test.go Tags cloud-access IAM resources.
internal/​service/​cloudbackupsnapshotexportjob/​resource_cloud_backup_snapshot_export_job_test.go Tags export-job AWS resources.
internal/​service/​cloudbackupsnapshotexportbucket/​resource_cloud_backup_snapshot_export_bucket_test.go Tags export-bucket IAM resources.
internal/​service/​cloudbackupschedule/​resource_cloud_backup_schedule_test.go Tags backup export resources.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@marcabreracast

marcabreracast commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

Heads-up for reviewers: the CI acceptance test failures are expected for now. The tests now tag the AWS resources they create (required by the Cloud Tag Policy), but the CI users don't yet have tagging permissions, tracked in CLOUDP-451854. Looking for early feedback on the approach in the meantime, and won't merge until the permissions are in place and the tests run green.

@marcabreracast
marcabreracast marked this pull request as ready for review September 30, 2026 10:22
@marcabreracast
marcabreracast requested a review from a team as a code owner September 30, 2026 10:22
@marcabreracast
marcabreracast added this pull request to stack #4775 September 30, 2026 10:23
@augmentcode

augmentcode Bot commented Sep 30, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR prepares AWS-backed acceptance tests for the upcoming Cloud Tag Policy.

Changes:

  • Adds shared helpers that emit AWS provider default_tags, sourcing owner/environment values from MONGODB_TAG_OWNER and MONGODB_TAG_ENV.
  • Uses team-email and test defaults for local runs when those variables are unset.
  • Applies the tagged provider configuration to acceptance-test templates creating AWS IAM, S3, VPC, PrivateLink, and related resources.
  • Extends existing explicit AWS provider blocks with the same default-tag configuration while preserving their credentials and region settings.
Technical Notes: The change centralizes tag generation so all updated test configs use consistent mandatory tags; CI tagging-permission failures are expected until the tracked access update is deployed.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Comment thread internal/testutil/acc/provider.go Outdated
Comment on lines +19 to +22
tagOwnerEnvVar = "MONGODB_TAG_OWNER"
tagEnvEnvVar = "MONGODB_TAG_ENV"
defaultTagOwner = "api-experience-integrations-team@mongodb.com"
defaultTagEnv = "test"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I assume we are fine with having same tag values for both CI and local test runs? should we add MONGODB_TAG_OWNER and MONGODB_TAG_ENV as GH secrets/variables? and use the env vars in https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/.github/workflows/acceptance-tests.yml?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, addressed in 4f752f1

if v := os.Getenv(envVar); v != "" {
return v
}
if os.Getenv("TF_ACC") == "" {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Without TF_ACC, configs are constructed but never applied, so return a placeholder to keep unit tests independent of the tag env vars. With TF_ACC=1, fail fast when the variable is unset.

@marcabreracast
marcabreracast force-pushed the CLOUDP-441536-tag-test-cloud-resources branch from 4f752f1 to 992288a Compare September 30, 2026 13:50
@svc-apix-Bot

Copy link
Copy Markdown
Contributor

This PR has gone 7 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 7 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

@marcabreracast marcabreracast added the not_stale Not stale issue or PR label Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not_stale Not stale issue or PR stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants