From bec06bffb55d335ad6a9b722bd1cabbd796dcc4b Mon Sep 17 00:00:00 2001 From: Oriol Arbusi Date: Wed, 20 Nov 2024 09:48:01 +0100 Subject: [PATCH 1/4] wip remove mentions of serverless and shared tier --- docs/resources/cluster.md | 13 -- .../aws/serverless-instance/README.md | 116 ------------------ .../serverless-instance/atlas-privatelink.tf | 14 --- .../atlas-serverless-instance.tf | 13 -- .../aws/serverless-instance/aws-vpc.tf | 57 --------- .../aws/serverless-instance/output.tf | 14 --- .../aws/serverless-instance/provider.tf | 9 -- .../aws/serverless-instance/variables.tf | 25 ---- .../aws/serverless-instance/versions.tf | 13 -- .../aws/README.md | 97 --------------- .../aws/atlas-cluster.tf | 26 ---- .../aws/aws-vpc.tf | 59 --------- .../aws/main.tf | 23 ---- .../aws/provider.tf | 9 -- .../aws/variables.tf | 25 ---- .../aws/versions.tf | 13 -- .../azure/Readme.md | 84 ------------- .../azure/main.tf | 71 ----------- .../azure/variables.tf | 30 ----- .../azure/versions.tf | 13 -- 20 files changed, 724 deletions(-) delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/README.md delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-privatelink.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-serverless-instance.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/aws-vpc.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/output.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/provider.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/variables.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/versions.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/README.md delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/atlas-cluster.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/aws-vpc.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/provider.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/variables.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/versions.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/Readme.md delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/variables.tf delete mode 100644 examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/versions.tf diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index ab526505b9..91ca02ff55 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -187,19 +187,6 @@ resource "mongodbatlas_cluster" "cluster-test" { } } ``` -### Example AWS Shared Tier (M2/M5) cluster -```terraform -resource "mongodbatlas_cluster" "cluster-test" { - project_id = "" - name = "cluster-test-global" - - # Provider Settings "block" - provider_name = "TENANT" - backing_provider_name = "AWS" - provider_region_name = "US_EAST_1" - provider_instance_size_name = "M2" -} -``` ### Example AWS Free Tier cluster ```terraform resource "mongodbatlas_cluster" "cluster-test" { diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/README.md b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/README.md deleted file mode 100644 index 3235900b62..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/README.md +++ /dev/null @@ -1,116 +0,0 @@ -# Example - AWS and Atlas PrivateLink with Terraform - -Setup private connection to a [MongoDB Atlas Serverless Instance](https://www.mongodb.com/use-cases/serverless) utilizing [Amazon Virtual Private Cloud (aws vpc)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html). - -## Dependencies - -* Terraform v0.13 -* An AWS account - provider.aws: version = "~> 4" -* A MongoDB Atlas account - provider.mongodbatlas: version = "~> 1.8" - -## Usage - -**1\. Ensure your AWS and MongoDB Atlas credentials are set up.** - -This can be done using environment variables: - -```bash -export MONGODB_ATLAS_PUBLIC_KEY="xxxx" -export MONGODB_ATLAS_PRIVATE_KEY="xxxx" -``` - -``` bash -$ export AWS_SECRET_ACCESS_KEY='your secret key' -$ export AWS_ACCESS_KEY_ID='your key id' -``` - -... or the `~/.aws/credentials` file. - -``` -$ cat ~/.aws/credentials -[default] -aws_access_key_id = your key id -aws_secret_access_key = your secret key - -``` -... or follow as in the `variables.tf` file and create **terraform.tfvars** file with all the variable values, ex: -``` -access_key = "" -secret_key = "" -public_key = "" -private_key = "" -project_id = "" -cluster_name = "aws-private-connection" -``` - -**2\. Review the Terraform plan.** - -Execute the below command and ensure you are happy with the plan. - -``` bash -$ terraform plan -``` -This project currently does the below deployments: - -- MongoDB cluster - M10 -- AWS Custom VPC, Internet Gateway, Route Tables, Subnets with Public and Private access -- PrivateLink Connection at MongoDB Atlas -- Create VPC Endpoint in AWS - -**3\. Configure the security group as required.** - -The security group in this configuration allows All Traffic access in Inbound and Outbound Rules. - -**4\. Execute the Terraform apply.** - -Now execute the plan to provision the AWS and Atlas resources. - -``` bash -$ terraform apply -``` - -**5\. Destroy the resources.** - -Once you are finished your testing, ensure you destroy the resources to avoid unnecessary charges. - -``` bash -$ terraform destroy -``` - -**What's the resource dependency chain?** -1. `mongodbatlas_project` must exist for any of the following -2. `mongodbatlas_serverless_instance` is dependent on the `mongodbatlas_project` -3. `mongodbatlas_privatelink_endpoint_serverless` is dependent on the `mongodbatlas_serverless_instance` -4. `aws_vpc_endpoint` is dependent on `mongodbatlas_privatelink_endpoint_serverless` -5. `mongodbatlas_privatelink_endpoint_service_serverless` is dependent on `aws_vpc_endpoint` -6. `mongodbatlas_serverless_instance` is dependent on `mongodbatlas_privatelink_endpoint_service_serverless` for its `connection_strings_private_endpoint_srv` - -**Important Point on dependency chain** -- `mongodbatlas_serverless_instance` must exist in-order to create a `mongodbatlas_privatelink_endpoint_service_serverless` for that instance. -- `mongodbatlas_privatelink_endpoint_service_serverless` must exist before `mongodbatlas_serverless_instance` can have its `connection_strings_private_endpoint_srv`. - -It is impossible to create both resources and have `connection_strings_private_endpoint_srv` populated in a single `terraform apply`.\ -To circumvent this issue, this example utilitizes the following data source - -``` -data "mongodbatlas_serverless_instance" "aws_private_connection" { - project_id = mongodbatlas_serverless_instance.aws_private_connection.project_id - name = mongodbatlas_serverless_instance.aws_private_connection.name - - depends_on = [mongodbatlas_privatelink_endpoint_service_serverless.pe_east_service] -} -``` - - -Serverless instance `connection_strings_private_endpoint_srv` is a list of strings.\ -To output the private connection strings, follow the [example output.tf](output.tf): - -``` -locals { - private_endpoints = coalesce(data.mongodbatlas_serverless_instance.aws_private_connection.connection_strings_private_endpoint_srv, []) -} - -output "connection_strings" { - value = local.private_endpoints -} -``` \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-privatelink.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-privatelink.tf deleted file mode 100644 index 36f3c90fed..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-privatelink.tf +++ /dev/null @@ -1,14 +0,0 @@ -resource "mongodbatlas_privatelink_endpoint_serverless" "pe_east" { - project_id = mongodbatlas_serverless_instance.aws_private_connection.project_id - instance_name = mongodbatlas_serverless_instance.aws_private_connection.name - provider_name = "AWS" -} - -resource "mongodbatlas_privatelink_endpoint_service_serverless" "pe_east_service" { - project_id = mongodbatlas_privatelink_endpoint_serverless.pe_east.project_id - instance_name = mongodbatlas_privatelink_endpoint_serverless.pe_east.instance_name - endpoint_id = mongodbatlas_privatelink_endpoint_serverless.pe_east.endpoint_id - provider_name = mongodbatlas_privatelink_endpoint_serverless.pe_east.provider_name - cloud_provider_endpoint_id = aws_vpc_endpoint.vpce_east.id - comment = "New serverless endpoint" -} \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-serverless-instance.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-serverless-instance.tf deleted file mode 100644 index 5039308d40..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/atlas-serverless-instance.tf +++ /dev/null @@ -1,13 +0,0 @@ -resource "mongodbatlas_serverless_instance" "aws_private_connection" { - project_id = var.project_id - name = var.instance_name - provider_settings_backing_provider_name = "AWS" - provider_settings_provider_name = "SERVERLESS" - provider_settings_region_name = "US_EAST_1" - continuous_backup_enabled = true - - tags { - key = "environment" - value = "dev" - } -} \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/aws-vpc.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/aws-vpc.tf deleted file mode 100644 index a3d3d581d2..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/aws-vpc.tf +++ /dev/null @@ -1,57 +0,0 @@ -resource "aws_vpc_endpoint" "vpce_east" { - vpc_id = aws_vpc.vpc_east.id - service_name = mongodbatlas_privatelink_endpoint_serverless.pe_east.endpoint_service_name - vpc_endpoint_type = "Interface" - subnet_ids = [aws_subnet.subnet_east_a.id, aws_subnet.subnet_east_b.id] - security_group_ids = [aws_security_group.sg_east.id] -} - -resource "aws_vpc" "vpc_east" { - cidr_block = "10.0.0.0/16" - enable_dns_hostnames = true - enable_dns_support = true -} - -resource "aws_internet_gateway" "ig_east" { - vpc_id = aws_vpc.vpc_east.id -} - -resource "aws_route" "route_east" { - route_table_id = aws_vpc.vpc_east.main_route_table_id - destination_cidr_block = "0.0.0.0/0" - gateway_id = aws_internet_gateway.ig_east.id -} - -resource "aws_subnet" "subnet_east_a" { - vpc_id = aws_vpc.vpc_east.id - cidr_block = "10.0.1.0/24" - map_public_ip_on_launch = true - availability_zone = "us-east-1a" -} - -resource "aws_subnet" "subnet_east_b" { - vpc_id = aws_vpc.vpc_east.id - cidr_block = "10.0.2.0/24" - map_public_ip_on_launch = false - availability_zone = "us-east-1b" -} - -resource "aws_security_group" "sg_east" { - name_prefix = "default-" - description = "Default security group for all instances in vpc" - vpc_id = aws_vpc.vpc_east.id - ingress { - from_port = 0 - to_port = 0 - protocol = "tcp" - cidr_blocks = [ - "0.0.0.0/0", - ] - } - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } -} diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/output.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/output.tf deleted file mode 100644 index 6ced909ebf..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/output.tf +++ /dev/null @@ -1,14 +0,0 @@ -data "mongodbatlas_serverless_instance" "aws_private_connection" { - project_id = mongodbatlas_serverless_instance.aws_private_connection.project_id - name = mongodbatlas_serverless_instance.aws_private_connection.name - - depends_on = [mongodbatlas_privatelink_endpoint_service_serverless.pe_east_service] -} - -locals { - private_endpoints = coalesce(data.mongodbatlas_serverless_instance.aws_private_connection.connection_strings_private_endpoint_srv, []) -} - -output "connection_strings" { - value = local.private_endpoints -} \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/provider.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/provider.tf deleted file mode 100644 index 61ef7cb227..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/provider.tf +++ /dev/null @@ -1,9 +0,0 @@ -provider "aws" { - access_key = var.access_key - secret_key = var.secret_key - region = "us-east-1" -} -provider "mongodbatlas" { - public_key = var.public_key - private_key = var.private_key -} diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/variables.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/variables.tf deleted file mode 100644 index 17cc8b1259..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/variables.tf +++ /dev/null @@ -1,25 +0,0 @@ -variable "public_key" { - description = "The public API key for MongoDB Atlas" - type = string -} -variable "private_key" { - description = "The private API key for MongoDB Atlas" - type = string -} -variable "access_key" { - description = "The access key for AWS Account" - type = string -} -variable "secret_key" { - description = "The secret key for AWS Account" - type = string -} -variable "project_id" { - description = "Atlas project ID" - type = string -} -variable "instance_name" { - description = "Atlas serverless instance name" - default = "aws-private-connection" - type = string -} diff --git a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/versions.tf b/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/versions.tf deleted file mode 100644 index 6b9f728948..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint/aws/serverless-instance/versions.tf +++ /dev/null @@ -1,13 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.0" - } - mongodbatlas = { - source = "mongodb/mongodbatlas" - version = "~> 1.0" - } - } - required_version = ">= 1.0" -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/README.md b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/README.md deleted file mode 100644 index 88c764b227..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# Example - AWS and Atlas PrivateLink with Terraform - -This project aims to provide a very straight-forward example of setting up PrivateLink connection between AWS and MongoDB Atlas Serverless. - - -## Dependencies - -* Terraform v0.13 -* An AWS account - provider.aws: version = "~> 3.3" -* A MongoDB Atlas account - provider.mongodbatlas: version = "~> 0.6" - -## Usage - -**1\. Ensure your AWS and MongoDB Atlas credentials are set up.** - -This can be done using environment variables: - -``` bash -$ export AWS_SECRET_ACCESS_KEY='your secret key' -$ export AWS_ACCESS_KEY_ID='your key id' -``` - -```bash -export MONGODB_ATLAS_PUBLIC_KEY="xxxx" -export MONGODB_ATLAS_PRIVATE_KEY="xxxx" -``` - -... or the `~/.aws/credentials` file. - -``` -$ cat ~/.aws/credentials -[default] -aws_access_key_id = your key id -aws_secret_access_key = your secret key - -``` -... or follow as in the `variables.tf` file and create **terraform.tfvars** file with all the variable values and make sure **not to commit it**. - -**2\. Review the Terraform plan.** - -Execute the below command and ensure you are happy with the plan. - -``` bash -$ terraform plan -``` -This project currently does the below deployments: - -- MongoDB cluster - M10 -- AWS Custom VPC, Internet Gateway, Route Tables, Subnets with Public and Private access -- PrivateLink Connection at MongoDB Atlas -- Create VPC Endpoint in AWS - -**3\. Configure the security group as required.** - -The security group in this configuration allows All Traffic access in Inbound and Outbound Rules. - -**4\. Execute the Terraform apply.** - -Now execute the plan to provision the AWS and Atlas resources. - -``` bash -$ terraform apply -``` - -**5\. Destroy the resources.** - -Once you are finished your testing, ensure you destroy the resources to avoid unnecessary charges. - -``` bash -$ terraform destroy -``` - -**Important Point** - -To fetch the connection string follow the below steps: -``` -output "atlasclusterstring" { - value = data.mongodbatlas_serverless_instance.cluster_atlas.connection_strings_standard_srv -} -``` -**Outputs:** -``` -atlasclusterstring = "mongodb+srv://cluster-atlas.za3fb.mongodb.net" - -``` - -To fetch a private connection string, use the output of terraform as below after second apply: - -``` -output "plstring" { - value = mongodbatlas_serverless_instance.cluster_atlas.connection_strings_private_endpoint_srv[0] -} -``` -**Output:** -``` -plstring = mongodb+srv://cluster-atlas-pe-0.za3fb.mongodb.net -``` diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/atlas-cluster.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/atlas-cluster.tf deleted file mode 100644 index dc4ba8a1b6..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/atlas-cluster.tf +++ /dev/null @@ -1,26 +0,0 @@ -resource "mongodbatlas_serverless_instance" "cluster_atlas" { - project_id = var.atlasprojectid - name = "ClusterAtlas" - provider_settings_backing_provider_name = "AWS" - provider_settings_provider_name = "SERVERLESS" - provider_settings_region_name = "US_EAST_1" - continuous_backup_enabled = true -} - -data "mongodbatlas_serverless_instance" "cluster_atlas" { - project_id = var.atlasprojectid - name = mongodbatlas_serverless_instance.cluster_atlas.name - depends_on = [mongodbatlas_privatelink_endpoint_service_serverless.atlaseplink] -} - - -output "atlasclusterstring" { - value = data.mongodbatlas_serverless_instance.cluster_atlas.connection_strings_standard_srv -} - -/* Note Value not available until second apply*/ -/* -output "plstring" { - value = mongodbatlas_serverless_instance.cluster_atlas.connection_strings_private_endpoint_srv[0] -} -*/ diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/aws-vpc.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/aws-vpc.tf deleted file mode 100644 index e6bd39e188..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/aws-vpc.tf +++ /dev/null @@ -1,59 +0,0 @@ -# Create Primary VPC -resource "aws_vpc" "primary" { - cidr_block = "10.0.0.0/16" - enable_dns_hostnames = true - enable_dns_support = true -} - -# Create IGW -resource "aws_internet_gateway" "primary" { - vpc_id = aws_vpc.primary.id -} - -# Route Table -resource "aws_route" "primary-internet_access" { - route_table_id = aws_vpc.primary.main_route_table_id - destination_cidr_block = "0.0.0.0/0" - gateway_id = aws_internet_gateway.primary.id -} - -# Subnet-A -resource "aws_subnet" "primary-az1" { - vpc_id = aws_vpc.primary.id - cidr_block = "10.0.1.0/24" - map_public_ip_on_launch = true - availability_zone = "${var.aws_region}a" -} - -# Subnet-B -resource "aws_subnet" "primary-az2" { - vpc_id = aws_vpc.primary.id - cidr_block = "10.0.2.0/24" - map_public_ip_on_launch = false - availability_zone = "${var.aws_region}b" -} - -/*Security-Group -Ingress - Port 80 -- limited to instance - Port 22 -- Open to ssh without limitations -Egress - Open to All*/ - -resource "aws_security_group" "primary_default" { - name_prefix = "default-" - description = "Default security group for all instances in ${aws_vpc.primary.id}" - vpc_id = aws_vpc.primary.id - ingress { - from_port = 0 - to_port = 0 - protocol = "tcp" - cidr_blocks = [ - "0.0.0.0/0", - ] - } - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf deleted file mode 100644 index cff417bd28..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf +++ /dev/null @@ -1,23 +0,0 @@ -resource "mongodbatlas_privatelink_endpoint_serverless" "atlaspl" { - project_id = var.atlasprojectid - provider_name = "AWS" - instance_name = mongodbatlas_serverless_instance.cluster_atlas.name -} - -resource "aws_vpc_endpoint" "ptfe_service" { - vpc_id = aws_vpc.primary.id - service_name = mongodbatlas_privatelink_endpoint_serverless.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_privatelink_endpoint_service_serverless" "atlaseplink" { - project_id = mongodbatlas_privatelink_endpoint_serverless.atlaspl.project_id - instance_name = mongodbatlas_serverless_instance.cluster_atlas.name - endpoint_id = mongodbatlas_privatelink_endpoint_serverless.atlaspl.endpoint_id - cloud_provider_endpoint_id = aws_vpc_endpoint.ptfe_service.id - provider_name = "AWS" - comment = "test" - -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/provider.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/provider.tf deleted file mode 100644 index e075e34d7e..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/provider.tf +++ /dev/null @@ -1,9 +0,0 @@ -provider "mongodbatlas" { - public_key = var.public_key - private_key = var.private_key -} -provider "aws" { - access_key = var.access_key - secret_key = var.secret_key - region = var.aws_region -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/variables.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/variables.tf deleted file mode 100644 index 86977d1bde..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/variables.tf +++ /dev/null @@ -1,25 +0,0 @@ -variable "public_key" { - description = "The public API key for MongoDB Atlas" - type = string -} -variable "private_key" { - description = "The private API key for MongoDB Atlas" - type = string -} -variable "atlasprojectid" { - description = "Atlas project ID" - type = string -} -variable "access_key" { - description = "The access key for AWS Account" - type = string -} -variable "secret_key" { - description = "The secret key for AWS Account" - type = string -} -variable "aws_region" { - default = "us-east-1" - description = "AWS Region" - type = string -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/versions.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/versions.tf deleted file mode 100644 index 6b9f728948..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/versions.tf +++ /dev/null @@ -1,13 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.0" - } - mongodbatlas = { - source = "mongodb/mongodbatlas" - version = "~> 1.0" - } - } - required_version = ">= 1.0" -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/Readme.md b/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/Readme.md deleted file mode 100644 index 012e789f2c..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/Readme.md +++ /dev/null @@ -1,84 +0,0 @@ -# Example - Microsoft Azure and MongoDB Atlas Private Endpoint Serverless - -This project aims to provide an example of using Azure and MongoDB Atlas together. - - -## Dependencies - -* Terraform v0.13 -* Microsoft Azure account -* MongoDB Atlas account - -``` -Terraform v0.13.0 -+ provider registry.terraform.io/hashicorp/azuread v1.0.0 -+ provider registry.terraform.io/hashicorp/azurerm v2.31.1 -+ provider registry.terraform.io/terraform-providers/mongodbatlas v0.6.5 -``` - -## Usage - -**1\. Ensure your Azure credentials are set up.** - -1. Install the Azure CLI by following the steps from the [official Azure documentation](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). -2. Run the command `az login` and this will take you to the default browser and perform the authentication. -3. Once authenticated, it will print the user details as below: - -``` -⇒ az login -You have logged in. Now let us find all the subscriptions to which you have access... -The following tenants don't contain accessible subscriptions. Use 'az login --allow-no-subscriptions' to have tenant level access. -XXXXX -[ - { - "cloudName": "AzureCloud", - "homeTenantId": "XXXXX", - "id": "XXXXX", - "isDefault": true, - "managedByTenants": [], - "name": "Pay-As-You-Go", - "state": "Enabled", - "tenantId": "XXXXX", - "user": { - "name": "person@domain.com", - "type": "user" - } - } -] -``` - -**2\. TFVARS** - -Now create **terraform.tfvars** file with all the variable values and make sure **not to commit it**. - -An serverless cluster in the project will be linked via the `cluster_name` variable. -If included, the azure connection string to the cluster will be output. - -**3\. Review the Terraform plan.** - -Execute the below command and ensure you are happy with the plan. - -``` bash -$ terraform plan -``` -This project currently does the below deployments: - -- MongoDB Atlas Azure Private Endpoint -- Azure Resource Group, VNET, Subnet, Private Endpoint -- Azure-MongoDB Private Link - -**4\. Execute the Terraform apply.** - -Now execute the plan to provision the Azure resources. - -``` bash -$ terraform apply -``` - -**5\. Destroy the resources.** - -Once you are finished your testing, ensure you destroy the resources to avoid unnecessary Azure and Atlas charges. - -``` bash -$ terraform destroy -``` diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf deleted file mode 100644 index d40e580bc5..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/main.tf +++ /dev/null @@ -1,71 +0,0 @@ -provider "azurerm" { - subscription_id = var.subscription_id - client_id = var.client_id - client_secret = var.client_secret - tenant_id = var.tenant_id - features { - } -} - -data "azurerm_resource_group" "test" { - name = var.resource_group_name -} - -resource "azurerm_virtual_network" "test" { - name = "acceptanceTestVirtualNetwork1" - address_space = ["10.0.0.0/16"] - location = data.azurerm_resource_group.test.location - resource_group_name = var.resource_group_name -} - -resource "azurerm_subnet" "test" { - name = "testsubnet" - resource_group_name = var.resource_group_name - virtual_network_name = azurerm_virtual_network.test.name - address_prefixes = ["10.0.1.0/24"] - private_link_service_network_policies_enabled = true - private_endpoint_network_policies_enabled = true -} - -resource "mongodbatlas_privatelink_endpoint_serverless" "test" { - project_id = var.project_id - instance_name = mongodbatlas_serverless_instance.test.name - provider_name = "AZURE" -} - -resource "azurerm_private_endpoint" "test" { - name = "endpoint-test" - location = data.azurerm_resource_group.test.location - resource_group_name = var.resource_group_name - subnet_id = azurerm_subnet.test.id - private_service_connection { - name = mongodbatlas_privatelink_endpoint_serverless.test.endpoint_service_name - private_connection_resource_id = mongodbatlas_privatelink_endpoint_serverless.test.private_link_service_resource_id - is_manual_connection = true - request_message = "Azure Private Link test" - } - -} - -resource "mongodbatlas_privatelink_endpoint_service_serverless" "test" { - project_id = mongodbatlas_privatelink_endpoint_serverless.test.project_id - instance_name = mongodbatlas_serverless_instance.test.name - endpoint_id = mongodbatlas_privatelink_endpoint_serverless.test.endpoint_id - cloud_provider_endpoint_id = azurerm_private_endpoint.test.id - private_endpoint_ip_address = azurerm_private_endpoint.test.private_service_connection[0].private_ip_address - provider_name = "AZURE" - comment = "test" -} - -resource "mongodbatlas_serverless_instance" "test" { - project_id = var.project_id - name = var.cluster_name - provider_settings_backing_provider_name = "AZURE" - provider_settings_provider_name = "SERVERLESS" - provider_settings_region_name = "US_EAST_2" - continuous_backup_enabled = true -} - -output "private_endpoints" { - value = mongodbatlas_serverless_instance.test.connection_strings_private_endpoint_srv[0] -} \ No newline at end of file diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/variables.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/variables.tf deleted file mode 100644 index 65b1347a9f..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/variables.tf +++ /dev/null @@ -1,30 +0,0 @@ - -variable "project_id" { - default = "PROJECT-ID" - type = string -} -variable "subscription_id" { - default = "AZURE SUBSCRIPTION ID" - type = string -} -variable "client_id" { - default = "AZURE CLIENT ID" - type = string -} -variable "client_secret" { - default = "AZURE CLIENT SECRET" - type = string -} -variable "tenant_id" { - default = "AZURE TENANT ID" - type = string -} -variable "resource_group_name" { - default = "AZURE RESOURCE GROUP NAME" - type = string -} -variable "cluster_name" { - description = "Cluster whose connection string to output" - default = "cluster-serverless" - type = string -} diff --git a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/versions.tf b/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/versions.tf deleted file mode 100644 index 7d50229e5c..0000000000 --- a/examples/mongodbatlas_privatelink_endpoint_service_serverless/azure/versions.tf +++ /dev/null @@ -1,13 +0,0 @@ -terraform { - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = "~> 3.0" - } - mongodbatlas = { - source = "mongodb/mongodbatlas" - version = "~> 1.0" - } - } - required_version = ">= 1.0" -} From 1abad7491887ccd42d6a2e5f94e1299c44d830a0 Mon Sep 17 00:00:00 2001 From: Oriol Arbusi Date: Wed, 20 Nov 2024 14:56:02 +0100 Subject: [PATCH 2/4] remove examples from template for serverless privatelink --- templates/data-source.md.tmpl | 2 -- templates/resources.md.tmpl | 2 -- 2 files changed, 4 deletions(-) diff --git a/templates/data-source.md.tmpl b/templates/data-source.md.tmpl index 45b3c38584..b649202982 100644 --- a/templates/data-source.md.tmpl +++ b/templates/data-source.md.tmpl @@ -9,9 +9,7 @@ {{ else if eq .Name "mongodbatlas_privatelink_endpoint" }} {{ tffile (printf "examples/%s/aws/cluster/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_privatelink_endpoint_service_serverless" }} - {{ tffile (printf "examples/%s/aws/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_privatelink_endpoint_serverless" }} - {{ tffile "examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf" }} {{ else if eq .Name "mongodbatlas_cluster" }} {{ tffile (printf "examples/%s/tenant-upgrade/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_cluster" }} diff --git a/templates/resources.md.tmpl b/templates/resources.md.tmpl index ed9ba98760..855f829e7a 100644 --- a/templates/resources.md.tmpl +++ b/templates/resources.md.tmpl @@ -9,9 +9,7 @@ {{ else if eq .Name "mongodbatlas_privatelink_endpoint" }} {{ tffile (printf "examples/%s/aws/cluster/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_privatelink_endpoint_service_serverless" }} - {{ tffile (printf "examples/%s/aws/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_privatelink_endpoint_serverless" }} - {{ tffile "examples/mongodbatlas_privatelink_endpoint_service_serverless/aws/main.tf" }} {{ else if eq .Name "mongodbatlas_cluster" }} {{ tffile (printf "examples/%s/tenant-upgrade/main.tf" .Name )}} {{ else if eq .Name "mongodbatlas_cluster" }} From 0af93d281a9a2e09f96c2317f98732ffdc2e08ed Mon Sep 17 00:00:00 2001 From: Oriol Arbusi Date: Wed, 20 Nov 2024 15:27:42 +0100 Subject: [PATCH 3/4] change from M5 to M0 for tenant examples of adv cluster --- docs/data-sources/advanced_cluster.md | 2 +- docs/data-sources/advanced_clusters.md | 2 +- docs/resources/advanced_cluster.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/data-sources/advanced_cluster.md b/docs/data-sources/advanced_cluster.md index 0b69cd8796..009dc76228 100644 --- a/docs/data-sources/advanced_cluster.md +++ b/docs/data-sources/advanced_cluster.md @@ -19,7 +19,7 @@ resource "mongodbatlas_advanced_cluster" "example" { replication_specs { region_configs { electable_specs { - instance_size = "M5" + instance_size = "M0" } provider_name = "TENANT" backing_provider_name = "AWS" diff --git a/docs/data-sources/advanced_clusters.md b/docs/data-sources/advanced_clusters.md index c1d26b12e3..a1b361410a 100644 --- a/docs/data-sources/advanced_clusters.md +++ b/docs/data-sources/advanced_clusters.md @@ -19,7 +19,7 @@ resource "mongodbatlas_advanced_cluster" "example" { replication_specs { region_configs { electable_specs { - instance_size = "M5" + instance_size = "M0" } provider_name = "TENANT" backing_provider_name = "AWS" diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index 43424d4d4a..c9a8ec9870 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -56,7 +56,7 @@ resource "mongodbatlas_advanced_cluster" "test" { replication_specs { region_configs { electable_specs { - instance_size = "M5" + instance_size = "M0" } provider_name = "TENANT" backing_provider_name = "AWS" From 94f192fb1a214bfc16a995fafbae7cdf7f809323 Mon Sep 17 00:00:00 2001 From: Oriol Arbusi Date: Wed, 20 Nov 2024 17:49:24 +0100 Subject: [PATCH 4/4] add note on M0 --- docs/data-sources/advanced_cluster.md | 2 ++ docs/data-sources/advanced_clusters.md | 2 ++ docs/resources/advanced_cluster.md | 2 ++ 3 files changed, 6 insertions(+) diff --git a/docs/data-sources/advanced_cluster.md b/docs/data-sources/advanced_cluster.md index 009dc76228..be655ab1cd 100644 --- a/docs/data-sources/advanced_cluster.md +++ b/docs/data-sources/advanced_cluster.md @@ -35,6 +35,8 @@ data "mongodbatlas_advanced_cluster" "example" { } ``` +**NOTE:** There can only be one M0 cluster per project. + ## Example using latest sharding configurations with independent shard scaling in the cluster ```terraform diff --git a/docs/data-sources/advanced_clusters.md b/docs/data-sources/advanced_clusters.md index a1b361410a..4a86b4df40 100644 --- a/docs/data-sources/advanced_clusters.md +++ b/docs/data-sources/advanced_clusters.md @@ -34,6 +34,8 @@ data "mongodbatlas_advanced_clusters" "example" { } ``` +**NOTE:** There can only be one M0 cluster per project. + ## Example using latest sharding configurations with independent shard scaling in the cluster ```terraform diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index c9a8ec9870..56c5824239 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -67,6 +67,8 @@ resource "mongodbatlas_advanced_cluster" "test" { } ``` +**NOTE:** There can only be one M0 cluster per project. + **NOTE**: Upgrading the shared tier is supported. Any change from a shared tier cluster (a tenant) to a different instance size will be considered a tenant upgrade. When upgrading from the shared tier, change the `provider_name` from "TENANT" to your preferred provider (AWS, GCP or Azure) and remove the variable `backing_provider_name`. See the [Example Tenant Cluster Upgrade](#Example-Tenant-Cluster-Upgrade) below. You can upgrade a shared tier cluster only to a single provider on an M10-tier cluster or greater. When upgrading from the shared tier, *only* the upgrade changes will be applied. This helps avoid a corrupt state file in the event that the upgrade succeeds but subsequent updates fail within the same `terraform apply`. To apply additional cluster changes, run a secondary `terraform apply` after the upgrade succeeds.