From 13c7bb765d278c5943c2374b7b478590ae48edeb Mon Sep 17 00:00:00 2001 From: Abner Garcia Date: Tue, 14 Dec 2021 14:37:56 -0700 Subject: [PATCH 1/8] added privatelink_endpoint_service_adl resource and datasource --- ...batlas_privatelink_endpoint_service_adl.go | 82 ++++++++ ...s_privatelink_endpoint_service_adl_test.go | 50 +++++ ...atlas_privatelink_endpoints_service_adl.go | 128 ++++++++++++ ..._privatelink_endpoints_service_adl_test.go | 52 +++++ mongodbatlas/provider.go | 3 + ...batlas_privatelink_endpoint_service_adl.go | 194 ++++++++++++++++++ ...s_privatelink_endpoint_service_adl_test.go | 152 ++++++++++++++ ...atelink_endpoint_service_adl.html.markdown | 48 +++++ ...telink_endpoints_service_adl.html.markdown | 58 ++++++ ...atelink_endpoint_service_adl.html.markdown | 44 ++++ 10 files changed, 811 insertions(+) create mode 100644 mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go create mode 100644 mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl_test.go create mode 100644 mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go create mode 100644 mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl_test.go create mode 100644 mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go create mode 100644 mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go create mode 100644 website/docs/d/privatelink_endpoint_service_adl.html.markdown create mode 100644 website/docs/d/privatelink_endpoints_service_adl.html.markdown create mode 100644 website/docs/r/privatelink_endpoint_service_adl.html.markdown diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go new file mode 100644 index 0000000000..c5d77caccb --- /dev/null +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go @@ -0,0 +1,82 @@ +package mongodbatlas + +import ( + "context" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func dataSourceMongoDBAtlasPrivateLinkEndpointServiceADL() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceMongoDBAtlasPrivateLinkEndpointServiceADLRead, + Schema: map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Required: true, + }, + "endpoint_id": { + Type: schema.TypeString, + Required: true, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "comment": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func dataSourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + // Get client connection. + conn := meta.(*MongoDBClient).Atlas + ids := decodeStateID(d.Id()) + projectID := ids["project_id"] + endpointID := ids["endpoint_id"] + + privateLinkResponse, _, err := conn.PrivateLinkEndpointsADL.Get(ctx, projectID, endpointID) + if err != nil { + // case 404 + // deleted in the backend case + reset := strings.Contains(err.Error(), "404") && !d.IsNewResource() + + if reset { + d.SetId("") + return nil + } + + return diag.Errorf("error getting adl private link endpoint information: %s", err) + } + + if err := d.Set("endpoint_id", privateLinkResponse.EndpointID); err != nil { + return diag.Errorf("error setting `endpoint_id` for endpoint_id (%s): %s", d.Id(), err) + } + + if err := d.Set("type", privateLinkResponse.Type); err != nil { + return diag.Errorf("error setting `type` for endpoint_id (%s): %s", d.Id(), err) + } + + if err := d.Set("comment", privateLinkResponse.Comment); err != nil { + return diag.Errorf("error setting `comment` for endpoint_id (%s): %s", d.Id(), err) + } + + if err := d.Set("provider_name", privateLinkResponse.Provider); err != nil { + return diag.Errorf("error setting `provider_name` for endpoint_id (%s): %s", d.Id(), err) + } + + d.SetId(encodeStateID(map[string]string{ + "project_id": projectID, + "endpoint_id": privateLinkResponse.EndpointID, + })) + + return nil +} diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl_test.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl_test.go new file mode 100644 index 0000000000..8776e4dc6e --- /dev/null +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl_test.go @@ -0,0 +1,50 @@ +package mongodbatlas + +import ( + "fmt" + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccDataSourceMongoDBAtlasPrivateLinkEndpointServiceADL_basic(t *testing.T) { + //SkipTestExtCred(t) + datasourceName := "data.mongodbatlas_privatelink_endpoint_service_adl.test" + projectID := os.Getenv("MONGODB_ATLAS_PROJECT_ID") + endpointID := "1" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccMongoDBAtlasPrivateLinkEndpointADLDataSourceConfig(projectID, endpointID), + Check: resource.ComposeTestCheckFunc( + testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLExists(datasourceName), + resource.TestCheckResourceAttr(datasourceName, "endpoint_id", endpointID), + resource.TestCheckResourceAttr(datasourceName, "type", "DATA_LAKE"), + resource.TestCheckResourceAttr(datasourceName, "provider_name", "AWS"), + resource.TestCheckResourceAttr(datasourceName, "comment", "private link adl comment"), + ), + }, + }, + }) +} + +func testAccMongoDBAtlasPrivateLinkEndpointADLDataSourceConfig(projectID, endpointID string) string { + return fmt.Sprintf(` + resource "mongodbatlas_privatelink_endpoint_service_adl" "test" { + project_id = "%[1]s" + endpoint_id = "%[2]s" + comment = "private link adl comment" + type = "DATA_LAKE" + provider_name = "AWS" + } + + data "mongodbatlas_privatelink_endpoint_service_adl" "test" { + project_id = mongodbatlas_privatelink_endpoint_service_adl.test.project_id + endpoint_id = mongodbatlas_privatelink_endpoint_service_adl.test.endpoint_id + } + `, projectID, endpointID) +} diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go new file mode 100644 index 0000000000..433f4e4dd3 --- /dev/null +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go @@ -0,0 +1,128 @@ +package mongodbatlas + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + matlas "go.mongodb.org/atlas/mongodbatlas" +) + +func dataSourceMongoDBAtlasPrivateLinkEndpointsServiceADL() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceMongoDBAtlasPrivateLinkEndpointsServiceADLRead, + Schema: map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Required: true, + }, + "links": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "href": { + Type: schema.TypeString, + Computed: true, + }, + "rel": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "results": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "endpoint_id": { + Type: schema.TypeString, + Computed: true, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "comment": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "total_count": { + Type: schema.TypeInt, + Computed: true, + }, + }, + } +} + +func dataSourceMongoDBAtlasPrivateLinkEndpointsServiceADLRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + + // Get client connection. + conn := meta.(*MongoDBClient).Atlas + projectID := d.Get("project_id").(string) + + privateLinkEndpoints, _, err := conn.PrivateLinkEndpointsADL.List(ctx, projectID) + if err != nil { + return diag.FromErr(fmt.Errorf("error getting privateLinkEndpoints information: %s", err)) + } + + if err := d.Set("links", flattenADLPrivateEndpointLinks(privateLinkEndpoints.Links)); err != nil { + return diag.FromErr(fmt.Errorf("error setting `results`: %s", err)) + } + + if err := d.Set("results", flattenADLPrivateLinkEndpoints(privateLinkEndpoints.Results)); err != nil { + return diag.FromErr(fmt.Errorf("error setting `results`: %s", err)) + } + + if err := d.Set("total_count", privateLinkEndpoints.TotalCount); err != nil { + return diag.FromErr(fmt.Errorf("error setting `total_count`: %s", err)) + } + + d.SetId(resource.UniqueId()) + + return nil +} + +func flattenADLPrivateEndpointLinks(links []*matlas.Link) []map[string]interface{} { + linksList := make([]map[string]interface{}, 0) + + for _, link := range links { + mLink := map[string]interface{}{ + "href": link.Href, + "rel": link.Rel, + } + linksList = append(linksList, mLink) + } + + return linksList +} + +func flattenADLPrivateLinkEndpoints(privateLinks []*matlas.PrivateLinkEndpointADL) []map[string]interface{} { + var results []map[string]interface{} + + if len(privateLinks) > 0 { + results = make([]map[string]interface{}, len(privateLinks)) + + for k, privateLink := range privateLinks { + results[k] = map[string]interface{}{ + "endpoint_id": privateLink.EndpointID, + "type": privateLink.Type, + "provider_name": privateLink.Provider, + "comment": privateLink.Comment, + } + } + } + + return results +} diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl_test.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl_test.go new file mode 100644 index 0000000000..9d30b8bc9f --- /dev/null +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl_test.go @@ -0,0 +1,52 @@ +package mongodbatlas + +import ( + "fmt" + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccDataSourceMongoDBAtlasPrivateLinkEndpointsServiceADL_basic(t *testing.T) { + //SkipTestExtCred(t) + datasourceName := "data.mongodbatlas_privatelink_endpoint_service_adl.test" + projectID := os.Getenv("MONGODB_ATLAS_PROJECT_ID") + endpointID := "1" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccMongoDBAtlasPrivateLinkEndpointsADLDataSourceConfig(projectID, endpointID), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(datasourceName, "project_id"), + resource.TestCheckResourceAttrSet(datasourceName, "links.#"), + resource.TestCheckResourceAttrSet(datasourceName, "results.#"), + resource.TestCheckResourceAttrSet(datasourceName, "results.0.endpoint_id"), + resource.TestCheckResourceAttrSet(datasourceName, "results.0.type"), + resource.TestCheckResourceAttrSet(datasourceName, "results.0.provider_name"), + resource.TestCheckResourceAttrSet(datasourceName, "results.0.comment"), + resource.TestCheckResourceAttr(datasourceName, "total_count", "1"), + ), + }, + }, + }) +} + +func testAccMongoDBAtlasPrivateLinkEndpointsADLDataSourceConfig(projectID, endpointID string) string { + return fmt.Sprintf(` + resource "mongodbatlas_privatelink_endpoint_service_adl" "test" { + project_id = "%[1]s" + endpoint_id = "%[2]s" + comment = "private link adl comment" + type = "DATA_LAKE" + provider_name = "AWS" + } + + data "mongodbatlas_privatelink_endpoints_service_adl" "test" { + project_id = mongodbatlas_privatelink_endpoint_service_adl.test.project_id + } + `, projectID, endpointID) +} diff --git a/mongodbatlas/provider.go b/mongodbatlas/provider.go index 5a2bd1454f..7e57c14d49 100644 --- a/mongodbatlas/provider.go +++ b/mongodbatlas/provider.go @@ -98,6 +98,8 @@ func getDataSourcesMap() map[string]*schema.Resource { "mongodbatlas_x509_authentication_database_user": dataSourceMongoDBAtlasX509AuthDBUser(), "mongodbatlas_privatelink_endpoint": dataSourceMongoDBAtlasPrivateLinkEndpoint(), "mongodbatlas_privatelink_endpoint_service": dataSourceMongoDBAtlasPrivateEndpointServiceLink(), + "mongodbatlas_privatelink_endpoint_service_adl": dataSourceMongoDBAtlasPrivateLinkEndpointServiceADL(), + "mongodbatlas_privatelink_endpoints_service_adl": dataSourceMongoDBAtlasPrivateLinkEndpointsServiceADL(), "mongodbatlas_cloud_provider_snapshot_backup_policy": dataSourceMongoDBAtlasCloudProviderSnapshotBackupPolicy(), "mongodbatlas_cloud_backup_schedule": dataSourceMongoDBAtlasCloudBackupSchedule(), "mongodbatlas_third_party_integrations": dataSourceMongoDBAtlasThirdPartyIntegrations(), @@ -148,6 +150,7 @@ func getResourcesMap() map[string]*schema.Resource { "mongodbatlas_x509_authentication_database_user": resourceMongoDBAtlasX509AuthDBUser(), "mongodbatlas_privatelink_endpoint": resourceMongoDBAtlasPrivateLinkEndpoint(), "mongodbatlas_privatelink_endpoint_service": resourceMongoDBAtlasPrivateEndpointServiceLink(), + "mongodbatlas_privatelink_endpoint_service_adl": resourceMongoDBAtlasPrivateLinkEndpointServiceADL(), "mongodbatlas_cloud_provider_snapshot_backup_policy": resourceMongoDBAtlasCloudProviderSnapshotBackupPolicy(), "mongodbatlas_third_party_integration": resourceMongoDBAtlasThirdPartyIntegration(), "mongodbatlas_project_ip_access_list": resourceMongoDBAtlasProjectIPAccessList(), diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go new file mode 100644 index 0000000000..c7b1cae730 --- /dev/null +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go @@ -0,0 +1,194 @@ +package mongodbatlas + +import ( + "context" + "errors" + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + matlas "go.mongodb.org/atlas/mongodbatlas" +) + +const ( + errorADLServiceEndpointAdd = "error adding MongoDB ADL Private Link Endpoint Connection(%s): %s" +) + +func resourceMongoDBAtlasPrivateLinkEndpointServiceADL() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceMongoDBAtlasPrivateLinkEndpointServiceADLCreate, + ReadContext: resourceMongoDBAtlasPrivateLinkEndpointServiceADLRead, + UpdateContext: resourceMongoDBAtlasPrivateLinkEndpointServiceADLUpdate, + DeleteContext: resourceMongoDBAtlasPrivateLinkEndpointServiceADLDelete, + Importer: &schema.ResourceImporter{ + StateContext: resourceMongoDBAtlasPrivateLinkEndpointServiceADLImportState, + }, + Schema: map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "endpoint_id": { + Type: schema.TypeString, + Required: true, + }, + "provider_name": { + Type: schema.TypeString, + Required: true, + Default: "AWS", + ValidateFunc: validation.StringInSlice([]string{"AWS"}, false), + }, + "type": { + Type: schema.TypeString, + Required: true, + Default: "DATA_LAKE", + ValidateFunc: validation.StringInSlice([]string{"DATA_LAKE"}, false), + }, + "comment": { + Type: schema.TypeString, + Optional: true, + }, + }, + } +} + +func resourceMongoDBAtlasPrivateLinkEndpointServiceADLUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + // Get client connection. + conn := meta.(*MongoDBClient).Atlas + ids := decodeStateID(d.Id()) + projectID := ids["project_id"] + endpointID := ids["endpoint_id"] + + privateLink, _, err := conn.PrivateLinkEndpointsADL.Get(ctx, projectID, endpointID) + if err != nil { + return diag.Errorf("error getting private link endpoint information: %s", err) + } + + if d.HasChange("comment") { + privateLink.Comment = d.Get("comment").(string) + } + + _, _, err = conn.PrivateLinkEndpointsADL.Create(context.Background(), projectID, privateLink) + if err != nil { + return diag.Errorf("error updating private link endpoint (%s): %s", privateLink.EndpointID, err) + } + + return resourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx, d, meta) +} + +func resourceMongoDBAtlasPrivateLinkEndpointServiceADLCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + // Get client connection. + conn := meta.(*MongoDBClient).Atlas + projectID := d.Get("project_id").(string) + + privateLinkRequest := &matlas.PrivateLinkEndpointADL{ + EndpointID: d.Get("endpoint_id").(string), + Type: d.Get("type").(string), + Provider: d.Get("provider_name").(string), + Comment: d.Get("comment").(string), + } + + _, _, err := conn.PrivateLinkEndpointsADL.Create(ctx, projectID, privateLinkRequest) + if err != nil { + return diag.Errorf(errorADLServiceEndpointAdd, privateLinkRequest.EndpointID, err) + } + + d.SetId(encodeStateID(map[string]string{ + "project_id": projectID, + "endpoint_id": privateLinkRequest.EndpointID, + })) + + return resourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx, d, meta) + +} + +func resourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + // Get client connection. + conn := meta.(*MongoDBClient).Atlas + ids := decodeStateID(d.Id()) + projectID := ids["project_id"] + endpointID := ids["endpoint_id"] + + privateLinkResponse, _, err := conn.PrivateLinkEndpointsADL.Get(ctx, projectID, endpointID) + if err != nil { + // case 404 + // deleted in the backend case + reset := strings.Contains(err.Error(), "404") && !d.IsNewResource() + + if reset { + d.SetId("") + return nil + } + + return diag.Errorf("error getting adl private link endpoint information: %s", err) + } + + if err := d.Set("endpoint_id", privateLinkResponse.EndpointID); err != nil { + return diag.Errorf("error setting `endpoint_id` for endpoint_id (%s): %s", d.Id(), err) + } + + if err := d.Set("type", privateLinkResponse.Type); err != nil { + return diag.Errorf("error setting `type` for endpoint_id (%s): %s", d.Id(), err) + } + + if err := d.Set("comment", privateLinkResponse.Comment); err != nil { + return diag.Errorf("error setting `comment` for endpoint_id (%s): %s", d.Id(), err) + } + + if err := d.Set("provider_name", privateLinkResponse.Provider); err != nil { + return diag.Errorf("error setting `provider_name` for endpoint_id (%s): %s", d.Id(), err) + } + + return nil +} + +func resourceMongoDBAtlasPrivateLinkEndpointServiceADLDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + // Get client connection. + conn := meta.(*MongoDBClient).Atlas + ids := decodeStateID(d.Id()) + projectID := ids["project_id"] + endpointID := ids["endpoint_id"] + + _, err := conn.PrivateLinkEndpointsADL.Delete(ctx, projectID, endpointID) + if err != nil { + return diag.Errorf("error deleting adl private link endpoint(%s): %s", endpointID, err) + } + + return nil +} + +func resourceMongoDBAtlasPrivateLinkEndpointServiceADLImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + conn := meta.(*MongoDBClient).Atlas + + parts := strings.SplitN(d.Id(), "--", 2) + if len(parts) != 2 { + return nil, errors.New("import format error: to import a search index, use the format {project_id}--{endpoint_id}") + } + + projectID := parts[0] + endpointID := parts[1] + + _, _, err := conn.PrivateLinkEndpointsADL.Get(ctx, projectID, endpointID) + if err != nil { + return nil, fmt.Errorf("couldn't adl private link endpoint (%s) in projectID (%s) , error: %s", endpointID, projectID, err) + } + + if err := d.Set("project_id", projectID); err != nil { + log.Printf("[WARN] Error setting project_id for (%s): %s", projectID, err) + } + + if err := d.Set("endpoint_id", endpointID); err != nil { + log.Printf("[WARN] Error setting index_id for (%s): %s", endpointID, err) + } + + d.SetId(encodeStateID(map[string]string{ + "project_id": projectID, + "endpoint_id": endpointID, + })) + + return []*schema.ResourceData{d}, nil +} diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go new file mode 100644 index 0000000000..ca8bfab302 --- /dev/null +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go @@ -0,0 +1,152 @@ +package mongodbatlas + +import ( + "context" + "fmt" + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceADL_basic(t *testing.T) { + var ( + resourceName = "mongodbatlas_privatelink_endpoint_service_adl.adl-test" + projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID") + endpointID = "1" + commentOrigin = "this is a comment for adl private link endpoint" + commentUpdate = "this is a comment for adl private link endpoint [UPDATED]" + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLDestroy, + Steps: []resource.TestStep{ + { + Config: testAccMongoDBAtlasPrivateLinkEndpointServiceADLConfig(projectID, endpointID, commentOrigin), + Check: resource.ComposeTestCheckFunc( + testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "endpoint_id", endpointID), + resource.TestCheckResourceAttr(resourceName, "type", "DATA_LAKE"), + resource.TestCheckResourceAttr(resourceName, "provider_name", "AWS"), + resource.TestCheckResourceAttr(resourceName, "comment", commentOrigin), + ), + }, + { + Config: testAccMongoDBAtlasPrivateLinkEndpointServiceADLConfig(projectID, endpointID, commentUpdate), + Check: resource.ComposeTestCheckFunc( + testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "endpoint_id", endpointID), + resource.TestCheckResourceAttr(resourceName, "type", "DATA_LAKE"), + resource.TestCheckResourceAttr(resourceName, "provider_name", "AWS"), + resource.TestCheckResourceAttr(resourceName, "comment", commentUpdate), + ), + }, + }, + }) + +} + +func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceADL_importBasic(t *testing.T) { + var ( + //privateLink = matlas.PrivateLinkEndpointADL{} + resourceName = "mongodbatlas_privatelink_endpoint_service_adl.test" + projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID") + endpointID = "" + commentOrigin = "this is a comment for adl private link endpoint" + ) + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasSearchIndexDestroy, + Steps: []resource.TestStep{ + /* { + Config: testAccMongoDBAtlasPrivateLinkEndpointServiceADLConfig(projectID, endpointID, commentOrigin), + Check: resource.ComposeTestCheckFunc( + testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLExists(resourceName, &privateLink), + resource.TestCheckResourceAttr(resourceName, "endpoint_id", endpointID), + resource.TestCheckResourceAttr(resourceName, "type", "DATA_LAKE"), + resource.TestCheckResourceAttr(resourceName, "provider", "AWS"), + resource.TestCheckResourceAttr(resourceName, "comment", commentOrigin), + ), + },*/ + { + Config: testAccMongoDBAtlasPrivateLinkEndpointServiceADLConfig(projectID, endpointID, commentOrigin), + ResourceName: resourceName, + ImportStateIdFunc: testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLImportStateIDFunc(resourceName), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLDestroy(state *terraform.State) error { + conn := testAccProvider.Meta().(*MongoDBClient).Atlas + + for _, rs := range state.RootModule().Resources { + if rs.Type != "mongodbatlas_privatelink_endpoint_service_adl" { + continue + } + + ids := decodeStateID(rs.Primary.ID) + + privateLink, _, err := conn.PrivateLinkEndpointsADL.Get(context.Background(), ids["project_id"], ids["endpoint_id"]) + if err == nil && privateLink != nil { + return fmt.Errorf("endpoint_id (%s) still exists", ids["endpoint_id"]) + } + } + + return nil +} + +func testAccMongoDBAtlasPrivateLinkEndpointServiceADLConfig(projectID, endpointID, comment string) string { + return fmt.Sprintf(` + resource "mongodbatlas_privatelink_endpoint_service_adl" "adl_test" { + project_id = "%[1]s" + endpoint_id = "%[2]s" + comment = "%[3]s" + type = "DATA_LAKE" + provider_name = "AWS" + } + `, projectID, endpointID, comment) +} + +func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLExists(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := testAccProvider.Meta().(*MongoDBClient).Atlas + + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("not found: %s", resourceName) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("no ID is set") + } + + ids := decodeStateID(rs.Primary.ID) + + _, _, err := conn.PrivateLinkEndpointsADL.Get(context.Background(), ids["project_id"], ids["endpoint_id"]) + if err == nil { + return nil + } + + return fmt.Errorf("endpoint_id (%s) does not exist", ids["endpoint_id"]) + } +} + +func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLImportStateIDFunc(resourceName string) resource.ImportStateIdFunc { + return func(s *terraform.State) (string, error) { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return "", fmt.Errorf("not found: %s", resourceName) + } + + ids := decodeStateID(rs.Primary.ID) + + return fmt.Sprintf("%s--%s", ids["project_id"], ids["endpoint_id"]), nil + } +} diff --git a/website/docs/d/privatelink_endpoint_service_adl.html.markdown b/website/docs/d/privatelink_endpoint_service_adl.html.markdown new file mode 100644 index 0000000000..21c0c149ec --- /dev/null +++ b/website/docs/d/privatelink_endpoint_service_adl.html.markdown @@ -0,0 +1,48 @@ +--- +layout: "mongodbatlas" +page_title: "MongoDB Atlas: privatelink_endpoint_service_adl" +sidebar_current: "docs-mongodbatlas-datasource-privatelink-endpoint-service-adl" +description: |- +Describes a DataLake and Online Archive private link endpoint. +--- + + +# privatelink_endpoint_service_adl + +`privatelink_endpoint_service_adl` Provides DataLake and Online Archive private link endpoint resource. + +-> **NOTE:** Groups and projects are synonymous terms. You may find group_id in the official documentation. + +## Example Usage + +### Basic +```terraform +resource "mongodbatlas_privatelink_endpoint_service_adl" "adl_test" { + project_id = "" + endpoint_id = "" + comment = "comments for private link endpoint adl" + type = "DATA_LAKE" + provider_name = "AWS" +} + +data "mongodbatlas_privatelink_endpoint_service_adl" "test" { + project_id = mongodbatlas_privatelink_endpoint_service_adl.adl_test.project_id + private_link_id = mongodbatlas_privatelink_endpoint_service_adl.adl_test.endpoint_id +} +``` + + +## Argument Reference + +* `project_id` - (Required) Unique 24-digit hexadecimal string that identifies the project. +* `endpoint_id` - (Required) Unique 22-character alphanumeric string that identifies the private endpoint. Atlas supports AWS private endpoints using the [|aws| PrivateLink](https://aws.amazon.com/privatelink/) feature. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `type` - Human-readable label that identifies the resource associated with this private endpoint. Value is `DATA_LAKE`. +* `provider_name` - Human-readable label that identifies the cloud provider for this endpoint. Value is AWS. +* `comment` - Human-readable string to associate with this private endpoint. + +For more information see: [MongoDB Atlas API - DataLake](https://docs.mongodb.com/datalake/reference/api/datalakes-api/) and [MongoDB Atlas API - Online Archive](https://docs.atlas.mongodb.com/reference/api/online-archive/) Documentation. diff --git a/website/docs/d/privatelink_endpoints_service_adl.html.markdown b/website/docs/d/privatelink_endpoints_service_adl.html.markdown new file mode 100644 index 0000000000..59592af2bf --- /dev/null +++ b/website/docs/d/privatelink_endpoints_service_adl.html.markdown @@ -0,0 +1,58 @@ +--- +layout: "mongodbatlas" +page_title: "MongoDB Atlas: privatelink_endpoints_service_adl" +sidebar_current: "docs-mongodbatlas-datasource-privatelink-endpoints-service-adl" +description: |- +Describes the list of all DataLake and Online Archive private link endpoints. +--- + +# privatelink_endpoints_service_adl + +`privatelink_endpoints_service_adl` Describes the list of all DataLake and Online Archive private link endpoints. + +-> **NOTE:** Groups and projects are synonymous terms. You may find group_id in the official documentation. + + +## Example Usage + +### Basic +```terraform +resource "mongodbatlas_privatelink_endpoint_service_adl" "adl_test" { + project_id = "" + endpoint_id = "" + comment = "comments for private link endpoint adl" + type = "DATA_LAKE" + provider_name = "AWS" +} + +data "mongodbatlas_privatelink_endpoints_service_adl" "test" { + project_id = mongodbatlas_privatelink_endpoint_service_adl.adl_test.project_id +} +``` + +## Argument Reference + +* `project_id` - (Required) The unique ID for the project. + +# Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `links` - The links array includes one or more links to sub-resources or related resources. The relations between URLs are explained in the [Web Linking Specification](http://tools.ietf.org/html/rfc5988). +* `results` - Each element in the `result` array is one private endpoint. +* `total_count` - This value is the count of the total number of items in the result set. `total_count may be greater than the number of objects in the results array if the entire result set is paginated. + +### links +Each object in the `links` array represents an online archive with the following attributes: +* `self` - The URL endpoint for this resource. + +### results + +Each object in the `results` array represents an online archive with the following attributes: + +* `endpoint_id` - (Required) Unique 22-character alphanumeric string that identifies the private endpoint. Atlas supports AWS private endpoints using the [|aws| PrivateLink](https://aws.amazon.com/privatelink/) feature. +* `type` - Human-readable label that identifies the resource associated with this private endpoint. Value is `DATA_LAKE`. +* `provider_name` - Human-readable label that identifies the cloud provider for this endpoint. Value is AWS. +* `comment` - Human-readable string to associate with this private endpoint. + +See [MongoDB Atlas API](https://docs.atlas.mongodb.com/reference/api/online-archive-get-all-for-cluster/) Documentation for more information. diff --git a/website/docs/r/privatelink_endpoint_service_adl.html.markdown b/website/docs/r/privatelink_endpoint_service_adl.html.markdown new file mode 100644 index 0000000000..4b8b6648c1 --- /dev/null +++ b/website/docs/r/privatelink_endpoint_service_adl.html.markdown @@ -0,0 +1,44 @@ +--- +layout: "mongodbatlas" +page_title: "MongoDB Atlas: privatelink_endpoint_service_adl" +sidebar_current: "docs-mongodbatlas-resource-privatelink-endpoint-service-adl" +description: |- +Provides DataLake and Online Archive private link endpoint. +--- + + +# privatelink_endpoint_service_adl + +`privatelink_endpoint_service_adl` Describe a DataLake and Online Archive private link endpoint resource. + +## Example Usage + +### Basic +```terraform +resource "mongodbatlas_privatelink_endpoint_service_adl" "adl_test" { + project_id = "" + endpoint_id = "" + comment = "comments for private link endpoint adl" + type = "DATA_LAKE" + provider_name = "AWS" +} +``` + + +## Argument Reference + +* `project_id` - (Required) Unique 24-digit hexadecimal string that identifies the project. +* `endpoint_id` - (Required) Unique 22-character alphanumeric string that identifies the private endpoint. Atlas supports AWS private endpoints using the [|aws| PrivateLink](https://aws.amazon.com/privatelink/) feature. +* `type` - (Required) Human-readable label that identifies the type of resource to associate with this private endpoint. Atlas supports `DATA_LAKE` only. If empty, defaults to `DATA_LAKE`. +* `provider_name` - (Required) Human-readable label that identifies the cloud provider for this endpoint. Atlas supports AWS only. If empty, defaults to AWS. +* `comment` - Human-readable string to associate with this private endpoint. + +## Import + +ADL privatelink endpoint can be imported using project ID and endpoint ID, in the format `project_id`--`endpoint_id`, e.g. + +``` +$ terraform import privatelink_endpoint_service_adl.test 1112222b3bf99403840e8934--vpce-jjg5e24qp93513h03 +``` + +For more information see: [MongoDB Atlas API - DataLake](https://docs.mongodb.com/datalake/reference/api/datalakes-api/) and [MongoDB Atlas API - Online Archive](https://docs.atlas.mongodb.com/reference/api/online-archive/) Documentation. From feb83db30b797b9ccf0d70cfd1fdd18d807b314a Mon Sep 17 00:00:00 2001 From: Abner Garcia Date: Tue, 14 Dec 2021 15:05:44 -0700 Subject: [PATCH 2/8] fix tests --- ...godbatlas_privatelink_endpoint_service_adl.go | 5 ++--- ...tlas_privatelink_endpoint_service_adl_test.go | 3 +-- ...las_privatelink_endpoints_service_adl_test.go | 5 ++--- ...godbatlas_privatelink_endpoint_service_adl.go | 2 -- ...tlas_privatelink_endpoint_service_adl_test.go | 16 +++++++--------- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go index c5d77caccb..44aae7e86f 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go @@ -39,9 +39,8 @@ func dataSourceMongoDBAtlasPrivateLinkEndpointServiceADL() *schema.Resource { func dataSourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas - ids := decodeStateID(d.Id()) - projectID := ids["project_id"] - endpointID := ids["endpoint_id"] + projectID := d.Get("project_id").(string) + endpointID := d.Get("endpoint_id").(string) privateLinkResponse, _, err := conn.PrivateLinkEndpointsADL.Get(ctx, projectID, endpointID) if err != nil { diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl_test.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl_test.go index 8776e4dc6e..2da91735f0 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl_test.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl_test.go @@ -9,10 +9,9 @@ import ( ) func TestAccDataSourceMongoDBAtlasPrivateLinkEndpointServiceADL_basic(t *testing.T) { - //SkipTestExtCred(t) datasourceName := "data.mongodbatlas_privatelink_endpoint_service_adl.test" projectID := os.Getenv("MONGODB_ATLAS_PROJECT_ID") - endpointID := "1" + endpointID := "vpce-jjg5e24qp93513h03" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl_test.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl_test.go index 9d30b8bc9f..d262a8801f 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl_test.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl_test.go @@ -9,10 +9,9 @@ import ( ) func TestAccDataSourceMongoDBAtlasPrivateLinkEndpointsServiceADL_basic(t *testing.T) { - //SkipTestExtCred(t) - datasourceName := "data.mongodbatlas_privatelink_endpoint_service_adl.test" + datasourceName := "data.mongodbatlas_privatelink_endpoints_service_adl.test" projectID := os.Getenv("MONGODB_ATLAS_PROJECT_ID") - endpointID := "1" + endpointID := "vpce-jjg5e24qp93513h03" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go index c7b1cae730..1915af4760 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go @@ -39,13 +39,11 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADL() *schema.Resource { "provider_name": { Type: schema.TypeString, Required: true, - Default: "AWS", ValidateFunc: validation.StringInSlice([]string{"AWS"}, false), }, "type": { Type: schema.TypeString, Required: true, - Default: "DATA_LAKE", ValidateFunc: validation.StringInSlice([]string{"DATA_LAKE"}, false), }, "comment": { diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go index ca8bfab302..4e9db68a07 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go @@ -12,9 +12,9 @@ import ( func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceADL_basic(t *testing.T) { var ( - resourceName = "mongodbatlas_privatelink_endpoint_service_adl.adl-test" + resourceName = "mongodbatlas_privatelink_endpoint_service_adl.test" projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID") - endpointID = "1" + endpointID = "vpce-jjg5e24qp93513h03" commentOrigin = "this is a comment for adl private link endpoint" commentUpdate = "this is a comment for adl private link endpoint [UPDATED]" ) @@ -51,10 +51,9 @@ func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceADL_basic(t *testing.T func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceADL_importBasic(t *testing.T) { var ( - //privateLink = matlas.PrivateLinkEndpointADL{} resourceName = "mongodbatlas_privatelink_endpoint_service_adl.test" projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID") - endpointID = "" + endpointID = "vpce-jjg5e24qp93513h03" commentOrigin = "this is a comment for adl private link endpoint" ) resource.ParallelTest(t, resource.TestCase{ @@ -62,16 +61,15 @@ func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceADL_importBasic(t *tes ProviderFactories: testAccProviderFactories, CheckDestroy: testAccCheckMongoDBAtlasSearchIndexDestroy, Steps: []resource.TestStep{ - /* { + { Config: testAccMongoDBAtlasPrivateLinkEndpointServiceADLConfig(projectID, endpointID, commentOrigin), Check: resource.ComposeTestCheckFunc( - testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLExists(resourceName, &privateLink), resource.TestCheckResourceAttr(resourceName, "endpoint_id", endpointID), resource.TestCheckResourceAttr(resourceName, "type", "DATA_LAKE"), - resource.TestCheckResourceAttr(resourceName, "provider", "AWS"), + resource.TestCheckResourceAttr(resourceName, "provider_name", "AWS"), resource.TestCheckResourceAttr(resourceName, "comment", commentOrigin), ), - },*/ + }, { Config: testAccMongoDBAtlasPrivateLinkEndpointServiceADLConfig(projectID, endpointID, commentOrigin), ResourceName: resourceName, @@ -104,7 +102,7 @@ func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLDestroy(state *terrafo func testAccMongoDBAtlasPrivateLinkEndpointServiceADLConfig(projectID, endpointID, comment string) string { return fmt.Sprintf(` - resource "mongodbatlas_privatelink_endpoint_service_adl" "adl_test" { + resource "mongodbatlas_privatelink_endpoint_service_adl" "test" { project_id = "%[1]s" endpoint_id = "%[2]s" comment = "%[3]s" From 93daaf464af6f62885f8d9ab2ddb6a5f1fe50923 Mon Sep 17 00:00:00 2001 From: Abner Garcia Date: Wed, 15 Dec 2021 11:48:17 -0700 Subject: [PATCH 3/8] changed go-client method in resource --- ...ongodbatlas_privatelink_endpoint_service_adl.go | 2 +- ...ngodbatlas_privatelink_endpoints_service_adl.go | 4 ++-- ...ongodbatlas_privatelink_endpoint_service_adl.go | 14 +++++++------- ...batlas_privatelink_endpoint_service_adl_test.go | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go index 44aae7e86f..c82d21b130 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go @@ -42,7 +42,7 @@ func dataSourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx context.Context projectID := d.Get("project_id").(string) endpointID := d.Get("endpoint_id").(string) - privateLinkResponse, _, err := conn.PrivateLinkEndpointsADL.Get(ctx, projectID, endpointID) + privateLinkResponse, _, err := conn.DataLakes.GetPrivateLinkEndpoint(ctx, projectID, endpointID) if err != nil { // case 404 // deleted in the backend case diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go index 433f4e4dd3..d7f0a2474b 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go @@ -72,7 +72,7 @@ func dataSourceMongoDBAtlasPrivateLinkEndpointsServiceADLRead(ctx context.Contex conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - privateLinkEndpoints, _, err := conn.PrivateLinkEndpointsADL.List(ctx, projectID) + privateLinkEndpoints, _, err := conn.DataLakes.ListPrivateLinkEndpoint(ctx, projectID) if err != nil { return diag.FromErr(fmt.Errorf("error getting privateLinkEndpoints information: %s", err)) } @@ -108,7 +108,7 @@ func flattenADLPrivateEndpointLinks(links []*matlas.Link) []map[string]interface return linksList } -func flattenADLPrivateLinkEndpoints(privateLinks []*matlas.PrivateLinkEndpointADL) []map[string]interface{} { +func flattenADLPrivateLinkEndpoints(privateLinks []*matlas.PrivateLinkEndpointDataLake) []map[string]interface{} { var results []map[string]interface{} if len(privateLinks) > 0 { diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go index 1915af4760..924d079569 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go @@ -61,7 +61,7 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADLUpdate(ctx context.Context projectID := ids["project_id"] endpointID := ids["endpoint_id"] - privateLink, _, err := conn.PrivateLinkEndpointsADL.Get(ctx, projectID, endpointID) + privateLink, _, err := conn.DataLakes.GetPrivateLinkEndpoint(ctx, projectID, endpointID) if err != nil { return diag.Errorf("error getting private link endpoint information: %s", err) } @@ -70,7 +70,7 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADLUpdate(ctx context.Context privateLink.Comment = d.Get("comment").(string) } - _, _, err = conn.PrivateLinkEndpointsADL.Create(context.Background(), projectID, privateLink) + _, _, err = conn.DataLakes.CreatePrivateLinkEndpoint(context.Background(), projectID, privateLink) if err != nil { return diag.Errorf("error updating private link endpoint (%s): %s", privateLink.EndpointID, err) } @@ -83,14 +83,14 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADLCreate(ctx context.Context conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - privateLinkRequest := &matlas.PrivateLinkEndpointADL{ + privateLinkRequest := &matlas.PrivateLinkEndpointDataLake{ EndpointID: d.Get("endpoint_id").(string), Type: d.Get("type").(string), Provider: d.Get("provider_name").(string), Comment: d.Get("comment").(string), } - _, _, err := conn.PrivateLinkEndpointsADL.Create(ctx, projectID, privateLinkRequest) + _, _, err := conn.DataLakes.CreatePrivateLinkEndpoint(ctx, projectID, privateLinkRequest) if err != nil { return diag.Errorf(errorADLServiceEndpointAdd, privateLinkRequest.EndpointID, err) } @@ -111,7 +111,7 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx context.Context, projectID := ids["project_id"] endpointID := ids["endpoint_id"] - privateLinkResponse, _, err := conn.PrivateLinkEndpointsADL.Get(ctx, projectID, endpointID) + privateLinkResponse, _, err := conn.DataLakes.GetPrivateLinkEndpoint(ctx, projectID, endpointID) if err != nil { // case 404 // deleted in the backend case @@ -151,7 +151,7 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADLDelete(ctx context.Context projectID := ids["project_id"] endpointID := ids["endpoint_id"] - _, err := conn.PrivateLinkEndpointsADL.Delete(ctx, projectID, endpointID) + _, err := conn.DataLakes.DeletePrivateLinkEndpoint(ctx, projectID, endpointID) if err != nil { return diag.Errorf("error deleting adl private link endpoint(%s): %s", endpointID, err) } @@ -170,7 +170,7 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADLImportState(ctx context.Co projectID := parts[0] endpointID := parts[1] - _, _, err := conn.PrivateLinkEndpointsADL.Get(ctx, projectID, endpointID) + _, _, err := conn.DataLakes.GetPrivateLinkEndpoint(ctx, projectID, endpointID) if err != nil { return nil, fmt.Errorf("couldn't adl private link endpoint (%s) in projectID (%s) , error: %s", endpointID, projectID, err) } diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go index 4e9db68a07..2d6c49a4b2 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go @@ -91,7 +91,7 @@ func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLDestroy(state *terrafo ids := decodeStateID(rs.Primary.ID) - privateLink, _, err := conn.PrivateLinkEndpointsADL.Get(context.Background(), ids["project_id"], ids["endpoint_id"]) + privateLink, _, err := conn.DataLakes.GetPrivateLinkEndpoint(context.Background(), ids["project_id"], ids["endpoint_id"]) if err == nil && privateLink != nil { return fmt.Errorf("endpoint_id (%s) still exists", ids["endpoint_id"]) } @@ -127,7 +127,7 @@ func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceADLExists(resourceName st ids := decodeStateID(rs.Primary.ID) - _, _, err := conn.PrivateLinkEndpointsADL.Get(context.Background(), ids["project_id"], ids["endpoint_id"]) + _, _, err := conn.DataLakes.GetPrivateLinkEndpoint(context.Background(), ids["project_id"], ids["endpoint_id"]) if err == nil { return nil } From 2c309abf1f19eaa3aa4a6c9325795a77ae0690dc Mon Sep 17 00:00:00 2001 From: Abner Garcia Date: Thu, 16 Dec 2021 09:31:34 -0700 Subject: [PATCH 4/8] updated go.mod atlas dep --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3fbaf8803a..951f8dd0fa 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,6 @@ require ( github.com/mwielbut/pointy v1.1.0 github.com/spf13/cast v1.4.1 github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20210625132053-af2d5c0ad54f - go.mongodb.org/atlas v0.14.0 + go.mongodb.org/atlas v0.14.1-0.20211216094555-210b54c6a1ca go.mongodb.org/realm v0.1.0 ) diff --git a/go.sum b/go.sum index f2530e8364..961480c560 100644 --- a/go.sum +++ b/go.sum @@ -1199,6 +1199,8 @@ go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsX go.mongodb.org/atlas v0.12.0/go.mod h1:wVCnHcm/7/IfTjEB6K8K35PLG70yGz8BdkRwX0oK9/M= go.mongodb.org/atlas v0.14.0 h1:g5y/ZbM+eg++qJtpjG/oxoEicf3MTx7o7JaTpoKfyYw= go.mongodb.org/atlas v0.14.0/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8= +go.mongodb.org/atlas v0.14.1-0.20211216094555-210b54c6a1ca h1:Am8hGiVfgnHYhWG7SmiD8yfsjM/zjydYVsOmzBoOZBY= +go.mongodb.org/atlas v0.14.1-0.20211216094555-210b54c6a1ca/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8= go.mongodb.org/realm v0.1.0 h1:zJiXyLaZrznQ+Pz947ziSrDKUep39DO4SfA0Fzx8M4M= go.mongodb.org/realm v0.1.0/go.mod h1:4Vj6iy+Puo1TDERcoh4XZ+pjtwbOzPpzqy3Cwe8ZmDM= go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o= From 71b9b9fe1155a481aa76cdcc89977275869dd8bc Mon Sep 17 00:00:00 2001 From: Abner Garcia Date: Fri, 17 Dec 2021 14:30:18 -0700 Subject: [PATCH 5/8] fix lint issueS --- ...data_source_mongodbatlas_privatelink_endpoints_service_adl.go | 1 - .../resource_mongodbatlas_privatelink_endpoint_service_adl.go | 1 - ...esource_mongodbatlas_privatelink_endpoint_service_adl_test.go | 1 - 3 files changed, 3 deletions(-) diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go index d7f0a2474b..0d20b4a608 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go @@ -67,7 +67,6 @@ func dataSourceMongoDBAtlasPrivateLinkEndpointsServiceADL() *schema.Resource { } func dataSourceMongoDBAtlasPrivateLinkEndpointsServiceADLRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go index 924d079569..a35a8e74f0 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go @@ -101,7 +101,6 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADLCreate(ctx context.Context })) return resourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx, d, meta) - } func resourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go index 2d6c49a4b2..e3de246295 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl_test.go @@ -46,7 +46,6 @@ func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceADL_basic(t *testing.T }, }, }) - } func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceADL_importBasic(t *testing.T) { From 62f241ea1c14043445bde6e3f93bd3a0b8824536 Mon Sep 17 00:00:00 2001 From: Abner Garcia Date: Mon, 20 Dec 2021 10:53:50 -0700 Subject: [PATCH 6/8] fix --- ...atlas_privatelink_endpoints_service_adl.go | 22 ++++++++++--------- ...batlas_privatelink_endpoint_service_adl.go | 4 +--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go index 0d20b4a608..e31368028b 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go @@ -110,16 +110,18 @@ func flattenADLPrivateEndpointLinks(links []*matlas.Link) []map[string]interface func flattenADLPrivateLinkEndpoints(privateLinks []*matlas.PrivateLinkEndpointDataLake) []map[string]interface{} { var results []map[string]interface{} - if len(privateLinks) > 0 { - results = make([]map[string]interface{}, len(privateLinks)) - - for k, privateLink := range privateLinks { - results[k] = map[string]interface{}{ - "endpoint_id": privateLink.EndpointID, - "type": privateLink.Type, - "provider_name": privateLink.Provider, - "comment": privateLink.Comment, - } + if len(privateLinks) == 0 { + return results + } + + results = make([]map[string]interface{}, len(privateLinks)) + + for k, privateLink := range privateLinks { + results[k] = map[string]interface{}{ + "endpoint_id": privateLink.EndpointID, + "type": privateLink.Type, + "provider_name": privateLink.Provider, + "comment": privateLink.Comment, } } diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go index a35a8e74f0..0d487f6411 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go @@ -114,9 +114,7 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx context.Context, if err != nil { // case 404 // deleted in the backend case - reset := strings.Contains(err.Error(), "404") && !d.IsNewResource() - - if reset { + if strings.Contains(err.Error(), "404") { d.SetId("") return nil } From 91a7c7c3027fdda9d38f98898691fc4f49673961 Mon Sep 17 00:00:00 2001 From: Abner Garcia Date: Mon, 20 Dec 2021 11:00:51 -0700 Subject: [PATCH 7/8] fix --- go.sum | 12 ++++++++++++ ..._mongodbatlas_privatelink_endpoint_service_adl.go | 4 +--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/go.sum b/go.sum index 58122e5e48..7b95dcca99 100644 --- a/go.sum +++ b/go.sum @@ -1199,6 +1199,7 @@ go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsX go.mongodb.org/atlas v0.12.0/go.mod h1:wVCnHcm/7/IfTjEB6K8K35PLG70yGz8BdkRwX0oK9/M= go.mongodb.org/atlas v0.14.1-0.20211216094555-210b54c6a1ca h1:Am8hGiVfgnHYhWG7SmiD8yfsjM/zjydYVsOmzBoOZBY= go.mongodb.org/atlas v0.14.1-0.20211216094555-210b54c6a1ca/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8= +go.mongodb.org/realm v0.1.0 h1:zJiXyLaZrznQ+Pz947ziSrDKUep39DO4SfA0Fzx8M4M= go.mongodb.org/realm v0.1.0/go.mod h1:4Vj6iy+Puo1TDERcoh4XZ+pjtwbOzPpzqy3Cwe8ZmDM= go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o= go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= @@ -1208,6 +1209,7 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -1245,6 +1247,7 @@ golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1341,6 +1344,7 @@ golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5o golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1355,6 +1359,7 @@ golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c h1:pkQiBZBvdos9qq4wBAHqlzuZHEXo07pqV06ef90u1WI= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1463,6 +1468,7 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210601080250-7ecdf8ef093b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 h1:faDu4veV+8pcThn4fewv6TVlNCezafGoC1gM/mxQLbQ= golang.org/x/sys v0.0.0-20210611083646-a4fc73990273/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1473,6 +1479,7 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1609,6 +1616,7 @@ google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= google.golang.org/api v0.46.0/go.mod h1:ceL4oozhkAiTID8XMmJBsIxID/9wMXJVVFXPg4ylg3I= google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= +google.golang.org/api v0.48.0 h1:RDAPWfNFY06dffEXfn7hZF5Fr1ZbnChzfQZAPyBd1+I= google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1674,6 +1682,7 @@ google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQ google.golang.org/genproto v0.0.0-20210517163617-5e0236093d7a/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210601144548-a796c710e9b6/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08 h1:pc16UedxnxXXtGxHCSUhafAoVHQZ0yXl8ZelMH4EETc= google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= @@ -1703,6 +1712,7 @@ google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -1716,6 +1726,7 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= @@ -1751,6 +1762,7 @@ gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.6/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go index c82d21b130..a8506a7b05 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go @@ -46,9 +46,7 @@ func dataSourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx context.Context if err != nil { // case 404 // deleted in the backend case - reset := strings.Contains(err.Error(), "404") && !d.IsNewResource() - - if reset { + if strings.Contains(err.Error(), "404") { d.SetId("") return nil } From ab3a9ff3ea394aa2b6252aa72f9a3bbd5eff19c8 Mon Sep 17 00:00:00 2001 From: Abner Garcia Date: Mon, 3 Jan 2022 13:31:12 -0700 Subject: [PATCH 8/8] fix documentation --- ...ce_mongodbatlas_privatelink_endpoint_service_adl.go | 2 +- ...e_mongodbatlas_privatelink_endpoints_service_adl.go | 9 ++++----- ...ce_mongodbatlas_privatelink_endpoint_service_adl.go | 6 +++--- .../d/privatelink_endpoint_service_adl.html.markdown | 10 +++++----- .../d/privatelink_endpoints_service_adl.html.markdown | 10 +++++----- .../r/privatelink_endpoint_service_adl.html.markdown | 4 ++-- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go index a8506a7b05..6e06cb96cf 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_adl.go @@ -51,7 +51,7 @@ func dataSourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx context.Context return nil } - return diag.Errorf("error getting adl private link endpoint information: %s", err) + return diag.Errorf("error getting ADL PrivateLink Endpoint Information: %s", err) } if err := d.Set("endpoint_id", privateLinkResponse.EndpointID); err != nil { diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go index e31368028b..ba84d25cd6 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoints_service_adl.go @@ -2,7 +2,6 @@ package mongodbatlas import ( "context" - "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -73,19 +72,19 @@ func dataSourceMongoDBAtlasPrivateLinkEndpointsServiceADLRead(ctx context.Contex privateLinkEndpoints, _, err := conn.DataLakes.ListPrivateLinkEndpoint(ctx, projectID) if err != nil { - return diag.FromErr(fmt.Errorf("error getting privateLinkEndpoints information: %s", err)) + return diag.Errorf("error getting ADL PrivateLink Endpoints Information: %s", err) } if err := d.Set("links", flattenADLPrivateEndpointLinks(privateLinkEndpoints.Links)); err != nil { - return diag.FromErr(fmt.Errorf("error setting `results`: %s", err)) + return diag.Errorf("error setting `results`: %s", err) } if err := d.Set("results", flattenADLPrivateLinkEndpoints(privateLinkEndpoints.Results)); err != nil { - return diag.FromErr(fmt.Errorf("error setting `results`: %s", err)) + return diag.Errorf("error setting `results`: %s", err) } if err := d.Set("total_count", privateLinkEndpoints.TotalCount); err != nil { - return diag.FromErr(fmt.Errorf("error setting `total_count`: %s", err)) + return diag.Errorf("error setting `total_count`: %s", err) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go index 0d487f6411..de1c5a87c5 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_adl.go @@ -14,7 +14,7 @@ import ( ) const ( - errorADLServiceEndpointAdd = "error adding MongoDB ADL Private Link Endpoint Connection(%s): %s" + errorADLServiceEndpointAdd = "error adding MongoDB ADL PrivateLink Endpoint Connection(%s): %s" ) func resourceMongoDBAtlasPrivateLinkEndpointServiceADL() *schema.Resource { @@ -63,7 +63,7 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADLUpdate(ctx context.Context privateLink, _, err := conn.DataLakes.GetPrivateLinkEndpoint(ctx, projectID, endpointID) if err != nil { - return diag.Errorf("error getting private link endpoint information: %s", err) + return diag.Errorf("error getting ADL PrivateLink Endpoint Information: %s", err) } if d.HasChange("comment") { @@ -72,7 +72,7 @@ func resourceMongoDBAtlasPrivateLinkEndpointServiceADLUpdate(ctx context.Context _, _, err = conn.DataLakes.CreatePrivateLinkEndpoint(context.Background(), projectID, privateLink) if err != nil { - return diag.Errorf("error updating private link endpoint (%s): %s", privateLink.EndpointID, err) + return diag.Errorf("error updating ADL PrivateLink endpoint (%s): %s", privateLink.EndpointID, err) } return resourceMongoDBAtlasPrivateLinkEndpointServiceADLRead(ctx, d, meta) diff --git a/website/docs/d/privatelink_endpoint_service_adl.html.markdown b/website/docs/d/privatelink_endpoint_service_adl.html.markdown index 21c0c149ec..e17e40ab72 100644 --- a/website/docs/d/privatelink_endpoint_service_adl.html.markdown +++ b/website/docs/d/privatelink_endpoint_service_adl.html.markdown @@ -3,13 +3,13 @@ layout: "mongodbatlas" page_title: "MongoDB Atlas: privatelink_endpoint_service_adl" sidebar_current: "docs-mongodbatlas-datasource-privatelink-endpoint-service-adl" description: |- -Describes a DataLake and Online Archive private link endpoint. +Describes an Atlas Data Lake and Online Archive PrivateLink endpoint --- # privatelink_endpoint_service_adl -`privatelink_endpoint_service_adl` Provides DataLake and Online Archive private link endpoint resource. +`privatelink_endpoint_service_adl` Provides an Atlas Data Lake (ADL) and Online Archive PrivateLink endpoint resource. -> **NOTE:** Groups and projects are synonymous terms. You may find group_id in the official documentation. @@ -20,7 +20,7 @@ Describes a DataLake and Online Archive private link endpoint. resource "mongodbatlas_privatelink_endpoint_service_adl" "adl_test" { project_id = "" endpoint_id = "" - comment = "comments for private link endpoint adl" + comment = "Comment for PrivateLink endpoint ADL" type = "DATA_LAKE" provider_name = "AWS" } @@ -41,8 +41,8 @@ data "mongodbatlas_privatelink_endpoint_service_adl" "test" { In addition to all arguments above, the following attributes are exported: -* `type` - Human-readable label that identifies the resource associated with this private endpoint. Value is `DATA_LAKE`. -* `provider_name` - Human-readable label that identifies the cloud provider for this endpoint. Value is AWS. +* `type` - Human-readable label that identifies the type of resource to associate with this private endpoint. +* `provider_name` - Human-readable label that identifies the cloud provider for this endpoint. * `comment` - Human-readable string to associate with this private endpoint. For more information see: [MongoDB Atlas API - DataLake](https://docs.mongodb.com/datalake/reference/api/datalakes-api/) and [MongoDB Atlas API - Online Archive](https://docs.atlas.mongodb.com/reference/api/online-archive/) Documentation. diff --git a/website/docs/d/privatelink_endpoints_service_adl.html.markdown b/website/docs/d/privatelink_endpoints_service_adl.html.markdown index 59592af2bf..4ea323a1f3 100644 --- a/website/docs/d/privatelink_endpoints_service_adl.html.markdown +++ b/website/docs/d/privatelink_endpoints_service_adl.html.markdown @@ -3,12 +3,12 @@ layout: "mongodbatlas" page_title: "MongoDB Atlas: privatelink_endpoints_service_adl" sidebar_current: "docs-mongodbatlas-datasource-privatelink-endpoints-service-adl" description: |- -Describes the list of all DataLake and Online Archive private link endpoints. +Describes the list of all Atlas Data Lake and Online Archive PrivateLink endpoints. --- # privatelink_endpoints_service_adl -`privatelink_endpoints_service_adl` Describes the list of all DataLake and Online Archive private link endpoints. +`privatelink_endpoints_service_adl` Describes the list of all Atlas Data Lake (ADL) and Online Archive PrivateLink endpoints resource. -> **NOTE:** Groups and projects are synonymous terms. You may find group_id in the official documentation. @@ -20,7 +20,7 @@ Describes the list of all DataLake and Online Archive private link endpoints. resource "mongodbatlas_privatelink_endpoint_service_adl" "adl_test" { project_id = "" endpoint_id = "" - comment = "comments for private link endpoint adl" + comment = "Comment for PrivateLink endpoint ADL" type = "DATA_LAKE" provider_name = "AWS" } @@ -51,8 +51,8 @@ Each object in the `links` array represents an online archive with the following Each object in the `results` array represents an online archive with the following attributes: * `endpoint_id` - (Required) Unique 22-character alphanumeric string that identifies the private endpoint. Atlas supports AWS private endpoints using the [|aws| PrivateLink](https://aws.amazon.com/privatelink/) feature. -* `type` - Human-readable label that identifies the resource associated with this private endpoint. Value is `DATA_LAKE`. -* `provider_name` - Human-readable label that identifies the cloud provider for this endpoint. Value is AWS. +* `type` - Human-readable label that identifies the type of resource to associate with this private endpoint. +* `provider_name` - Human-readable label that identifies the cloud provider for this endpoint. * `comment` - Human-readable string to associate with this private endpoint. See [MongoDB Atlas API](https://docs.atlas.mongodb.com/reference/api/online-archive-get-all-for-cluster/) Documentation for more information. diff --git a/website/docs/r/privatelink_endpoint_service_adl.html.markdown b/website/docs/r/privatelink_endpoint_service_adl.html.markdown index 4b8b6648c1..b4423e401a 100644 --- a/website/docs/r/privatelink_endpoint_service_adl.html.markdown +++ b/website/docs/r/privatelink_endpoint_service_adl.html.markdown @@ -3,13 +3,13 @@ layout: "mongodbatlas" page_title: "MongoDB Atlas: privatelink_endpoint_service_adl" sidebar_current: "docs-mongodbatlas-resource-privatelink-endpoint-service-adl" description: |- -Provides DataLake and Online Archive private link endpoint. +Provides an Atlas Data Lake and Online Archive PrivateLink endpoint. --- # privatelink_endpoint_service_adl -`privatelink_endpoint_service_adl` Describe a DataLake and Online Archive private link endpoint resource. +`privatelink_endpoint_service_adl` Provides an Atlas Data Lake (ADL) and Online Archive PrivateLink endpoint resource. The same configuration will provide a PrivateLink connection for either Atlas Data Lake or Online Archive. ## Example Usage