Skip to content

feat: Add privateEndpointHostames field to Data Federation resource#4358

Open
marcabreracast wants to merge 21 commits intomasterfrom
CLOUDP-391245_DataFederation_Add_privateEndpointHostnames_Field
Open

feat: Add privateEndpointHostames field to Data Federation resource#4358
marcabreracast wants to merge 21 commits intomasterfrom
CLOUDP-391245_DataFederation_Add_privateEndpointHostnames_Field

Conversation

@marcabreracast
Copy link
Copy Markdown
Collaborator

@marcabreracast marcabreracast commented Apr 1, 2026

Description

This PR adds the computed attribute private_endpoint_hostnames to mongodbatlas_federated_database_instance resource, and corresponding data sources mongodbatlas_federated_database_instance and mongodbatlas_federated_database_instances.

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

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

Copilot AI review requested due to automatic review settings April 1, 2026 08:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds exposure of Data Federation private endpoint hostname information in the Terraform provider’s federated database instance resource.

Changes:

  • Adds a new computed private_endpoint_hostnames attribute to the federated database instance resource schema.
  • Populates the attribute during Read and Import using a new flattener for the Atlas SDK response type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@svc-apix-Bot
Copy link
Copy Markdown
Collaborator

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 not_stale Not stale issue or PR and removed stale labels Apr 7, 2026
@marcabreracast marcabreracast marked this pull request as ready for review April 7, 2026 14:05
@marcabreracast marcabreracast requested review from a team as code owners April 7, 2026 14:05
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

APIx bot: a message has been sent to Docs Slack channel

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 7, 2026

🤖 Augment PR Summary

Summary: Adds support for exposing private endpoint hostnames on Atlas Data Federation resources and data sources.

Changes:

  • Introduced computed private_endpoint_hostnames in mongodbatlas_federated_database_instance resource schema and read/import flows
  • Added the same computed attribute to the singular and plural federated database instance data sources
  • Implemented a shared flattener to map Atlas SDK PrivateEndpointHostname objects into Terraform state
  • Extended acceptance tests to assert the new attribute is present (currently empty in the test environment)
  • Updated docs and changelog entries to document the new attribute

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

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

Copy link
Copy Markdown
Contributor

@corryroot corryroot left a comment

Choose a reason for hiding this comment

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

LGTM! I commented with some copy nits.


* `id` - The Terraform's unique identifier used internally for state management.
* `hostnames` - The list of hostnames assigned to the Federated Database Instance. Each string in the array is a hostname assigned to the Federated Database Instance.
* `private_endpoint_hostnames` - The list of private endpoint hostnames assigned to the Federated Database Instance.
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.

Suggested change
* `private_endpoint_hostnames` - The list of private endpoint hostnames assigned to the Federated Database Instance.
* `private_endpoint_hostnames` - List of private endpoint hostnames assigned to the Federated Database Instance.

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.

Addressed in 0c7f891

* `id` - The Terraform's unique identifier used internally for state management.
* `hostnames` - The list of hostnames assigned to the Federated Database Instance. Each string in the array is a hostname assigned to the Federated Database Instance.
* `private_endpoint_hostnames` - The list of private endpoint hostnames assigned to the Federated Database Instance.
* `private_endpoint_hostnames.#.hostname` - Human-readable label identifying the hostname.
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.

Suggested change
* `private_endpoint_hostnames.#.hostname` - Human-readable label identifying the hostname.
* `private_endpoint_hostnames.#.hostname` - Human-readable label that identifies the host.

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.

Addressed in 0c7f891

* `hostnames` - The list of hostnames assigned to the Federated Database Instance. Each string in the array is a hostname assigned to the Federated Database Instance.
* `private_endpoint_hostnames` - The list of private endpoint hostnames assigned to the Federated Database Instance.
* `private_endpoint_hostnames.#.hostname` - Human-readable label identifying the hostname.
* `private_endpoint_hostnames.#.private_endpoint` - Human-readable label identifying the private endpoint.
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.

Suggested change
* `private_endpoint_hostnames.#.private_endpoint` - Human-readable label identifying the private endpoint.
* `private_endpoint_hostnames.#.private_endpoint` - Human-readable label that identifies the private endpoint.

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.

Addressed in 0c7f891

Comment on lines +37 to +39
* `private_endpoint_hostnames` - The list of private endpoint hostnames assigned to the Federated Database Instance.
* `private_endpoint_hostnames.#.hostname` - Human-readable label identifying the hostname.
* `private_endpoint_hostnames.#.private_endpoint` - Human-readable label identifying the private endpoint.
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.

Same as above

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.

Addressed in 0c7f891

Comment on lines +216 to +218
* `private_endpoint_hostnames` - The list of private endpoint hostnames assigned to the Federated Database Instance.
* `private_endpoint_hostnames.#.hostname` - Human-readable label identifying the hostname.
* `private_endpoint_hostnames.#.private_endpoint` - Human-readable label identifying the private endpoint.
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.

Same as above.

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.

Addressed in 0c7f891

"storage_stores.0.read_preference.0.tag_sets.#": "2",
"storage_stores.0.read_preference.0.tag_sets.0.tags.#": "2",
"storage_databases.0.collections.0.data_sources.0.database": "sample_airbnb",
"private_endpoint_hostnames.#": "0",
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.

Do we have any test where this is set?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agree, first double check on which scenario it is populated and from there see feasibility of capturing within a test

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.

Added a test in a435f94 to fully create a private endpoint from scratch. Note that because the creation takes some time, I had to take a similar approach to what we're doing in encryptionatrest resource test, where we wait for the value to be populated.

return diag.FromErr(fmt.Errorf(errorFederatedDatabaseInstanceSetting, "hostnames", name, err))
}

if err := d.Set("private_endpoint_hostnames", flattenPrivateEndpointHostnames(dataFederationInstance.GetPrivateEndpointHostnames())); err != nil {
Copy link
Copy Markdown
Collaborator

@EspenAlbert EspenAlbert Apr 7, 2026

Choose a reason for hiding this comment

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

not sure if the API always returns privateEndpointHostnames = [] or omits the field.
Using the GetXXX will not differentiate the two cases but I think this is ok here since it is a computed attribute it makes it simpler for the consumers, so they never have to worry about null value and can always assume a []

Copy link
Copy Markdown
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.

LGTM. But ideally we should have a test where it is not empty

Copy link
Copy Markdown
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

LGTM

`, federatedInstanceName, projectName, orgID)
}

func TestAccFederatedDatabaseInstance_withPrivateEndpoint(t *testing.T) {
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.

[nit] Move test above all the internal functions

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.

Addressed in 7bda453

region = "us-east-1"
}

resource "aws_vpc" "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.

q: Is this the only place were we create aws_vpc* resources? Seems like a good opportunity to refactor?

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.

We also do it in resource_private_endpoint_regional_mode_test.go. However looking at the config used there, it differs meaningfully from what we're doing in this resource. I'd say that it's a refactor where the gain would be minimal as the boiler plate we could extract is very minor.


func configWithPrivateEndpoint(projectID, name string) string {
return fmt.Sprintf(`
provider "aws" {
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.

Why do we need this? Isn't it part of ExternalProviders?

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.

Not needed, added it because I wanted to make the region specific but as it's our default anyway, removed it in 7f39bec

},
{
PreConfig: waitForStatusUpdate,
RefreshState: true,
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.

Why is this needed? (Add comment)

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.

Added comment in 46b452b

Config: configWithPrivateEndpoint(projectID, name),
},
{
PreConfig: waitForStatusUpdate,
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.

Q: Is this something we should also document? That you need a sleep resource for the private_endpoint_hostnames to be populated?
Seems like a "gotcha" that users can run into.

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.

Yeah makes sense, added a note to the docs in 2f36c2d

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.

Looking into this further, a time_sleep resource would not help here since it cannot trigger a re-read of a resource that has already been applied to my understanding. A terraform apply -refresh-only after the initial apply will update state with the populated hostnames.

Rephrased the note in 76d38cc, let me know if it makes sense.

}

func TestAccFederatedDatabaseInstance_withPrivateEndpoint(t *testing.T) {
var (
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.

Great job on adding this!
Maybe it is worth also adding it to the examples/ directory?

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.

We could add it yes, however where would we want it to go? We already have examples for Data Federation Private Link in examples/mongodbatlas_privatelink_endpoint/aws/data-federation-online-archive, and also for examples/mongodbatlas_federated_database_instance/aws

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.

Added an example in ab1c745ab1c745ab1c745 under the data_federation examples. Let me know if it suits or we want a different place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement not_stale Not stale issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants