* mongodb project definition * wip * add psc output to net-address module * wip * wip * initial README, test * remove providers file * boilerplate * tfdoc * test * fix unrelated test * outputs, better README
4.1 KiB
MongoDB Atlas
This simple setup allows creating and configuring a managed MongoDB Atlas cluster, and connecting it to a local VPC network via Private Endpoints.
Prerequisites
The project.yaml file describes the project-level configuration needed in terms of API activation and IAM bindings.
If you are deploying this inside a FAST-enabled organization, the file can be lightly edited to match your configuration, and then used directly in the project factory.
This Terraform can of course be deployed using any pre-existing project. In that case use the YAML file to determine the configuration you need to set on the project:
- enable the APIs listed under
services - grant the permissions listed under
iamto the principal running Terraform, either machine (service account) or human
Variable Configuration
Configuration is mostly done via the atlas_config and vpc_config variables. Note that:
- VPC configuration can be set to reference a Shared VPC Host network like shown below, or an in-project network if that is preferred
- the PSC CIDR block is used to allocate the required 50 endpoint addresses in the VPC, so it needs to be large enough to accommodate them
- the Atlas region must match the GCP subnetwork region
Bringing up a cluster and the associated connectivity from scratch will require approximately 30 minutes.
atlas_config = {
cluster_name = "test-0"
organization_id = "fmoajt0b2fwdvp9yvu7m7zl2"
project_name = "my-atlas-project"
region = "NORTH_AMERICA_NORTHEAST_1"
database_version = "7.0"
instance_size = "M10"
provider = {
public_key = "xxxx"
private_key = "xxxxx-xxxx-xxxx-xxxx-xxxxxxxx"
}
}
project_id = "my-prod-shared-mongodb-0"
vpc_config = {
network_name = "dev-spoke-0"
subnetwork_id = "projects/my-dev-net-spoke-0/regions/northamerica-northeast1/subnetworks/gce"
psc_cidr_block = "10.8.11.192/26"
}
# tftest skip
Variables
| name | description | type | required | default |
|---|---|---|---|---|
| atlas_config | MongoDB Atlas configuration. | object({…}) |
✓ | |
| project_id | Project id where the registries will be created. | string |
✓ | |
| vpc_config | VPC configuration. | object({…}) |
✓ | |
| name | Prefix used for all resource names. | string |
"mongodb" |
Outputs
| name | description | sensitive |
|---|---|---|
| atlas_cluster | MongoDB Atlas cluster. | |
| atlas_project | MongoDB Atlas project. | |
| endpoints | MongoDB Atlas endpoints. |
Test
module "test" {
source = "./fabric/fast/project-templates/data-mongodb"
atlas_config = {
cluster_name = "test-0"
organization_id = "fmoajt0b2fwdvp9yvu7m7zl2"
project_name = "my-atlas-project"
region = "NORTH_AMERICA_NORTHEAST_1"
database_version = "7.0"
instance_size = "M10"
provider = {
public_key = "xxxx"
private_key = "xxxxx-xxxx-xxxx-xxxx-xxxxxxxx"
}
}
project_id = "my-prod-shared-mongodb-0"
vpc_config = {
network_name = "dev-spoke-0"
subnetwork_id = "projects/my-dev-net-spoke-0/regions/northamerica-northeast1/subnetworks/gce"
psc_cidr_block = "10.8.11.192/26"
}
}
# tftest modules=2 resources=104