From 3e1befb25842f5c93fa8992f309363da1f143950 Mon Sep 17 00:00:00 2001 From: coderGo93 Date: Mon, 28 Jun 2021 18:37:21 -0600 Subject: [PATCH] INTMDB-214: Deprecation of private endpoint (#484) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * deleted deprecated resource, datasource and docs of private endpoint * added upgrade guide for deprecation private endpoint * changed name of resource * added terratest for deprecation private endpoint and import with privatelink endpoint * added comments Co-authored-by: Edgar López --- examples/aws-atlas-privatelink/atlas-pl.tf | 10 +- .../v100/privatelink-endpoint/v091/main.tf | 44 ++++ .../privatelink-endpoint/v091/variables.tf | 44 ++++ .../privatelink-endpoint/v091/versions.tf | 9 + .../v100/privatelink-endpoint/v100/main.tf | 34 +++ .../privatelink-endpoint/v100/variables.tf | 44 ++++ .../privatelink-endpoint/v100/versions.tf | 9 + integration-testing/test-upgrades_test.go | 73 ++++++ ...ta_source_mongodbatlas_private_endpoint.go | 88 ------- ...dbatlas_private_endpoint_interface_link.go | 81 ------ ...as_private_endpoint_interface_link_test.go | 79 ------ ...urce_mongodbatlas_private_endpoint_test.go | 47 ---- mongodbatlas/provider.go | 4 - .../resource_mongodbatlas_private_endpoint.go | 244 ------------------ ...dbatlas_private_endpoint_interface_link.go | 223 ---------------- ...as_private_endpoint_interface_link_test.go | 220 ---------------- ...urce_mongodbatlas_private_endpoint_test.go | 145 ----------- ...ngodbatlas_privatelink_endpoint_service.go | 8 +- website/docs/d/private_endpoint.html.markdown | 59 ----- ...vate_endpoint_interface_link.html.markdown | 70 ----- .../guides/1.0.0-upgrade-guide.html.markdown | 38 +++ website/docs/r/private_endpoint.html.markdown | 84 ------ ...vate_endpoint_interface_link.html.markdown | 76 ------ 23 files changed, 304 insertions(+), 1429 deletions(-) create mode 100644 examples/test-upgrade/v100/privatelink-endpoint/v091/main.tf create mode 100644 examples/test-upgrade/v100/privatelink-endpoint/v091/variables.tf create mode 100644 examples/test-upgrade/v100/privatelink-endpoint/v091/versions.tf create mode 100644 examples/test-upgrade/v100/privatelink-endpoint/v100/main.tf create mode 100644 examples/test-upgrade/v100/privatelink-endpoint/v100/variables.tf create mode 100644 examples/test-upgrade/v100/privatelink-endpoint/v100/versions.tf delete mode 100644 mongodbatlas/data_source_mongodbatlas_private_endpoint.go delete mode 100644 mongodbatlas/data_source_mongodbatlas_private_endpoint_interface_link.go delete mode 100644 mongodbatlas/data_source_mongodbatlas_private_endpoint_interface_link_test.go delete mode 100644 mongodbatlas/data_source_mongodbatlas_private_endpoint_test.go delete mode 100644 mongodbatlas/resource_mongodbatlas_private_endpoint.go delete mode 100644 mongodbatlas/resource_mongodbatlas_private_endpoint_interface_link.go delete mode 100644 mongodbatlas/resource_mongodbatlas_private_endpoint_interface_link_test.go delete mode 100644 mongodbatlas/resource_mongodbatlas_private_endpoint_test.go delete mode 100644 website/docs/d/private_endpoint.html.markdown delete mode 100644 website/docs/d/private_endpoint_interface_link.html.markdown delete mode 100644 website/docs/r/private_endpoint.html.markdown delete mode 100644 website/docs/r/private_endpoint_interface_link.html.markdown diff --git a/examples/aws-atlas-privatelink/atlas-pl.tf b/examples/aws-atlas-privatelink/atlas-pl.tf index bb15d8732e..40e72eddfc 100644 --- a/examples/aws-atlas-privatelink/atlas-pl.tf +++ b/examples/aws-atlas-privatelink/atlas-pl.tf @@ -1,4 +1,4 @@ -resource "mongodbatlas_private_endpoint" "atlaspl" { +resource "mongodbatlas_privatelink_endpoint" "atlaspl" { project_id = var.atlasprojectid provider_name = "AWS" region = var.aws_region @@ -6,14 +6,14 @@ resource "mongodbatlas_private_endpoint" "atlaspl" { resource "aws_vpc_endpoint" "ptfe_service" { vpc_id = aws_vpc.primary.id - service_name = mongodbatlas_private_endpoint.atlaspl.endpoint_service_name + service_name = mongodbatlas_privatelink_endpoint.atlaspl.endpoint_service_name vpc_endpoint_type = "Interface" subnet_ids = [aws_subnet.primary-az1.id, aws_subnet.primary-az2.id] security_group_ids = [aws_security_group.primary_default.id] } -resource "mongodbatlas_private_endpoint_interface_link" "atlaseplink" { - project_id = mongodbatlas_private_endpoint.atlaspl.project_id - private_link_id = mongodbatlas_private_endpoint.atlaspl.private_link_id +resource "mongodbatlas_privatelink_endpoint_service" "atlaseplink" { + project_id = mongodbatlas_privatelink_endpoint.atlaspl.project_id + private_link_id = mongodbatlas_privatelink_endpoint.atlaspl.private_link_id interface_endpoint_id = aws_vpc_endpoint.ptfe_service.id } diff --git a/examples/test-upgrade/v100/privatelink-endpoint/v091/main.tf b/examples/test-upgrade/v100/privatelink-endpoint/v091/main.tf new file mode 100644 index 0000000000..b299e372eb --- /dev/null +++ b/examples/test-upgrade/v100/privatelink-endpoint/v091/main.tf @@ -0,0 +1,44 @@ +// This config will create aws endpoint, private endpoint and private endpoint interface +// To verify that everything is working even after terraform plan and show not changes +// and then do the import stuff in the folder for v100 + +resource "mongodbatlas_project" "test" { + name = var.project_name + org_id = var.org_id +} + +provider "aws" { + region = "us-east-1" + access_key = var.aws_access_key + secret_key = var.aws_secret_key +} + +resource "mongodbatlas_private_endpoint" "test" { + project_id = mongodbatlas_project.test.id + provider_name = "AWS" + region = "us-east-1" +} + +resource "aws_vpc_endpoint" "ptfe_service" { + vpc_id = var.aws_vpc_id + service_name = mongodbatlas_private_endpoint.test.endpoint_service_name + vpc_endpoint_type = "Interface" + subnet_ids = [var.aws_subnet_ids] + security_group_ids = [var.aws_sg_ids] +} + +resource "mongodbatlas_private_endpoint_interface_link" "test" { + project_id = mongodbatlas_private_endpoint.test.project_id + private_link_id = mongodbatlas_private_endpoint.test.private_link_id + interface_endpoint_id = aws_vpc_endpoint.ptfe_service.id +} + +output "project_id" { + value = mongodbatlas_project.test.id +} +output "private_endpoint_id" { + value = mongodbatlas_private_endpoint.test.private_link_id +} +output "vpc_endpoint_id" { + value = aws_vpc_endpoint.ptfe_service.id +} diff --git a/examples/test-upgrade/v100/privatelink-endpoint/v091/variables.tf b/examples/test-upgrade/v100/privatelink-endpoint/v091/variables.tf new file mode 100644 index 0000000000..a00f366374 --- /dev/null +++ b/examples/test-upgrade/v100/privatelink-endpoint/v091/variables.tf @@ -0,0 +1,44 @@ +variable "public_key" { + description = "The public API key for MongoDB Atlas" + default = "" +} +variable "private_key" { + description = "The private API key for MongoDB Atlas" + default = "" +} +variable "project_name" { + description = "Atlas project name" + default = "" +} +variable "org_id" { + description = "The organization ID" + default = "" +} +variable "username" { + description = "Username" + default = "" +} +variable "role_name" { + description = "The role name" + default = "" +} +variable "aws_access_key" { + description = "The access key for AWS Account" + default = "" +} +variable "aws_secret_key" { + description = "The secret key for AWS Account" + default = "" +} +variable "aws_vpc_id" { + description = "The secret key for AWS Account" + default = "" +} +variable "aws_subnet_ids" { + description = "The secret key for AWS Account" + default = "" +} +variable "aws_sg_ids" { + description = "The secret key for AWS Account" + default = "" +} diff --git a/examples/test-upgrade/v100/privatelink-endpoint/v091/versions.tf b/examples/test-upgrade/v100/privatelink-endpoint/v091/versions.tf new file mode 100644 index 0000000000..158ddeb04b --- /dev/null +++ b/examples/test-upgrade/v100/privatelink-endpoint/v091/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + mongodbatlas = { + source = "mongodb/mongodbatlas" + version = "0.9.1" + } + } + required_version = ">= 0.15" +} diff --git a/examples/test-upgrade/v100/privatelink-endpoint/v100/main.tf b/examples/test-upgrade/v100/privatelink-endpoint/v100/main.tf new file mode 100644 index 0000000000..453aeeac3e --- /dev/null +++ b/examples/test-upgrade/v100/privatelink-endpoint/v100/main.tf @@ -0,0 +1,34 @@ +// This is only for import stuff because it needs the resource names and set to +// avoid changes when terraform plan + +resource "mongodbatlas_project" "test" { + name = var.project_name + org_id = var.org_id +} + +provider "aws" { + region = "us-east-1" + access_key = var.aws_access_key + secret_key = var.aws_secret_key +} + +resource "mongodbatlas_privatelink_endpoint" "test" { + project_id = mongodbatlas_project.test.id + provider_name = "AWS" + region = "us-east-1" +} + +resource "aws_vpc_endpoint" "ptfe_service" { + vpc_id = var.aws_vpc_id + service_name = mongodbatlas_privatelink_endpoint.test.endpoint_service_name + vpc_endpoint_type = "Interface" + subnet_ids = [var.aws_subnet_ids] + security_group_ids = [var.aws_sg_ids] +} + +resource "mongodbatlas_privatelink_endpoint_service" "test" { + project_id = mongodbatlas_privatelink_endpoint.test.project_id + private_link_id = mongodbatlas_privatelink_endpoint.test.private_link_id + endpoint_service_id = aws_vpc_endpoint.ptfe_service.id + provider_name = "AWS" +} \ No newline at end of file diff --git a/examples/test-upgrade/v100/privatelink-endpoint/v100/variables.tf b/examples/test-upgrade/v100/privatelink-endpoint/v100/variables.tf new file mode 100644 index 0000000000..a00f366374 --- /dev/null +++ b/examples/test-upgrade/v100/privatelink-endpoint/v100/variables.tf @@ -0,0 +1,44 @@ +variable "public_key" { + description = "The public API key for MongoDB Atlas" + default = "" +} +variable "private_key" { + description = "The private API key for MongoDB Atlas" + default = "" +} +variable "project_name" { + description = "Atlas project name" + default = "" +} +variable "org_id" { + description = "The organization ID" + default = "" +} +variable "username" { + description = "Username" + default = "" +} +variable "role_name" { + description = "The role name" + default = "" +} +variable "aws_access_key" { + description = "The access key for AWS Account" + default = "" +} +variable "aws_secret_key" { + description = "The secret key for AWS Account" + default = "" +} +variable "aws_vpc_id" { + description = "The secret key for AWS Account" + default = "" +} +variable "aws_subnet_ids" { + description = "The secret key for AWS Account" + default = "" +} +variable "aws_sg_ids" { + description = "The secret key for AWS Account" + default = "" +} diff --git a/examples/test-upgrade/v100/privatelink-endpoint/v100/versions.tf b/examples/test-upgrade/v100/privatelink-endpoint/v100/versions.tf new file mode 100644 index 0000000000..952cf2256f --- /dev/null +++ b/examples/test-upgrade/v100/privatelink-endpoint/v100/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + mongodbatlas = { + source = "mongodb/mongodbatlas" + version = "0.1.0-dev" + } + } + required_version = ">= 0.15" +} diff --git a/integration-testing/test-upgrades_test.go b/integration-testing/test-upgrades_test.go index 3a2d629fd8..c89fd90105 100644 --- a/integration-testing/test-upgrades_test.go +++ b/integration-testing/test-upgrades_test.go @@ -466,6 +466,79 @@ func TestUpgradeDesignIDState(t *testing.T) { terraform.Plan(t, terraformOptionsSnapshotRestore) } +func TestUpgradePrivateLinkEndpointDeprecation(t *testing.T) { + t.Parallel() + + var ( + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acctest.RandomWithPrefix("test-acc") + publicKey = os.Getenv("MONGODB_ATLAS_PUBLIC_KEY") + privateKey = os.Getenv("MONGODB_ATLAS_PRIVATE_KEY") + awsAccess = os.Getenv("AWS_ACCESS_KEY_ID") + awsSecret = os.Getenv("AWS_SECRET_ACCESS_KEY") + awsVPC = os.Getenv("AWS_VPC_ID") + awsSubnets = os.Getenv("AWS_SUBNET_ID") + awsSG = os.Getenv("AWS_SECURITY_GROUP_ID") + ) + // Construct the terraform options with default retryable errors to handle the most common + // retryable errors in terraform testing. + terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ + // The path to where our Terraform code is located + TerraformDir: "../examples/test-upgrade/v100/privatelink-endpoint/v091", + Vars: map[string]interface{}{ + "project_name": projectName, + "org_id": orgID, + "public_key": publicKey, + "private_key": privateKey, + "aws_access_key": awsAccess, + "aws_secret_key": awsSecret, + "aws_vpc_id": awsVPC, + "aws_subnet_ids": awsSubnets, + "aws_sg_ids": awsSG, + }, + }) + + // At the end of the test, run `terraform destroy` to clean up any resources that were created. + defer terraform.Destroy(t, terraformOptions) + + // Run `terraform init` and `terraform apply`. Fail the test if there are any errors. + terraform.InitAndApply(t, terraformOptions) + + terraform.Plan(t, terraformOptions) + + projectID := terraform.Output(t, terraformOptions, "project_id") + vpcEndpoint := terraform.Output(t, terraformOptions, "vpc_endpoint_id") + privateEndpoint := terraform.Output(t, terraformOptions, "private_endpoint_id") + + tempTestFolder := CleanUpState(t, "examples/test-upgrade/v100/privatelink-endpoint/v100") + + terraformOptionsSecond := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ + // The path to where our Terraform code is located + TerraformDir: tempTestFolder, + Vars: map[string]interface{}{ + "project_name": projectName, + "org_id": orgID, + "public_key": publicKey, + "private_key": privateKey, + "aws_access_key": awsAccess, + "aws_secret_key": awsSecret, + "aws_vpc_id": awsVPC, + "aws_subnet_ids": awsSubnets, + "aws_sg_ids": awsSG, + }, + }) + + terraform.RunTerraformCommand(t, terraformOptionsSecond, "init", fmt.Sprintf("--plugin-dir=%s", localPluginPath)) + //Remove states + terraform.RunTerraformCommand(t, terraformOptionsSecond, "import", "mongodbatlas_project.test", projectID) + terraform.RunTerraformCommand(t, terraformOptionsSecond, "import", "mongodbatlas_privatelink_endpoint.test", fmt.Sprintf("%s-%s-%s-%s", projectID, privateEndpoint, "AWS", "us-east-1")) + terraform.RunTerraformCommand(t, terraformOptionsSecond, "import", "aws_vpc_endpoint.ptfe_service", vpcEndpoint) + terraform.RunTerraformCommand(t, terraformOptionsSecond, "import", "mongodbatlas_privatelink_endpoint_service.test", fmt.Sprintf("%s--%s--%s--%s", projectID, privateEndpoint, vpcEndpoint, "AWS")) + // Run `terraform apply`. Fail the test if there are any errors. + terraform.Plan(t, terraformOptionsSecond) + +} + // This func means that the terraform state will be always clean to avoid error about resource already used func CleanUpState(t *testing.T, path string) string { // Root folder where terraform files should be (relative to the test folder) diff --git a/mongodbatlas/data_source_mongodbatlas_private_endpoint.go b/mongodbatlas/data_source_mongodbatlas_private_endpoint.go deleted file mode 100644 index 16426951f9..0000000000 --- a/mongodbatlas/data_source_mongodbatlas_private_endpoint.go +++ /dev/null @@ -1,88 +0,0 @@ -package mongodbatlas - -import ( - "context" - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - - matlas "go.mongodb.org/atlas/mongodbatlas" -) - -func dataSourceMongoDBAtlasPrivateEndpoint() *schema.Resource { - return &schema.Resource{ - Read: dataSourceMongoDBAtlasPrivateEndpointrRead, - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "private_link_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "endpoint_service_name": { - Type: schema.TypeString, - Computed: true, - }, - "error_message": { - Type: schema.TypeString, - Computed: true, - }, - "interface_endpoints": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - }, - DeprecationMessage: "this data source is deprecated, please transition as soon as possible to mongodbatlas_privatelink_endpoint", - } -} - -func dataSourceMongoDBAtlasPrivateEndpointrRead(d *schema.ResourceData, meta interface{}) error { - // Get client connection. - conn := meta.(*matlas.Client) - - projectID := d.Get("project_id").(string) - privateLinkID := d.Get("private_link_id").(string) - - privateEndpoint, _, err := conn.PrivateEndpointsDeprecated.Get(context.Background(), projectID, privateLinkID) - if err != nil { - return fmt.Errorf(errorPrivateEndpointsRead, privateLinkID, err) - } - - if err := d.Set("private_link_id", privateEndpoint.ID); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "private_link_id", privateLinkID, err) - } - - if err := d.Set("endpoint_service_name", privateEndpoint.EndpointServiceName); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "endpoint_service_name", privateLinkID, err) - } - - if err := d.Set("error_message", privateEndpoint.ErrorMessage); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "error_message", privateLinkID, err) - } - - if err := d.Set("interface_endpoints", privateEndpoint.InterfaceEndpoints); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "interface_endpoints", privateLinkID, err) - } - - if err := d.Set("status", privateEndpoint.Status); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "status", privateLinkID, err) - } - - d.SetId(encodeStateID(map[string]string{ - "private_link_id": privateEndpoint.ID, - "project_id": projectID, - })) - - return nil -} diff --git a/mongodbatlas/data_source_mongodbatlas_private_endpoint_interface_link.go b/mongodbatlas/data_source_mongodbatlas_private_endpoint_interface_link.go deleted file mode 100644 index 5aaf127285..0000000000 --- a/mongodbatlas/data_source_mongodbatlas_private_endpoint_interface_link.go +++ /dev/null @@ -1,81 +0,0 @@ -package mongodbatlas - -import ( - "context" - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/spf13/cast" - - matlas "go.mongodb.org/atlas/mongodbatlas" -) - -func dataSourceMongoDBAtlasPrivateEndpointInterfaceLink() *schema.Resource { - return &schema.Resource{ - Read: dataSourceMongoDBAtlasPrivateEndpointInterfaceLinkRead, - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "private_link_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "interface_endpoint_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "delete_requested": { - Type: schema.TypeBool, - Computed: true, - }, - "error_message": { - Type: schema.TypeString, - Computed: true, - }, - "connection_status": { - Type: schema.TypeString, - Computed: true, - }, - }, - DeprecationMessage: "this data source is deprecated, please transition as soon as possible to mongodbatlas_privatelink_endpoint_service", - } -} - -func dataSourceMongoDBAtlasPrivateEndpointInterfaceLinkRead(d *schema.ResourceData, meta interface{}) error { - // Get client connection. - conn := meta.(*matlas.Client) - - projectID := d.Get("project_id").(string) - privateLinkID := d.Get("private_link_id").(string) - interfaceEndpointID := d.Get("interface_endpoint_id").(string) - - interfaceEndpoint, _, err := conn.PrivateEndpointsDeprecated.GetOneInterfaceEndpoint(context.Background(), projectID, privateLinkID, interfaceEndpointID) - if err != nil { - return fmt.Errorf(errorServiceEndpointRead, interfaceEndpointID, err) - } - - if err := d.Set("delete_requested", cast.ToBool(interfaceEndpoint.DeleteRequested)); err != nil { - return fmt.Errorf(errorEndpointSetting, "delete_requested", interfaceEndpointID, err) - } - - if err := d.Set("error_message", interfaceEndpoint.ErrorMessage); err != nil { - return fmt.Errorf(errorEndpointSetting, "error_message", interfaceEndpointID, err) - } - - if err := d.Set("connection_status", interfaceEndpoint.ConnectionStatus); err != nil { - return fmt.Errorf(errorEndpointSetting, "connection_status", interfaceEndpointID, err) - } - - d.SetId(encodeStateID(map[string]string{ - "project_id": projectID, - "private_link_id": privateLinkID, - "interface_endpoint_id": interfaceEndpoint.ID, - })) - - return nil -} diff --git a/mongodbatlas/data_source_mongodbatlas_private_endpoint_interface_link_test.go b/mongodbatlas/data_source_mongodbatlas_private_endpoint_interface_link_test.go deleted file mode 100644 index 27151f2b63..0000000000 --- a/mongodbatlas/data_source_mongodbatlas_private_endpoint_interface_link_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package mongodbatlas - -import ( - "fmt" - "os" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" -) - -func TestAccDataSourceMongoDBAtlasPrivateEndpointLink_basic(t *testing.T) { - SkipTestExtCred(t) - resourceName := "data.mongodbatlas_private_endpoint_interface_link.test" - - awsAccessKey := os.Getenv("AWS_ACCESS_KEY_ID") - awsSecretKey := os.Getenv("AWS_SECRET_ACCESS_KEY") - - projectID := os.Getenv("MONGODB_ATLAS_PROJECT_ID") - region := os.Getenv("AWS_REGION") - providerName := "AWS" - - vpcID := os.Getenv("AWS_VPC_ID") - subnetID := os.Getenv("AWS_SUBNET_ID") - securityGroupID := os.Getenv("AWS_SECURITY_GROUP_ID") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t); checkPeeringEnvAWS(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccMongoDBAtlasPrivateEndpointLinkDataSourceConfig( - awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID, - ), - Check: resource.ComposeTestCheckFunc( - testAccCheckMongoDBAtlasPrivateEndpointLinkExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttrSet(resourceName, "private_link_id"), - resource.TestCheckResourceAttrSet(resourceName, "interface_endpoint_id"), - ), - }, - }, - }) -} - -func testAccMongoDBAtlasPrivateEndpointLinkDataSourceConfig(awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID string) string { - return fmt.Sprintf(` - provider "aws" { - region = "us-east-1" - access_key = "%s" - secret_key = "%s" - } - - resource "mongodbatlas_private_endpoint" "test" { - project_id = "%s" - provider_name = "%s" - region = "%s" - } - - resource "aws_vpc_endpoint" "ptfe_service" { - vpc_id = "%s" - service_name = "${mongodbatlas_private_endpoint.test.endpoint_service_name}" - vpc_endpoint_type = "Interface" - subnet_ids = ["%s"] - security_group_ids = ["%s"] - } - - resource "mongodbatlas_private_endpoint_interface_link" "test" { - project_id = "${mongodbatlas_private_endpoint.test.project_id}" - private_link_id = "${mongodbatlas_private_endpoint.test.private_link_id}" - interface_endpoint_id = "${aws_vpc_endpoint.ptfe_service.id}" - } - - data "mongodbatlas_private_endpoint_interface_link" "test" { - project_id = "${mongodbatlas_private_endpoint_interface_link.test.project_id}" - private_link_id = "${mongodbatlas_private_endpoint_interface_link.test.private_link_id}" - interface_endpoint_id = "${mongodbatlas_private_endpoint_interface_link.test.interface_endpoint_id}" - } - `, awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID) -} diff --git a/mongodbatlas/data_source_mongodbatlas_private_endpoint_test.go b/mongodbatlas/data_source_mongodbatlas_private_endpoint_test.go deleted file mode 100644 index 45232b290e..0000000000 --- a/mongodbatlas/data_source_mongodbatlas_private_endpoint_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package mongodbatlas - -import ( - "fmt" - "os" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" -) - -func TestAccDataSourceMongoDBAtlasPrivateEndpoint_basic(t *testing.T) { - SkipTestExtCred(t) - resourceName := "data.mongodbatlas_private_endpoint.test" - projectID := os.Getenv("MONGODB_ATLAS_PROJECT_ID") - region := os.Getenv("AWS_REGION") - providerName := "AWS" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAWS(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccMongoDBAtlasPrivateEndpointDataSourceConfig(projectID, providerName, region), - Check: resource.ComposeTestCheckFunc( - testAccCheckMongoDBAtlasPrivateEndpointExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttrSet(resourceName, "private_link_id"), - ), - }, - }, - }) -} - -func testAccMongoDBAtlasPrivateEndpointDataSourceConfig(projectID, providerName, region string) string { - return fmt.Sprintf(` - resource "mongodbatlas_private_endpoint" "test" { - project_id = "%s" - provider_name = "%s" - region = "%s" - } - - data "mongodbatlas_private_endpoint" "test" { - project_id = "${mongodbatlas_private_endpoint.test.project_id}" - private_link_id = "${mongodbatlas_private_endpoint.test.private_link_id}" - } - `, projectID, providerName, region) -} diff --git a/mongodbatlas/provider.go b/mongodbatlas/provider.go index 40aba5c228..584c6aa2a7 100644 --- a/mongodbatlas/provider.go +++ b/mongodbatlas/provider.go @@ -64,8 +64,6 @@ func Provider() terraform.ResourceProvider { "mongodbatlas_x509_authentication_database_user": dataSourceMongoDBAtlasX509AuthDBUser(), "mongodbatlas_privatelink_endpoint": dataSourceMongoDBAtlasPrivateLinkEndpoint(), "mongodbatlas_privatelink_endpoint_service": dataSourceMongoDBAtlasPrivateEndpointServiceLink(), - "mongodbatlas_private_endpoint": dataSourceMongoDBAtlasPrivateEndpoint(), - "mongodbatlas_private_endpoint_interface_link": dataSourceMongoDBAtlasPrivateEndpointInterfaceLink(), "mongodbatlas_cloud_provider_snapshot_backup_policy": dataSourceMongoDBAtlasCloudProviderSnapshotBackupPolicy(), "mongodbatlas_third_party_integrations": dataSourceMongoDBAtlasThirdPartyIntegrations(), "mongodbatlas_third_party_integration": dataSourceMongoDBAtlasThirdPartyIntegration(), @@ -101,8 +99,6 @@ func Provider() terraform.ResourceProvider { "mongodbatlas_x509_authentication_database_user": resourceMongoDBAtlasX509AuthDBUser(), "mongodbatlas_privatelink_endpoint": resourceMongoDBAtlasPrivateLinkEndpoint(), "mongodbatlas_privatelink_endpoint_service": resourceMongoDBAtlasPrivateEndpointServiceLink(), - "mongodbatlas_private_endpoint": resourceMongoDBAtlasPrivateEndpoint(), - "mongodbatlas_private_endpoint_interface_link": resourceMongoDBAtlasPrivateEndpointInterfaceLink(), "mongodbatlas_cloud_provider_snapshot_backup_policy": resourceMongoDBAtlasCloudProviderSnapshotBackupPolicy(), "mongodbatlas_third_party_integration": resourceMongoDBAtlasThirdPartyIntegration(), "mongodbatlas_project_ip_access_list": resourceMongoDBAtlasProjectIPAccessList(), diff --git a/mongodbatlas/resource_mongodbatlas_private_endpoint.go b/mongodbatlas/resource_mongodbatlas_private_endpoint.go deleted file mode 100644 index 97046c32d7..0000000000 --- a/mongodbatlas/resource_mongodbatlas_private_endpoint.go +++ /dev/null @@ -1,244 +0,0 @@ -package mongodbatlas - -import ( - "context" - "errors" - "fmt" - "log" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - - matlas "go.mongodb.org/atlas/mongodbatlas" -) - -const ( - errorPrivateEndpointsCreate = "error creating MongoDB Private Endpoints Connection: %s" - errorPrivateEndpointsRead = "error reading MongoDB Private Endpoints Connection(%s): %s" - errorPrivateEndpointsDelete = "error deleting MongoDB Private Endpoints Connection(%s): %s" - errorPrivateEndpointsSetting = "error setting `%s` for MongoDB Private Endpoints Connection(%s): %s" -) - -func resourceMongoDBAtlasPrivateEndpoint() *schema.Resource { - return &schema.Resource{ - Create: resourceMongoDBAtlasPrivateEndpointCreate, - Read: resourceMongoDBAtlasPrivateEndpointRead, - Delete: resourceMongoDBAtlasPrivateEndpointDelete, - Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasPrivateEndpointImportState, - }, - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "provider_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{"AWS"}, false), - }, - "region": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "private_link_id": { - Type: schema.TypeString, - Computed: true, - }, - "endpoint_service_name": { - Type: schema.TypeString, - Computed: true, - }, - "error_message": { - Type: schema.TypeString, - Computed: true, - }, - "interface_endpoints": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - }, - DeprecationMessage: "this resource is deprecated, please transition as soon as possible to mongodbatlas_privatelink_endpoint", - } -} - -func resourceMongoDBAtlasPrivateEndpointCreate(d *schema.ResourceData, meta interface{}) error { - conn := meta.(*matlas.Client) - projectID := d.Get("project_id").(string) - - request := &matlas.PrivateEndpointConnectionDeprecated{ - ProviderName: d.Get("provider_name").(string), - Region: d.Get("region").(string), - } - - privateEndpointConn, _, err := conn.PrivateEndpointsDeprecated.Create(context.Background(), projectID, request) - if err != nil { - return fmt.Errorf(errorPrivateEndpointsCreate, err) - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"INITIATING", "DELETING"}, - Target: []string{"WAITING_FOR_USER", "FAILED", "DELETED"}, - Refresh: resourcePrivateEndpointRefreshFunc(conn, projectID, privateEndpointConn.ID), - Timeout: 1 * time.Hour, - MinTimeout: 5 * time.Second, - Delay: 3 * time.Second, - } - - // Wait, catching any errors - _, err = stateConf.WaitForState() - if err != nil { - return fmt.Errorf(errorPrivateEndpointsCreate, err) - } - - d.SetId(encodeStateID(map[string]string{ - "private_link_id": privateEndpointConn.ID, - "project_id": projectID, - })) - - return resourceMongoDBAtlasPrivateEndpointRead(d, meta) -} - -func resourceMongoDBAtlasPrivateEndpointRead(d *schema.ResourceData, meta interface{}) error { - conn := meta.(*matlas.Client) - - ids := decodeStateID(d.Id()) - projectID := ids["project_id"] - privateLinkID := ids["private_link_id"] - providerName := ids["provider_name"] - region := ids["region"] - - privateEndpoint, _, err := conn.PrivateEndpointsDeprecated.Get(context.Background(), projectID, privateLinkID) - if err != nil { - return fmt.Errorf(errorPrivateEndpointsRead, privateLinkID, err) - } - - if err := d.Set("private_link_id", privateEndpoint.ID); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "private_link_id", privateLinkID, err) - } - - if err := d.Set("endpoint_service_name", privateEndpoint.EndpointServiceName); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "endpoint_service_name", privateLinkID, err) - } - - if err := d.Set("error_message", privateEndpoint.ErrorMessage); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "error_message", privateLinkID, err) - } - - if err := d.Set("interface_endpoints", privateEndpoint.InterfaceEndpoints); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "interface_endpoints", privateLinkID, err) - } - - if err := d.Set("status", privateEndpoint.Status); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "status", privateLinkID, err) - } - - if err := d.Set("provider_name", providerName); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "provider_name", privateLinkID, err) - } - - if err := d.Set("region", region); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "provider_name", privateLinkID, err) - } - - return nil -} - -func resourceMongoDBAtlasPrivateEndpointDelete(d *schema.ResourceData, meta interface{}) error { - conn := meta.(*matlas.Client) - - ids := decodeStateID(d.Id()) - privateLinkID := ids["private_link_id"] - projectID := ids["project_id"] - - resp, err := conn.PrivateEndpointsDeprecated.Delete(context.Background(), projectID, privateLinkID) - if err != nil { - if resp.Response.StatusCode == 404 { - return nil - } - - return fmt.Errorf(errorPrivateEndpointsDelete, privateLinkID, err) - } - - log.Println("[INFO] Waiting for MongoDB Private Endpoints Connection to be destroyed") - - stateConf := &resource.StateChangeConf{ - Pending: []string{"DELETING"}, - Target: []string{"DELETED", "FAILED"}, - Refresh: resourcePrivateEndpointRefreshFunc(conn, projectID, privateLinkID), - Timeout: 10 * time.Minute, - MinTimeout: 5 * time.Second, - Delay: 3 * time.Second, - } - // Wait, catching any errors - _, err = stateConf.WaitForState() - if err != nil { - return fmt.Errorf(errorPrivateEndpointsDelete, privateLinkID, err) - } - - return nil -} - -func resourceMongoDBAtlasPrivateEndpointImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - conn := meta.(*matlas.Client) - - parts := strings.Split(d.Id(), "-") - if len(parts) != 6 { - return nil, errors.New("import format error: to import a MongoDB Private Endpoint, use the format {project_id}-{private_link_id}-{provider_name}-{region} ") - } - - projectID := parts[0] - privateLinkID := parts[1] - providerName := parts[2] - region := fmt.Sprintf("%s-%s-%s", parts[3], parts[4], parts[5]) - - privateEndpoint, _, err := conn.PrivateEndpointsDeprecated.Get(context.Background(), projectID, privateLinkID) - if err != nil { - return nil, fmt.Errorf("couldn't import peer %s in project %s, error: %s", privateLinkID, projectID, err) - } - - if err := d.Set("project_id", projectID); err != nil { - log.Printf(errorPrivateEndpointsSetting, "project_id", privateLinkID, err) - } - - d.SetId(encodeStateID(map[string]string{ - "private_link_id": privateEndpoint.ID, - "project_id": projectID, - "provider_name": providerName, - "region": region, - })) - - return []*schema.ResourceData{d}, nil -} - -func resourcePrivateEndpointRefreshFunc(client *matlas.Client, projectID, privateLinkID string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - p, resp, err := client.PrivateEndpointsDeprecated.Get(context.Background(), projectID, privateLinkID) - if err != nil { - if resp.Response.StatusCode == 404 { - return "", "DELETED", nil - } - - return nil, "REJECTED", err - } - - if p.Status != "WAITING_FOR_USER" { - return "", p.Status, nil - } - - return p, p.Status, nil - } -} diff --git a/mongodbatlas/resource_mongodbatlas_private_endpoint_interface_link.go b/mongodbatlas/resource_mongodbatlas_private_endpoint_interface_link.go deleted file mode 100644 index f8a5f75dd8..0000000000 --- a/mongodbatlas/resource_mongodbatlas_private_endpoint_interface_link.go +++ /dev/null @@ -1,223 +0,0 @@ -package mongodbatlas - -import ( - "context" - "errors" - "fmt" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/spf13/cast" - - matlas "go.mongodb.org/atlas/mongodbatlas" -) - -const ( - errorInterfaceEndpointAdd = "error adding MongoDB Interface Endpoint Connection(%s) to a Private Endpoint (%s): %s" - errorInterfaceEndpointRead = "error reading MongoDB Interface Endpoint Connection(%s): %s" - errorInterfaceEndpointDelete = "error deleting MongoDB Interface Endpoints Connection(%s): %s" - errorInterfaceEndpointSetting = "error setting `%s` for MongoDB Interface Endpoints Connection(%s): %s" -) - -func resourceMongoDBAtlasPrivateEndpointInterfaceLink() *schema.Resource { - return &schema.Resource{ - Create: resourceMongoDBAtlasPrivateEndpointInterfaceLinkCreate, - Read: resourceMongoDBAtlasPrivateEndpointInterfaceLinkRead, - Delete: resourceMongoDBAtlasPrivateEndpointInterfaceLinkDelete, - Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasPrivateEndpointInterfaceLinkImportState, - }, - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "private_link_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "interface_endpoint_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "delete_requested": { - Type: schema.TypeBool, - Computed: true, - }, - "error_message": { - Type: schema.TypeString, - Computed: true, - }, - "connection_status": { - Type: schema.TypeString, - Computed: true, - }, - }, - DeprecationMessage: "this resource is deprecated, please transition as soon as possible to mongodbatlas_privatelink_endpoint_service", - } -} - -func resourceMongoDBAtlasPrivateEndpointInterfaceLinkCreate(d *schema.ResourceData, meta interface{}) error { - conn := meta.(*matlas.Client) - projectID := d.Get("project_id").(string) - privateLinkID := d.Get("private_link_id").(string) - interfaceEndpointID := d.Get("interface_endpoint_id").(string) - - interfaceEndpointConn, _, err := conn.PrivateEndpointsDeprecated.AddOneInterfaceEndpoint(context.Background(), projectID, privateLinkID, interfaceEndpointID) - if err != nil { - return fmt.Errorf(errorInterfaceEndpointAdd, interfaceEndpointID, privateLinkID, err) - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"NONE", "PENDING_ACCEPTANCE", "PENDING", "DELETING"}, - Target: []string{"AVAILABLE", "REJECTED", "DELETED"}, - Refresh: resourceInterfaceEndpointRefreshFunc(conn, projectID, privateLinkID, interfaceEndpointConn.ID), - Timeout: 1 * time.Hour, - MinTimeout: 5 * time.Second, - Delay: 3 * time.Second, - } - // Wait, catching any errors - _, err = stateConf.WaitForState() - if err != nil { - return fmt.Errorf(errorInterfaceEndpointAdd, interfaceEndpointConn.ID, privateLinkID, err) - } - - d.SetId(encodeStateID(map[string]string{ - "project_id": projectID, - "private_link_id": privateLinkID, - "interface_endpoint_id": interfaceEndpointConn.ID, - })) - - return resourceMongoDBAtlasPrivateEndpointInterfaceLinkRead(d, meta) -} - -func resourceMongoDBAtlasPrivateEndpointInterfaceLinkRead(d *schema.ResourceData, meta interface{}) error { - conn := meta.(*matlas.Client) - - ids := decodeStateID(d.Id()) - projectID := ids["project_id"] - privateLinkID := ids["private_link_id"] - interfaceEndpointID := ids["interface_endpoint_id"] - - interfaceEndpoint, _, err := conn.PrivateEndpointsDeprecated.GetOneInterfaceEndpoint(context.Background(), projectID, privateLinkID, interfaceEndpointID) - if err != nil { - return fmt.Errorf(errorInterfaceEndpointRead, interfaceEndpointID, err) - } - - if err := d.Set("delete_requested", cast.ToBool(interfaceEndpoint.DeleteRequested)); err != nil { - return fmt.Errorf(errorInterfaceEndpointSetting, "delete_requested", interfaceEndpointID, err) - } - - if err := d.Set("error_message", interfaceEndpoint.ErrorMessage); err != nil { - return fmt.Errorf(errorInterfaceEndpointSetting, "error_message", interfaceEndpointID, err) - } - - if err := d.Set("connection_status", interfaceEndpoint.ConnectionStatus); err != nil { - return fmt.Errorf(errorInterfaceEndpointSetting, "connection_status", interfaceEndpointID, err) - } - - if err := d.Set("private_link_id", privateLinkID); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "private_link_id", privateLinkID, err) - } - - if err := d.Set("interface_endpoint_id", interfaceEndpointID); err != nil { - return fmt.Errorf(errorPrivateEndpointsSetting, "interface_endpoint_id", privateLinkID, err) - } - - return nil -} - -func resourceMongoDBAtlasPrivateEndpointInterfaceLinkDelete(d *schema.ResourceData, meta interface{}) error { - conn := meta.(*matlas.Client) - - ids := decodeStateID(d.Id()) - projectID := ids["project_id"] - privateLinkID := ids["private_link_id"] - interfaceEndpointID := ids["interface_endpoint_id"] - - if interfaceEndpointID != "" { - _, err := conn.PrivateEndpointsDeprecated.DeleteOneInterfaceEndpoint(context.Background(), projectID, privateLinkID, interfaceEndpointID) - if err != nil { - return fmt.Errorf(errorInterfaceEndpointDelete, interfaceEndpointID, err) - } - - stateConf := &resource.StateChangeConf{ - Pending: []string{"NONE", "PENDING_ACCEPTANCE", "PENDING", "DELETING"}, - Target: []string{"REJECTED", "DELETED"}, - Refresh: resourceInterfaceEndpointRefreshFunc(conn, projectID, privateLinkID, interfaceEndpointID), - Timeout: 1 * time.Hour, - MinTimeout: 5 * time.Second, - Delay: 3 * time.Second, - } - - // Wait, catching any errors - _, err = stateConf.WaitForState() - if err != nil { - return fmt.Errorf(errorInterfaceEndpointDelete, interfaceEndpointID, err) - } - } - - return nil -} - -func resourceMongoDBAtlasPrivateEndpointInterfaceLinkImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - conn := meta.(*matlas.Client) - - parts := strings.SplitN(d.Id(), "-", 4) - if len(parts) != 4 { - return nil, errors.New("import format error: to import a MongoDB Private Endpoint, use the format {project_id}-{private_link_id}-{interface_endpoint_id}") - } - - projectID := parts[0] - privateLinkID := parts[1] - interfaceEndpointID := parts[2] + "-" + parts[3] - - _, _, err := conn.PrivateEndpointsDeprecated.GetOneInterfaceEndpoint(context.Background(), projectID, privateLinkID, interfaceEndpointID) - if err != nil { - return nil, fmt.Errorf(errorInterfaceEndpointRead, interfaceEndpointID, err) - } - - if err := d.Set("project_id", projectID); err != nil { - return nil, fmt.Errorf(errorPrivateEndpointsSetting, "project_id", privateLinkID, err) - } - - if err := d.Set("private_link_id", privateLinkID); err != nil { - return nil, fmt.Errorf(errorPrivateEndpointsSetting, "private_link_id", privateLinkID, err) - } - - if err := d.Set("interface_endpoint_id", interfaceEndpointID); err != nil { - return nil, fmt.Errorf(errorPrivateEndpointsSetting, "interface_endpoint_id", privateLinkID, err) - } - - d.SetId(encodeStateID(map[string]string{ - "project_id": projectID, - "private_link_id": privateLinkID, - "interface_endpoint_id": interfaceEndpointID, - })) - - return []*schema.ResourceData{d}, nil -} - -func resourceInterfaceEndpointRefreshFunc(client *matlas.Client, projectID, privateLinkID, interfaceEndpointID string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - i, resp, err := client.PrivateEndpointsDeprecated.GetOneInterfaceEndpoint(context.Background(), projectID, privateLinkID, interfaceEndpointID) - if err != nil { - if resp.Response.StatusCode == 404 { - return "", "DELETED", nil - } - - return nil, "FAILED", err - } - - if i.ConnectionStatus != "AVAILABLE" { - return "", i.ConnectionStatus, nil - } - - return i, i.ConnectionStatus, nil - } -} diff --git a/mongodbatlas/resource_mongodbatlas_private_endpoint_interface_link_test.go b/mongodbatlas/resource_mongodbatlas_private_endpoint_interface_link_test.go deleted file mode 100644 index 8295910081..0000000000 --- a/mongodbatlas/resource_mongodbatlas_private_endpoint_interface_link_test.go +++ /dev/null @@ -1,220 +0,0 @@ -package mongodbatlas - -import ( - "context" - "fmt" - "os" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - matlas "go.mongodb.org/atlas/mongodbatlas" -) - -func TestAccResourceMongoDBAtlasPrivateEndpointLink_basic(t *testing.T) { - SkipTestExtCred(t) - var ( - resourceName = "mongodbatlas_private_endpoint_interface_link.test" - projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID") - privateLinkID = os.Getenv("MONGODB_PRIVATE_LINK_ID") - interfaceEndpointID = os.Getenv("AWS_INTERFACE_ENDPOINT_ID") - ) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - checkPeeringEnvAWS(t) - func() { - if os.Getenv("MONGODB_PRIVATE_LINK_ID") == "" && os.Getenv("AWS_INTERFACE_ENDPOINT_ID") == "" { - t.Fatal("`MONGODB_PRIVATE_LINK_ID` and `AWS_INTERFACE_ENDPOINT_ID` must be set for acceptance testing") - } - }() - }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateEndpointLinkDestroy, - Steps: []resource.TestStep{ - { - Config: testAccMongoDBAtlasPrivateEndpointLinkConfigBasic(projectID, privateLinkID, interfaceEndpointID), - Check: resource.ComposeTestCheckFunc( - testAccCheckMongoDBAtlasPrivateEndpointLinkExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttrSet(resourceName, "private_link_id"), - resource.TestCheckResourceAttrSet(resourceName, "interface_endpoint_id"), - ), - }, - }, - }) -} - -func TestAccResourceMongoDBAtlasPrivateEndpointLink_Complete(t *testing.T) { - SkipTestExtCred(t) - var ( - resourceName = "mongodbatlas_private_endpoint_interface_link.test" - - awsAccessKey = os.Getenv("AWS_ACCESS_KEY_ID") - awsSecretKey = os.Getenv("AWS_SECRET_ACCESS_KEY") - - providerName = "AWS" - projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID") - region = os.Getenv("AWS_REGION") - vpcID = os.Getenv("AWS_VPC_ID") - subnetID = os.Getenv("AWS_SUBNET_ID") - securityGroupID = os.Getenv("AWS_SECURITY_GROUP_ID") - ) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t); checkPeeringEnvAWS(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateEndpointLinkDestroy, - Steps: []resource.TestStep{ - { - Config: testAccMongoDBAtlasPrivateEndpointLinkConfigComplete( - awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID, - ), - Check: resource.ComposeTestCheckFunc( - testAccCheckMongoDBAtlasPrivateEndpointLinkExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttrSet(resourceName, "private_link_id"), - resource.TestCheckResourceAttrSet(resourceName, "interface_endpoint_id"), - ), - }, - }, - }) -} - -func TestAccResourceMongoDBAtlasPrivateEndpointLink_import(t *testing.T) { - SkipTestExtCred(t) - var ( - resourceName = "mongodbatlas_private_endpoint_interface_link.test" - - awsAccessKey = os.Getenv("AWS_ACCESS_KEY_ID") - awsSecretKey = os.Getenv("AWS_SECRET_ACCESS_KEY") - - providerName = "AWS" - projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID") - region = os.Getenv("AWS_REGION") - vpcID = os.Getenv("AWS_VPC_ID") - subnetID = os.Getenv("AWS_SUBNET_ID") - securityGroupID = os.Getenv("AWS_SECURITY_GROUP_ID") - ) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAWS(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateEndpointLinkDestroy, - Steps: []resource.TestStep{ - { - Config: testAccMongoDBAtlasPrivateEndpointLinkConfigComplete( - awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID, - ), - Check: resource.ComposeTestCheckFunc( - testAccCheckMongoDBAtlasPrivateEndpointLinkExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttrSet(resourceName, "private_link_id"), - resource.TestCheckResourceAttrSet(resourceName, "interface_endpoint_id"), - ), - }, - { - ResourceName: resourceName, - ImportStateIdFunc: testAccCheckMongoDBAtlasPrivateEndpointLinkImportStateIDFunc(resourceName), - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func testAccCheckMongoDBAtlasPrivateEndpointLinkImportStateIDFunc(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-%s", ids["project_id"], ids["private_link_id"], ids["interface_endpoint_id"]), nil - } -} - -func testAccCheckMongoDBAtlasPrivateEndpointLinkExists(resourceName string) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := testAccProvider.Meta().(*matlas.Client) - - 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.PrivateEndpointsDeprecated.GetOneInterfaceEndpoint(context.Background(), ids["project_id"], ids["private_link_id"], ids["interface_endpoint_id"]) - if err == nil { - return nil - } - - return fmt.Errorf("the MongoDB Interface Endpoint(%s) for the project(%s) does not exist", rs.Primary.Attributes["interface_endpoint_id"], rs.Primary.Attributes["project_id"]) - } -} - -func testAccCheckMongoDBAtlasPrivateEndpointLinkDestroy(s *terraform.State) error { - conn := testAccProvider.Meta().(*matlas.Client) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "mongodbatlas_private_endpoint_interface_link" { - continue - } - - ids := decodeStateID(rs.Primary.ID) - _, _, err := conn.PrivateEndpointsDeprecated.GetOneInterfaceEndpoint(context.Background(), ids["project_id"], ids["private_link_id"], ids["interface_endpoint_id"]) - if err == nil { - return fmt.Errorf("the MongoDB Private Endpoint(%s) still exists", ids["interface_endpoint_id"]) - } - } - - return nil -} - -func testAccMongoDBAtlasPrivateEndpointLinkConfigComplete(awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID string) string { - return fmt.Sprintf(` - provider "aws" { - region = "us-east-1" - access_key = "%s" - secret_key = "%s" - } - - resource "mongodbatlas_private_endpoint" "test" { - project_id = "%s" - provider_name = "%s" - region = "%s" - } - - resource "aws_vpc_endpoint" "ptfe_service" { - vpc_id = "%s" - service_name = "${mongodbatlas_private_endpoint.test.endpoint_service_name}" - vpc_endpoint_type = "Interface" - subnet_ids = ["%s"] - security_group_ids = ["%s"] - } - - resource "mongodbatlas_private_endpoint_interface_link" "test" { - project_id = "${mongodbatlas_private_endpoint.test.project_id}" - private_link_id = "${mongodbatlas_private_endpoint.test.private_link_id}" - interface_endpoint_id = "${aws_vpc_endpoint.ptfe_service.id}" - } - `, awsAccessKey, awsSecretKey, projectID, providerName, region, vpcID, subnetID, securityGroupID) -} - -func testAccMongoDBAtlasPrivateEndpointLinkConfigBasic(projectID, privateLinkID, interfaceEndpointID string) string { - return fmt.Sprintf(` - resource "mongodbatlas_private_endpoint_interface_link" "test" { - project_id = "%s" - private_link_id = "%s" - interface_endpoint_id = "%s" - } - `, projectID, privateLinkID, interfaceEndpointID) -} diff --git a/mongodbatlas/resource_mongodbatlas_private_endpoint_test.go b/mongodbatlas/resource_mongodbatlas_private_endpoint_test.go deleted file mode 100644 index f2a1b7ff3d..0000000000 --- a/mongodbatlas/resource_mongodbatlas_private_endpoint_test.go +++ /dev/null @@ -1,145 +0,0 @@ -package mongodbatlas - -import ( - "context" - "fmt" - "os" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - matlas "go.mongodb.org/atlas/mongodbatlas" -) - -func TestAccResourceMongoDBAtlasPrivateEndpoint_basic(t *testing.T) { - SkipTestExtCred(t) - var ( - resourceName = "mongodbatlas_private_endpoint.test" - projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID") - region = os.Getenv("AWS_REGION") - providerName = "AWS" - ) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateEndpointDestroy, - Steps: []resource.TestStep{ - { - Config: testAccMongoDBAtlasPrivateEndpointConfigBasic(projectID, providerName, region), - Check: resource.ComposeTestCheckFunc( - testAccCheckMongoDBAtlasPrivateEndpointExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttrSet(resourceName, "provider_name"), - resource.TestCheckResourceAttrSet(resourceName, "region"), - - resource.TestCheckResourceAttr(resourceName, "project_id", projectID), - resource.TestCheckResourceAttr(resourceName, "provider_name", providerName), - resource.TestCheckResourceAttr(resourceName, "region", region), - ), - }, - }, - }) -} - -func TestAccResourceMongoDBAtlasPrivateEndpoint_import(t *testing.T) { - SkipTestExtCred(t) - var ( - resourceName = "mongodbatlas_private_endpoint.test" - projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID") - region = os.Getenv("AWS_REGION") - providerName = "AWS" - ) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAzure(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateEndpointDestroy, - Steps: []resource.TestStep{ - { - Config: testAccMongoDBAtlasPrivateEndpointConfigBasic(projectID, providerName, region), - Check: resource.ComposeTestCheckFunc( - testAccCheckMongoDBAtlasPrivateEndpointExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttrSet(resourceName, "provider_name"), - resource.TestCheckResourceAttrSet(resourceName, "region"), - - resource.TestCheckResourceAttr(resourceName, "project_id", projectID), - resource.TestCheckResourceAttr(resourceName, "provider_name", providerName), - resource.TestCheckResourceAttr(resourceName, "region", region), - ), - }, - { - ResourceName: resourceName, - ImportStateIdFunc: testAccCheckMongoDBAtlasPrivateEndpointImportStateIDFunc(resourceName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"provider_name", "region"}, - }, - }, - }) -} - -func testAccCheckMongoDBAtlasPrivateEndpointImportStateIDFunc(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["private_link_id"]), nil - } -} - -func testAccCheckMongoDBAtlasPrivateEndpointExists(resourceName string) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := testAccProvider.Meta().(*matlas.Client) - - 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) - - if _, _, err := conn.PrivateEndpointsDeprecated.Get(context.Background(), ids["project_id"], ids["private_link_id"]); err == nil { - return nil - } - - return fmt.Errorf("the MongoDB Private Endpoint(%s) for the project(%s) does not exist", rs.Primary.Attributes["private_link_id"], rs.Primary.Attributes["project_id"]) - } -} - -func testAccCheckMongoDBAtlasPrivateEndpointDestroy(s *terraform.State) error { - conn := testAccProvider.Meta().(*matlas.Client) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "mongodbatlas_private_endpoint" { - continue - } - - ids := decodeStateID(rs.Primary.ID) - _, _, err := conn.PrivateEndpointsDeprecated.Get(context.Background(), ids["project_id"], ids["private_link_id"]) - if err == nil { - return fmt.Errorf("the MongoDB Private Endpoint(%s) still exists", ids["private_link_id"]) - } - } - - return nil -} - -func testAccMongoDBAtlasPrivateEndpointConfigBasic(projectID, providerName, region string) string { - return fmt.Sprintf(` - resource "mongodbatlas_private_endpoint" "test" { - project_id = "%s" - provider_name = "%s" - region = "%s" - } - `, projectID, providerName, region) -} diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go index 5017cdf96c..a4db48970c 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go @@ -237,19 +237,19 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkImportState(d *schema.Resourc } if err := d.Set("project_id", projectID); err != nil { - return nil, fmt.Errorf(errorPrivateEndpointsSetting, "project_id", privateLinkID, err) + return nil, fmt.Errorf(errorEndpointSetting, "project_id", privateLinkID, err) } if err := d.Set("private_link_id", privateLinkID); err != nil { - return nil, fmt.Errorf(errorPrivateEndpointsSetting, "private_link_id", privateLinkID, err) + return nil, fmt.Errorf(errorEndpointSetting, "private_link_id", privateLinkID, err) } if err := d.Set("endpoint_service_id", endpointServiceID); err != nil { - return nil, fmt.Errorf(errorPrivateEndpointsSetting, "endpoint_service_id", privateLinkID, err) + return nil, fmt.Errorf(errorEndpointSetting, "endpoint_service_id", privateLinkID, err) } if err := d.Set("provider_name", providerName); err != nil { - return nil, fmt.Errorf(errorPrivateEndpointsSetting, "provider_name", privateLinkID, err) + return nil, fmt.Errorf(errorEndpointSetting, "provider_name", privateLinkID, err) } d.SetId(encodeStateID(map[string]string{ diff --git a/website/docs/d/private_endpoint.html.markdown b/website/docs/d/private_endpoint.html.markdown deleted file mode 100644 index 07f53fb3c2..0000000000 --- a/website/docs/d/private_endpoint.html.markdown +++ /dev/null @@ -1,59 +0,0 @@ ---- -layout: "mongodbatlas" -page_title: "MongoDB Atlas: private_endpoint" -sidebar_current: "docs-mongodbatlas-datasource-private-endpoint" -description: |- - Describes a Private Endpoint. ---- - -# mongodbatlas_private_endpoint - -`mongodbatlas_private_endpoint` describe a Private Endpoint. This represents a Private Endpoint Connection to retrieve details regarding a private endpoint by id in an Atlas project - -!> **WARNING:** This datasource is deprecated and will be removed in the next major version - Please transition to privatelink_endpoint as soon as possible. [PrivateLink Endpoints](https://docs.atlas.mongodb.com/reference/api/private-endpoints-service-get-one/) - --> **NOTE:** Groups and projects are synonymous terms. You may find group_id in the official documentation. - -## Example Usage - -```hcl -resource "mongodbatlas_private_endpoint" "test" { - project_id = "" - provider_name = "AWS" - region = "us-east-1" -} - -data "mongodbatlas_private_endpoint" "test" { - project_id = mongodbatlas_private_endpoint.test.project_id - private_link_id = mongodbatlas_private_endpoint.test.private_link_id -} -``` - -## Argument Reference - -* `project_id` - (Required) Unique identifier for the project. -* `private_link_id` - (Required) Unique identifier of the AWS PrivateLink connection. - - -## Attributes Reference - -In addition to all arguments above, the following attributes are exported: - -* `id` - The Terraform's unique identifier used internally for state management. -* `endpoint_service_name` - Name of the PrivateLink endpoint service in AWS. Returns null while the endpoint service is being created. -* `error_message` - Error message pertaining to the AWS PrivateLink connection. Returns null if there are no errors. -* `interface_endpoints` - Unique identifiers of the interface endpoints in your VPC that you added to the AWS PrivateLink connection. -* `status` - Status of the AWS PrivateLink connection or Status of the Azure Private Link Service. Atlas returns one of the following values: - AWS: - * `AVAILABLE` Atlas is creating the network load balancer and VPC endpoint service. - * `WAITING_FOR_USER` The Atlas network load balancer and VPC endpoint service are created and ready to receive connection requests. - * `FAILED` A system failure has occurred. - * `DELETING` The AWS PrivateLink connection is being deleted. - AZURE: - * `AVAILABLE` Atlas created the load balancer and the Private Link Service. - * `INITIATING` Atlas is creating the load balancer and the Private Link Service. - * `FAILED` Atlas failed to create the load balancer and the Private Link service. - * `DELETING` Atlas is deleting the Private Link service. - -See [MongoDB Atlas API](https://docs.atlas.mongodb.com/reference/api/private-endpoint-get-one-private-endpoint-connection/) Documentation for more information. \ No newline at end of file diff --git a/website/docs/d/private_endpoint_interface_link.html.markdown b/website/docs/d/private_endpoint_interface_link.html.markdown deleted file mode 100644 index 114d3690cb..0000000000 --- a/website/docs/d/private_endpoint_interface_link.html.markdown +++ /dev/null @@ -1,70 +0,0 @@ ---- -layout: "mongodbatlas" -page_title: "MongoDB Atlas: private_endpoint_link" -sidebar_current: "docs-mongodbatlas-datasource-private-endpoint-link" -description: |- - Describes a Private Endpoint Link. ---- - -# mongodbatlas_private_endpoint_link - -`mongodbatlas_private_endpoint_interface_link` describe a Private Endpoint Link. This represents a Private Endpoint Link Connection that wants to retrieve details in an Atlas project. - -!> **WARNING:** This datasource is deprecated and will be removed in the next major version - Please transition to privatelink_endpoint_service as soon as possible. [PrivateLink Endpoint Service](https://docs.atlas.mongodb.com/reference/api/private-endpoints-endpoint-get-one/) - --> **NOTE:** Groups and projects are synonymous terms. You may find group_id in the official documentation. - -## Example Usage - -```hcl -resource "mongodbatlas_private_endpoint" "test" { - project_id = "" - provider_name = "AWS" - region = "us-east-1" -} - -resource "aws_vpc_endpoint" "ptfe_service" { - vpc_id = "vpc-7fc0a543" - service_name = mongodbatlas_private_endpoint.test.endpoint_service_name - vpc_endpoint_type = "Interface" - subnet_ids = ["subnet-de0406d2"] - security_group_ids = ["sg-3f238186"] -} - -resource "mongodbatlas_private_endpoint_interface_link" "test" { - project_id = mongodbatlas_private_endpoint.test.project_id - private_link_id = mongodbatlas_private_endpoint.test.private_link_id - interface_endpoint_id = aws_vpc_endpoint.ptfe_service.id -} - -data "mongodbatlas_private_endpoint_interface_link" "test" { - project_id = mongodbatlas_private_endpoint_link.test.project_id - private_link_id = mongodbatlas_private_endpoint_link.test.private_link_id - interface_endpoint_id = mongodbatlas_private_endpoint_link.test.interface_endpoint_id -} -``` - -## Argument Reference - -* `project_id` - (Required) Unique identifier for the project. -* `private_link_id` - (Required) Unique identifier of the AWS PrivateLink connection. -* `interface_endpoints` - (Required) Unique identifiers of the interface endpoints in your VPC. - -## Attributes Reference - -In addition to all arguments above, the following attributes are exported: - -* `id` - The Terraform's unique identifier used internally for state management. -* `delete_requested` - Indicates if Atlas received a request to remove the interface endpoint from the private endpoint connection. -* `error_message` - Error message pertaining to the interface endpoint. Returns null if there are no errors. -* `connection_status` - Status of the interface endpoint. - Returns one of the following values: - * `NONE` - Atlas created the network load balancer and VPC endpoint service, but AWS hasn’t yet created the VPC endpoint. - * `PENDING_ACCEPTANCE` - AWS has received the connection request from your VPC endpoint to the Atlas VPC endpoint service. - * `PENDING` - AWS is establishing the connection between your VPC endpoint and the Atlas VPC endpoint service. - * `AVAILABLE` - Atlas VPC resources are connected to the VPC endpoint in your VPC. You can connect to Atlas clusters in this region using AWS PrivateLink. - * `REJECTED` - AWS failed to establish a connection between Atlas VPC resources to the VPC endpoint in your VPC. - * `DELETING` - Atlas is removing the interface endpoint from the private endpoint connection. - -See [MongoDB Atlas API](https://docs.atlas.mongodb.com/reference/api/private-endpoint-get-one-interface-endpoint/) Documentation for more information. diff --git a/website/docs/guides/1.0.0-upgrade-guide.html.markdown b/website/docs/guides/1.0.0-upgrade-guide.html.markdown index 6a7661abe5..b70800d785 100644 --- a/website/docs/guides/1.0.0-upgrade-guide.html.markdown +++ b/website/docs/guides/1.0.0-upgrade-guide.html.markdown @@ -42,6 +42,44 @@ so no changes are needed. ``` **NOTE** Doc links for [mongodbatlas_project_ip_access_list](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/project_ip_access_list) +## End of Life and removal of Private Endpoint and Private Endpoint Interface Link and import with PrivateLink Endpoint and PrivateLink Endpoint Service + +To upgrade from v0.9.1 to v1.0.0 with the existing resources `mongodbatlas_private_endpoint` and `mongodbatlas_private_endpoint_interface_link` +perform the following steps + +1. Remove your existing `mongodbatlas_private_endpoint` and `mongodbatlas_private_endpoint_interface_link` resources from terraform state + **NOTE** before doing any terraform state change please do a backup + +```bash +$ terraform state rm mongodbatlas_private_endpoint.test +$ terraform state rm mongodbatlas_private_endpoint_interface_link.test +``` + +2. Change the version of provider to the v1.0.0 + +3. Perform an import from your existing `mongodbatlas_private_endpoint` to `mongodbatlas_privatelink_endpoint` and from `mongodbatlas_private_endpoint_interface_link` to `mongodbatlas_privatelink_endpoint_service` +```bash + terraform import mongodbatlas_privatelink_endpoint.test --- + terraform import mongodbatlas_privatelink_endpoint_service.test ------ +``` + +4. Do a terraform plan (no changes detected) + +```bash +terraform plan + +(...) + + +No changes. Your infrastructure matches the configuration. + +Terraform has compared your real infrastructure against your configuration and found no differences, +so no changes are needed. +``` +**NOTE** Doc links for [mongodbatlas_privatelink_endpoint](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/privatelink_endpoint) +**NOTE** Doc links for [mongodbatlas_privatelink_endpoint_service](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/privatelink_endpoint_service) + + ### Helpful Links * [Report bugs](https://github.com/mongodb/terraform-provider-mongodbatlas/issues) diff --git a/website/docs/r/private_endpoint.html.markdown b/website/docs/r/private_endpoint.html.markdown deleted file mode 100644 index 71776613c8..0000000000 --- a/website/docs/r/private_endpoint.html.markdown +++ /dev/null @@ -1,84 +0,0 @@ ---- -layout: "mongodbatlas" -page_title: "MongoDB Atlas: private_endpoint" -sidebar_current: "docs-mongodbatlas-resource-private_endpoint" -description: |- - Provides a Private Endpoint resource. ---- - -# mongodbatlas_private_endpoint - -`mongodbatlas_private_endpoint` provides a Private Endpoint resource. This represents a Private Endpoint Connection that can be created in an Atlas project. - -!> **WARNING:** This resource is deprecated and will be removed in the next major version - Please transition to privatelink_endpoint as soon as possible. [PrivateLink Endpoints] (https://docs.atlas.mongodb.com/reference/api/private-endpoints/) - -~> **IMPORTANT:**You must have one of the following roles to successfully handle the resource: - * Organization Owner - * Project Owner - --> **NOTE:** Groups and projects are synonymous terms. You may find group_id in the official documentation. - --> **NOTE:** A network container is created for a private endpoint to reside in if one does not yet exist in the project. - - -## Example Usage - -```hcl -resource "mongodbatlas_private_endpoint" "test" { - project_id = "" - provider_name = "AWS" - region = "us-east-1" -} -``` - -## Argument Reference - -* `project_id` - Required Unique identifier for the project. -* `providerName` - (Required) Name of the cloud provider you want to create the private endpoint connection for. Must be AWS. -* `region` - (Required) Cloud provider region in which you want to create the private endpoint connection. -Accepted values are: - * `us-east-1` - * `us-east-2` - * `us-west-1` - * `us-west-2` - * `ca-central-1` - * `sa-east-1` - * `eu-north-1` - * `eu-west-1` - * `eu-west-2` - * `eu-west-3` - * `eu-central-1` - * `me-south-1` - * `ap-northeast-1` - * `ap-northeast-2` - * `ap-south-1` - * `ap-southeast-1` - * `ap-southeast-2` - * `ap-east-1` - - -## Attributes Reference - -In addition to all arguments above, the following attributes are exported: - -* `id` - The Terraform's unique identifier used internally for state management. -* `private_link_id` - Unique identifier of the AWS PrivateLink connection. -* `endpoint_service_name` - Name of the PrivateLink endpoint service in AWS. Returns null while the endpoint service is being created. -* `error_message` - Error message pertaining to the AWS PrivateLink connection. Returns null if there are no errors. -* `interface_endpoints` - Unique identifiers of the interface endpoints in your VPC that you added to the AWS PrivateLink connection. -* `status` - Status of the AWS PrivateLink connection. - Returns one of the following values: - * `INITIATING` Atlas is creating the network load balancer and VPC endpoint service. - * `WAITING_FOR_USER` The Atlas network load balancer and VPC endpoint service are created and ready to receive connection requests. When you receive this status, create an interface endpoint to continue configuring the AWS PrivateLink connection. - * `FAILED` A system failure has occurred. - * `DELETING` The AWS PrivateLink connection is being deleted. - -## Import -Private Endpoint Connection can be imported using project ID and private link ID, provider name and region, in the format `{project_id}-{private_link_id}-{provider_name}-{region}`, e.g. - -``` -$ terraform import mongodbatlas_private_endpoint.test 1112222b3bf99403840e8934-3242342343112-AWS-us-east-2 -``` - -See detailed information for arguments and attributes: [MongoDB API Private Endpoint Connection](https://docs.atlas.mongodb.com/reference/api/private-endpoint-create-one-private-endpoint-connection/) \ No newline at end of file diff --git a/website/docs/r/private_endpoint_interface_link.html.markdown b/website/docs/r/private_endpoint_interface_link.html.markdown deleted file mode 100644 index 88e9e0b8a7..0000000000 --- a/website/docs/r/private_endpoint_interface_link.html.markdown +++ /dev/null @@ -1,76 +0,0 @@ ---- -layout: "mongodbatlas" -page_title: "MongoDB Atlas: private_endpoint_link" -sidebar_current: "docs-mongodbatlas-resource-private_endpoint_interface_link" -description: |- - Provides a Private Endpoint Link resource. ---- - -# mongodbatlas_private_endpoint_interface_link - -`mongodbatlas_private_endpoint_interface_link` provides a Private Endpoint Interface Link resource. This represents a Private Endpoint Interface Link, which adds one interface endpoint to a private endpoint connection in an Atlas project. - -!> **WARNING:** This resource is deprecated and will be removed in the next major version - Please transition to privatelink_endpoint_service as soon as possible. [PrivateLink Endpoints] (https://docs.atlas.mongodb.com/reference/api/private-endpoints-endpoint-create-one/) - -~> **IMPORTANT:**You must have one of the following roles to successfully handle the resource: - * Organization Owner - * Project Owner - --> **NOTE:** Groups and projects are synonymous terms. You may find group_id in the official documentation. - - -## Example Usage - -```hcl -resource "mongodbatlas_private_endpoint" "test" { - project_id = "" - provider_name = "AWS" - region = "us-east-1" -} - -resource "aws_vpc_endpoint" "ptfe_service" { - vpc_id = "vpc-7fc0a543" - service_name = mongodbatlas_private_endpoint.test.endpoint_service_name - vpc_endpoint_type = "Interface" - subnet_ids = ["subnet-de0406d2"] - security_group_ids = ["sg-3f238186"] -} - -resource "mongodbatlas_private_endpoint_interface_link" "test" { - project_id = mongodbatlas_private_endpoint.test.project_id - private_link_id = mongodbatlas_private_endpoint.test.private_link_id - interface_endpoint_id = aws_vpc_endpoint.ptfe_service.id -} -``` - -## Argument Reference - -* `project_id` - (Required) Unique identifier for the project. -* `private_link_id` - (Required) Unique identifier of the AWS PrivateLink connection which is created by `mongodbatlas_private_endpoint` resource. -* `interface_endpoint_id` - (Required) Unique identifier of the interface endpoint you created in your VPC with the AWS resource. - -## Attributes Reference - -In addition to all arguments above, the following attributes are exported: - -* `id` - The Terraform's unique identifier used internally for state management. -* `delete_requested` - Indicates if Atlas received a request to remove the interface endpoint from the private endpoint connection. -* `error_message` - Error message pertaining to the interface endpoint. Returns null if there are no errors. -* `connection_status` - Status of the interface endpoint. - Returns one of the following values: - * `NONE` - Atlas created the network load balancer and VPC endpoint service, but AWS hasn’t yet created the VPC endpoint. - * `PENDING_ACCEPTANCE` - AWS has received the connection request from your VPC endpoint to the Atlas VPC endpoint service. - * `PENDING` - AWS is establishing the connection between your VPC endpoint and the Atlas VPC endpoint service. - * `AVAILABLE` - Atlas VPC resources are connected to the VPC endpoint in your VPC. You can connect to Atlas clusters in this region using AWS PrivateLink. - * `REJECTED` - AWS failed to establish a connection between Atlas VPC resources to the VPC endpoint in your VPC. - * `DELETING` - Atlas is removing the interface endpoint from the private endpoint connection. - -## Import -Private Endpoint Link Connection can be imported using project ID and username, in the format `{project_id}-{private_link_id}-{interface_endpoint_id}`, e.g. - -``` -$ terraform import mongodbatlas_private_endpoint_interface_link.test 1112222b3bf99403840e8934-3242342343112-vpce-4242342343 -``` - -See detailed information for arguments and attributes: [MongoDB API Private Endpoint Link Connection](https://docs.atlas.mongodb.com/reference/api/private-endpoint-create-one-interface-endpoint/)