-
Notifications
You must be signed in to change notification settings - Fork 212
feat: Add privateEndpointHostnames field to Data Federation resource #4358
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
Changes from 15 commits
76a9fac
b3559ce
fcbf3fa
deee4f9
c391d97
ebbb7e5
de1e4ed
ce9eb6f
50e5ddc
d7635ec
0c7f891
a435f94
d0bc750
782f39e
3ca2e0c
7bda453
7f39bec
46b452b
2f36c2d
76d38cc
ab1c745
317a5d2
9d63c9e
172a7f2
ca40685
0da4f9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ```release-note:enhancement | ||
| resource/mongodbatlas_federated_database_instance: Adds `private_endpoint_hostnames` attribute | ||
| ``` | ||
|
|
||
| ```release-note:enhancement | ||
| data-source/mongodbatlas_federated_database_instance: Adds `private_endpoint_hostnames` attribute | ||
| ``` | ||
|
|
||
| ```release-note:enhancement | ||
| data-source/mongodbatlas_federated_database_instances: Adds `private_endpoint_hostnames` attribute | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |
| "maps" | ||
| "os" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
| "github.com/hashicorp/terraform-plugin-testing/terraform" | ||
|
|
@@ -31,6 +32,7 @@ func TestAccFederatedDatabaseInstance_basic(t *testing.T) { | |
| "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", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have any test where this is set?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| } | ||
| setChecks := []string{"project_id", "storage_stores.0.read_preference.0.tag_sets.#"} | ||
| firstStepChecks := acc.AddAttrChecks(resourceName, nil, valueChecks) | ||
|
|
@@ -595,6 +597,92 @@ data "mongodbatlas_federated_database_instance" "test" { | |
| `, federatedInstanceName, projectName, orgID) | ||
| } | ||
|
|
||
| func TestAccFederatedDatabaseInstance_withPrivateEndpoint(t *testing.T) { | ||
|
EspenAlbert marked this conversation as resolved.
Outdated
|
||
| var ( | ||
|
EspenAlbert marked this conversation as resolved.
Outdated
|
||
| projectID = acc.ProjectIDExecution(t) | ||
| name = acc.RandomName() | ||
| ) | ||
|
|
||
| resource.Test(t, resource.TestCase{ | ||
| PreCheck: func() { acc.PreCheckBasic(t); acc.PreCheckAwsEnvBasic(t) }, | ||
| ExternalProviders: acc.ExternalProvidersOnlyAWS(), | ||
| ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, | ||
| CheckDestroy: acc.CheckDestroyFederatedDatabaseInstance, | ||
| Steps: []resource.TestStep{ | ||
| { | ||
| Config: configWithPrivateEndpoint(projectID, name), | ||
| }, | ||
| { | ||
| PreConfig: waitForStatusUpdate, | ||
|
EspenAlbert marked this conversation as resolved.
Outdated
|
||
| RefreshState: true, | ||
|
EspenAlbert marked this conversation as resolved.
Outdated
|
||
| Check: resource.ComposeAggregateTestCheckFunc( | ||
| resource.TestCheckResourceAttr(resourceName, "private_endpoint_hostnames.#", "1"), | ||
| resource.TestCheckResourceAttrSet(resourceName, "private_endpoint_hostnames.0.hostname"), | ||
| resource.TestCheckResourceAttrSet(resourceName, "private_endpoint_hostnames.0.private_endpoint"), | ||
| ), | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| func waitForStatusUpdate() { | ||
| time.Sleep(2 * time.Minute) | ||
| } | ||
|
|
||
| func configWithPrivateEndpoint(projectID, name string) string { | ||
| return fmt.Sprintf(` | ||
| provider "aws" { | ||
|
EspenAlbert marked this conversation as resolved.
Outdated
|
||
| region = "us-east-1" | ||
| } | ||
|
|
||
| resource "aws_vpc" "test" { | ||
|
EspenAlbert marked this conversation as resolved.
|
||
| cidr_block = "10.0.0.0/16" | ||
| enable_dns_hostnames = true | ||
| enable_dns_support = true | ||
| } | ||
|
|
||
| resource "aws_subnet" "test" { | ||
| vpc_id = aws_vpc.test.id | ||
| cidr_block = "10.0.1.0/24" | ||
| availability_zone = "us-east-1a" | ||
| } | ||
|
|
||
| data "aws_security_group" "default" { | ||
| name = "default" | ||
| vpc_id = aws_vpc.test.id | ||
| } | ||
|
|
||
| resource "aws_vpc_endpoint" "test" { | ||
| vpc_id = aws_vpc.test.id | ||
| service_name = "com.amazonaws.vpce.us-east-1.vpce-svc-0a7247db33497082e" | ||
| vpc_endpoint_type = "Interface" | ||
| subnet_ids = [aws_subnet.test.id] | ||
| security_group_ids = [data.aws_security_group.default.id] | ||
| } | ||
|
|
||
| resource "mongodbatlas_privatelink_endpoint_service_data_federation_online_archive" "test" { | ||
| project_id = %[1]q | ||
| endpoint_id = aws_vpc_endpoint.test.id | ||
| provider_name = "AWS" | ||
| comment = "Terraform Acceptance Test" | ||
| customer_endpoint_dns_name = aws_vpc_endpoint.test.dns_entry[0].dns_name | ||
| region = "US_EAST_1" | ||
| } | ||
|
|
||
| resource "mongodbatlas_federated_database_instance" "test" { | ||
| project_id = %[1]q | ||
| name = %[2]q | ||
|
|
||
| data_process_region { | ||
| cloud_provider = "AWS" | ||
| region = "VIRGINIA_USA" | ||
| } | ||
|
|
||
| depends_on = [mongodbatlas_privatelink_endpoint_service_data_federation_online_archive.test] | ||
| } | ||
| `, projectID, name) | ||
| } | ||
|
|
||
| func configFirstStepsUpdate(federatedInstanceName, projectName, orgID string) string { | ||
| return fmt.Sprintf(` | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.