Skip to content

feat: Add azure attributes in federated database instance resource #3484

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

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

marcabreracast
Copy link

@marcabreracast marcabreracast commented Jul 9, 2025

Description

  • Adds azure to cloud-provider config in federated_database_instance
  • Refactored out the cloud_provider_access setup for Azure to acc.cloud_provider_access.go
  • There is already a migration test for empty CloudProvider config, so decided not to include an extra migration test.

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

Follow up Work

  1. Implement data source and refactor tests to run together with resource.
  2. Add documentation

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 fmt and formatted 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.

@@ -63,7 +63,7 @@ func Resource() *schema.Resource {
"aws": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Optional: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Investigation notes:

  1. cloud_provider_config (parent attribute) is not required in the create operation and is not returned from the API when it is not set. However, the attribute is already marked as Optional+Computed, so keeping it as is to allow no-op when the attribute is removed.
  2. aws changing from required to optional to allow azure usage

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

This information: Changing from required to optional to allow azure usage I would keep only as a PR comment.
Later after this is merged it will be no surprise to find this as optional.

return nil
}

// test_s3_bucket is not part of the API response
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we might need to pass the d *schema.ResourceData as before, as the tests are showing that this comment is still valid :/

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

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

We need to add:

          AZURE_ATLAS_APP_ID: ${{ inputs.azure_atlas_app_id }}
          AZURE_SERVICE_PRINCIPAL_ID: ${{ inputs.azure_service_principal_id }}
          AZURE_TENANT_ID: ${{ inputs.azure_tenant_id }}

Here: MONGODB_ATLAS_FEDERATION_SETTINGS_ID: ${{ inputs.mongodb_atlas_federation_settings_id }} so the test can use Azure in CI

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

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

Looks like we need to update the schema of the data sources too. Due to this failing tests:
https://github.com/mongodb/terraform-provider-mongodbatlas/actions/runs/16174869633/job/45657910272#step:5:91

github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).Set(0xc001192750, {0x2d7628f, 0x15}, {0x2619600, 0xc001a8eff0})
	/home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource_data.go:238 +0x2b2
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/federateddatabaseinstance.dataSourceMongoDBAtlasFederatedDatabaseInstanceRead({0x3197340, 0xc00057e150}, 0xc001192750, {0x2864b80?, 0xc001b6d740?})
	/home/runner/work/terraform-provider-mongodbatlas/terraform-provider-mongodbatlas/internal/service/federateddatabaseinstance/data_source_federated_database_instance.go:336 +0x78d

"azure": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Copy link
Collaborator

@EspenAlbert EspenAlbert Jul 11, 2025

Choose a reason for hiding this comment

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

All the nested fields starting from cloud_provider_config can be Computed only.
Also, please refactor out the schema for cloud_provider_config and use it in the plural data source too.
Bonus, you can even use it for the resource, with an isDatasource argument

@@ -53,6 +53,7 @@ func Resource() *schema.Resource {
Type: schema.TypeString,
},
},
// attribute not required in the create operation and not returned from the API when it is not set.
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] Start with uppercase
[nit] A lot of not, maybe it can be written clearer?

For example, Optional-only behavior from the API, but keeping O+C to avoid behavior changes.

Copy link
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!

@github-actions github-actions bot added the stale label Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants