From b6c325480302c74fbdea2200dfe6cc84a9ad3562 Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:32:58 +0200 Subject: [PATCH 1/2] remove modules folder --- modules/examples/atlas-basic/main.tf | 23 -- modules/examples/atlas-basic/versions.tf | 10 - modules/examples/sagemaker/main.tf | 26 -- modules/examples/sagemaker/versions.tf | 10 - .../README.md | 21 -- .../outputs.tf | 10 - .../sagemaker.tf | 280 ------------------ .../variables.tf | 75 ----- .../versions.tf | 13 - .../terraform-mongodbatlas-basic/README.md | 42 --- .../terraform-mongodbatlas-basic/aws-vpc.tf | 59 ---- modules/terraform-mongodbatlas-basic/main.tf | 114 ------- .../terraform-mongodbatlas-basic/outputs.tf | 1 - .../terraform-mongodbatlas-basic/variables.tf | 217 -------------- .../terraform-mongodbatlas-basic/versions.tf | 14 - 15 files changed, 915 deletions(-) delete mode 100644 modules/examples/atlas-basic/main.tf delete mode 100644 modules/examples/atlas-basic/versions.tf delete mode 100644 modules/examples/sagemaker/main.tf delete mode 100644 modules/examples/sagemaker/versions.tf delete mode 100644 modules/terraform-mongodbatlas-amazon-sagemaker-integration/README.md delete mode 100644 modules/terraform-mongodbatlas-amazon-sagemaker-integration/outputs.tf delete mode 100644 modules/terraform-mongodbatlas-amazon-sagemaker-integration/sagemaker.tf delete mode 100644 modules/terraform-mongodbatlas-amazon-sagemaker-integration/variables.tf delete mode 100644 modules/terraform-mongodbatlas-amazon-sagemaker-integration/versions.tf delete mode 100644 modules/terraform-mongodbatlas-basic/README.md delete mode 100644 modules/terraform-mongodbatlas-basic/aws-vpc.tf delete mode 100644 modules/terraform-mongodbatlas-basic/main.tf delete mode 100644 modules/terraform-mongodbatlas-basic/outputs.tf delete mode 100644 modules/terraform-mongodbatlas-basic/variables.tf delete mode 100644 modules/terraform-mongodbatlas-basic/versions.tf diff --git a/modules/examples/atlas-basic/main.tf b/modules/examples/atlas-basic/main.tf deleted file mode 100644 index 1fb35f72a0..0000000000 --- a/modules/examples/atlas-basic/main.tf +++ /dev/null @@ -1,23 +0,0 @@ -module "atlas-basic" { - source = "../../terraform-mongodbatlas-basic" - - public_key = "" - private_key = "" - atlas_org_id = "" - - database_name = ["test1","test2"] - db_users = ["user1","user2"] - db_passwords = ["",""] - database_names = ["test-db1","test-db2"] - region = "US_EAST_1" - - aws_vpc_cidr_block = "1.0.0.0/16" - aws_vpc_egress = "0.0.0.0/0" - aws_vpc_ingress = "0.0.0.0/0" - aws_subnet_cidr_block1 = "1.0.1.0/24" - aws_subnet_cidr_block2 = "1.0.2.0/24" - - cidr_block = ["10.1.0.0/16","12.2.0.0/16"] - ip_address = ["208.169.90.207","63.167.210.250"] - -} \ No newline at end of file diff --git a/modules/examples/atlas-basic/versions.tf b/modules/examples/atlas-basic/versions.tf deleted file mode 100644 index 1d70a22799..0000000000 --- a/modules/examples/atlas-basic/versions.tf +++ /dev/null @@ -1,10 +0,0 @@ -terraform { - required_version = ">= 1.0" - - required_providers { - aws = { - source = "hashicorp/aws" - version = ">= 5.0" - } - } -} \ No newline at end of file diff --git a/modules/examples/sagemaker/main.tf b/modules/examples/sagemaker/main.tf deleted file mode 100644 index f295a7684a..0000000000 --- a/modules/examples/sagemaker/main.tf +++ /dev/null @@ -1,26 +0,0 @@ - -# NOTE: -# go through the sagemaker-example/README.md file to create prerequisites and pass the inputs for the below - - -module "mongodb-atlas-analytics-amazon-sagemaker-integration" { - source = "../../terraform-mongodbatlas-amazon-sagemaker-integration" - - public_key = "" - private_key = "" - atlas_org_id = "" - - atlas_project_id = "" - realm_app_id = "" - database_name = "" - collection_name = "" - service_id = "" - - trigger_name = "" - - model_ecr_image_uri = "" - pull_lambda_ecr_image_uri = "" - model_data_s3_uri = "" - push_lambda_ecr_image_uri = "" - mongo_endpoint = "" -} diff --git a/modules/examples/sagemaker/versions.tf b/modules/examples/sagemaker/versions.tf deleted file mode 100644 index 1d70a22799..0000000000 --- a/modules/examples/sagemaker/versions.tf +++ /dev/null @@ -1,10 +0,0 @@ -terraform { - required_version = ">= 1.0" - - required_providers { - aws = { - source = "hashicorp/aws" - version = ">= 5.0" - } - } -} \ No newline at end of file diff --git a/modules/terraform-mongodbatlas-amazon-sagemaker-integration/README.md b/modules/terraform-mongodbatlas-amazon-sagemaker-integration/README.md deleted file mode 100644 index 5f545d0150..0000000000 --- a/modules/terraform-mongodbatlas-amazon-sagemaker-integration/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# quickstart-mongodb-atlas-analytics-amazon-sagemaker-integration - -## Overview - -![simple-quickstart-arch](https://user-images.githubusercontent.com/5663078/229119386-0dbc6e30-a060-465e-86dd-f89712b0fc49.png) - -This Partner Solutions template enables you to begin working with your machine learning models using MongoDB Atlas Cluster and Amazon SageMaker endpoints. With this template, you can utilize MongoDB as a data source and SageMaker for data analysis, streamlining the process of building and deploying machine learning models. - - -## MongoDB Atlas terraform Resources used by the templates - -- [mongodbatlas_event_trigger](../../mongodbatlas/data_source_mongodbatlas_event_trigger.go) - - -## Environment Configured by the Partner Solutions template -The Partner Solutions template will generate and configure the following resources: - - a [MongoDB Partner Event Bus](http://mongodb.com/docs/atlas/app-services/triggers/aws-eventbridge/#std-label-aws-eventbridge) - - a [database trigger](https://www.mongodb.com/docs/atlas/app-services/triggers/database-triggers/) with your Atlas Cluster - - lambda functions to run the machine learning model and send the classification results to your MongoDB Atlas Cluster. (See [iris_classifier](https://github.com/mongodb/mongodbatlas-cloudformation-resources/tree/master/examples/quickstart-mongodb-atlas-analytics-amazon-sagemaker-integration/sagemaker-example/iris_classifier) for an example of machine learning model to use with this template. See [lambda_functions](https://github.com/mongodb/mongodbatlas-cloudformation-resources/tree/master/examples/quickstart-mongodb-atlas-analytics-amazon-sagemaker-integration/sagemaker-example/lambda_functions) for an example of lambda functions to use to read and write data to your MongoDB Atlas cluster.) - - diff --git a/modules/terraform-mongodbatlas-amazon-sagemaker-integration/outputs.tf b/modules/terraform-mongodbatlas-amazon-sagemaker-integration/outputs.tf deleted file mode 100644 index d19a8d32b1..0000000000 --- a/modules/terraform-mongodbatlas-amazon-sagemaker-integration/outputs.tf +++ /dev/null @@ -1,10 +0,0 @@ - -output "sage_maker_endpoint_arn" { - description = "SageMaker endpoint ARN" - value = aws_sagemaker_endpoint.endpoint.arn -} - -output "event_bus_name" { - description = "Event Bus Name" - value = aws_cloudwatch_event_bus.event_bus_for_capturing_mdb_events.arn -} diff --git a/modules/terraform-mongodbatlas-amazon-sagemaker-integration/sagemaker.tf b/modules/terraform-mongodbatlas-amazon-sagemaker-integration/sagemaker.tf deleted file mode 100644 index 6a8ac985ca..0000000000 --- a/modules/terraform-mongodbatlas-amazon-sagemaker-integration/sagemaker.tf +++ /dev/null @@ -1,280 +0,0 @@ -provider "mongodbatlas" { - public_key = var.public_key - private_key = var.private_key -} - -data "aws_partition" "current" {} - -data "aws_region" "current" {} - -data "aws_caller_identity" "current" {} - - -resource "mongodbatlas_event_trigger" "trigger" { - project_id = var.atlas_project_id - name = var.trigger_name - type = "DATABASE" - app_id = var.realm_app_id - - config_database= var.database_name - config_collection = var.collection_name - config_operation_types = ["INSERT"] - config_service_id = var.service_id - config_full_document = true - - event_processors { - aws_eventbridge { - config_region = data.aws_region.current.name - config_account_id = data.aws_caller_identity.current.account_id - } - } -} - -resource "aws_iam_role" "sage_maker_execution_role" { - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Effect = "Allow" - Principal = { - Service = [ - "sagemaker.amazonaws.com" - ] - } - Action = [ - "sts:AssumeRole" - ] - } - ] - }) - path = "/" - managed_policy_arns = [ - "arn:${data.aws_partition.current.partition}:iam::aws:policy/AmazonSageMakerFullAccess", - "arn:${data.aws_partition.current.partition}:iam::aws:policy/AmazonSageMakerCanvasFullAccess" - ] - - inline_policy { - name = "qs-sagemaker-execution-policy" - policy = jsonencode({ - Version = "2012-10-17", - Statement = [ - { - Effect = "Allow", - Action = "s3:GetObject", - Resource = "arn:${data.aws_partition.current.partition}:s3:::*" - } - ] - }) - } -} - -resource "aws_sagemaker_model" "model" { - primary_container { - image = var.model_ecr_image_uri - model_data_url = var.model_data_s3_uri - mode = "SingleModel" - environment = { - SAGEMAKER_PROGRAM = "inference.py" - SAGEMAKER_SUBMIT_DIRECTORY = var.model_data_s3_uri - } - } - execution_role_arn = aws_iam_role.sage_maker_execution_role.arn -} - -resource "aws_sagemaker_endpoint_configuration" "endpoint_config" { - production_variants { - initial_instance_count = 1 - initial_variant_weight = 1.0 - instance_type = "ml.c5.large" - model_name = aws_sagemaker_model.model.name - variant_name = aws_sagemaker_model.model.name - } -} - -resource "aws_sagemaker_endpoint" "endpoint" { - endpoint_config_name = aws_sagemaker_endpoint_configuration.endpoint_config.name -} - -resource "aws_cloudwatch_event_bus" "event_bus_for_capturing_mdb_events" { - depends_on = [ mongodbatlas_event_trigger.trigger ] - event_source_name = "aws.partner/mongodb.com/stitch.trigger/${mongodbatlas_event_trigger.trigger.trigger_id}" - name = "aws.partner/mongodb.com/stitch.trigger/${mongodbatlas_event_trigger.trigger.trigger_id}" -} - -resource "aws_cloudwatch_event_bus" "event_bus_for_sage_maker_results" { - name = "qs-mongodb-sagemaker-results" -} - -resource "aws_lambda_function" "lambda_function_to_read_mdb_events" { - function_name = "pull-mdb-events" - package_type = "Image" - image_uri = var.pull_lambda_ecr_image_uri - role = aws_iam_role.pull_lambda_function_role.arn - environment { - variables = { - model_endpoint = aws_sagemaker_endpoint.endpoint.name - region_name = data.aws_region.current.name - eventbus_name = aws_cloudwatch_event_bus.event_bus_for_sage_maker_results.arn - } - } - architectures = [ - "x86_64" - ] - memory_size = 1024 - timeout = 300 -} - -resource "aws_cloudwatch_event_rule" "event_rule_to_match_mdb_events" { - description = "Event Rule to match MongoDB change events." - event_bus_name = aws_cloudwatch_event_bus.event_bus_for_capturing_mdb_events.name - event_pattern = jsonencode({ - account = [ - data.aws_caller_identity.current.account_id - ] - }) - is_enabled = true - name = "pull-mdb-events" -} - -resource "aws_cloudwatch_event_target" "read_mdb_event_target" { - event_bus_name = aws_cloudwatch_event_bus.event_bus_for_capturing_mdb_events.name - rule = aws_cloudwatch_event_rule.event_rule_to_match_mdb_events.name - target_id = "EventRuleToReadMatchMDBEventsID" - arn = aws_lambda_function.lambda_function_to_read_mdb_events.arn -} - -resource "aws_iam_role" "pull_lambda_function_role" { - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Effect = "Allow" - Principal = { - Service = [ - "lambda.amazonaws.com" - ] - } - Action = [ - "sts:AssumeRole" - ] - } - ] - }) - path = "/" - managed_policy_arns = [ - "arn:${data.aws_partition.current.partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - inline_policy { - name = "sagemaker-endpoint-invokation-policy" - policy = jsonencode({ - Version = "2012-10-17", - Statement = [ - { - Effect = "Allow", - Action = "sagemaker:InvokeEndpoint", - Resource = aws_sagemaker_endpoint.endpoint.arn - }, - { - Effect = "Allow", - Action = "events:PutEvents", - Resource = aws_cloudwatch_event_bus.event_bus_for_sage_maker_results.arn - } - ] - }) - } -} - -resource "aws_lambda_function" "lambda_function_to_write_to_mdb" { - function_name = "push_lambda_function" - package_type = "Image" - role = aws_iam_role.push_lambda_function_role.arn - image_uri = var.push_lambda_ecr_image_uri - environment { - variables = { - mongo_endpoint = var.mongo_endpoint - dbname = var.database_name - } - } - architectures = [ - "x86_64" - ] - memory_size = 1024 - timeout = 300 -} - -resource "aws_iam_role" "push_lambda_function_role" { - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Effect = "Allow" - Principal = { - Service = [ - "lambda.amazonaws.com" - ] - } - Action = [ - "sts:AssumeRole" - ] - } - ] - }) - path = "/" - managed_policy_arns = [ - "arn:${data.aws_partition.current.partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - inline_policy { - name = "sagemaker-endpoint-invokation-policy" - policy = jsonencode({ - Version = "2012-10-17", - Statement = [ - { - Effect = "Allow", - Action = "sagemaker:InvokeEndpoint", - Resource = aws_sagemaker_endpoint.endpoint.arn - }, - { - Effect = "Allow", - Action = "events:PutEvents", - Resource = aws_cloudwatch_event_rule.event_rule_to_match_mdb_events.arn - } - ] - }) - } -} - -resource "aws_cloudwatch_event_rule" "event_rule_to_capture_events_sent_from_lambda_function" { - description = "Event Rule to match result events returned by pull Lambda." - event_bus_name = aws_cloudwatch_event_bus.event_bus_for_sage_maker_results.name - event_pattern = jsonencode({ - source = [ - "user-event" - ] - detail-type = [ - "user-preferences" - ] - }) - is_enabled = true - name = "push-to-mongodb" -} - -resource "aws_cloudwatch_event_target" "write_event_from_lambda_to_target" { - event_bus_name = aws_cloudwatch_event_bus.event_bus_for_sage_maker_results.name - rule = aws_cloudwatch_event_rule.event_rule_to_capture_events_sent_from_lambda_function.name - target_id = "EventRuleToCaptureEventsSentFromLambdaFunctionID" - arn = aws_lambda_function.lambda_function_to_write_to_mdb.arn -} - -resource "aws_lambda_permission" "event_bridge_lambda_permission1" { - function_name = aws_lambda_function.lambda_function_to_read_mdb_events.arn - action = "lambda:InvokeFunction" - principal = "events.amazonaws.com" - source_arn = aws_cloudwatch_event_rule.event_rule_to_match_mdb_events.arn -} - -resource "aws_lambda_permission" "event_bridge_lambda_permission2" { - function_name = aws_lambda_function.lambda_function_to_write_to_mdb.arn - action = "lambda:InvokeFunction" - principal = "events.amazonaws.com" - source_arn = aws_cloudwatch_event_rule.event_rule_to_capture_events_sent_from_lambda_function.arn -} \ No newline at end of file diff --git a/modules/terraform-mongodbatlas-amazon-sagemaker-integration/variables.tf b/modules/terraform-mongodbatlas-amazon-sagemaker-integration/variables.tf deleted file mode 100644 index e788272a9b..0000000000 --- a/modules/terraform-mongodbatlas-amazon-sagemaker-integration/variables.tf +++ /dev/null @@ -1,75 +0,0 @@ -variable "atlas_org_id" { - description = "Atlas organization id" - type = string -} -variable "public_key" { - description = "Public API key to authenticate to Atlas" - type = string -} -variable "private_key" { - description = "Private API key to authenticate to Atlas" - type = string -} - - -variable profile { - description = "A secret with name cfn/atlas/profile/{Profile}" - default = "default" - type = string -} - -variable atlas_project_id { - description = "Atlas Project ID." - type = string -} - -variable database_name { - description = "Database name for the trigger." - type = string -} - -variable collection_name { - description = "Collection name for the trigger." - type = string -} - -variable service_id { - description = "Service ID." - type = string -} - -variable realm_app_id { - description = "Realm App ID." - type = string -} - -variable model_data_s3_uri { - description = "The S3 path where the model artifacts, which result from model training, are stored. This path must point to a single gzip compressed tar archive (.tar.gz suffix)." - type = string -} - -variable model_ecr_image_uri { - description = "AWS managed Deep Learning Container Image URI or your custom Image URI from ECR to deploy and run the model." - type = string -} - -variable pull_lambda_ecr_image_uri { - description = "ECR image URI of the Lambda function to read MongoDB events from EventBridge." - type = string -} - -variable push_lambda_ecr_image_uri { - description = "ECR image URI of the Lambda function to write results back to MongoDB." - type = string -} - -variable mongo_endpoint { - description = "Your MongoDB endpoint to push results by Lambda function." - type = string -} - -variable "trigger_name" { - description = "value of trigger name" - type = string - -} diff --git a/modules/terraform-mongodbatlas-amazon-sagemaker-integration/versions.tf b/modules/terraform-mongodbatlas-amazon-sagemaker-integration/versions.tf deleted file mode 100644 index 68b0b35a68..0000000000 --- a/modules/terraform-mongodbatlas-amazon-sagemaker-integration/versions.tf +++ /dev/null @@ -1,13 +0,0 @@ -terraform { - required_providers { - mongodbatlas = { - source = "mongodb/mongodbatlas" - version = "1.12.1" - } - aws = { - source = "hashicorp/aws" - version = "~> 5.17.0" - } - } - required_version = ">= 0.13" -} \ No newline at end of file diff --git a/modules/terraform-mongodbatlas-basic/README.md b/modules/terraform-mongodbatlas-basic/README.md deleted file mode 100644 index ff2e72d91b..0000000000 --- a/modules/terraform-mongodbatlas-basic/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# quickstart-mongodb-atlas - - - -## Overview - -![image](https://user-images.githubusercontent.com/5663078/229103723-4c6b9ab1-9492-47ba-b04d-7f29079e3817.png) - -The Atlas Partner Solutions templates allow you to set up all you need to start using MongoDB Atlas. We provide four different templates: - -- Deploy MongoDB Atlas without VPC peering. This option peers MongoDB Atlas with your existing VPC. -- Deploy MongoDB Atlas with VPC peering into a new VPC (end-to-end deployment). This option builds a complete MongoDB Atlas environment within AWS consisting of a project, cluster, and more. -- Deploy MongoDB Atlas with VPC peering into an existing VPC. This option peers MongoDB Atlas with a new VPC. -- Deploy MongoDB Atlas with Private Endpoint. This option connects MongoDB Atlas AWS VPC using Private Endpoint. - -All the quickstart templates create an Atlas Project, Cluster, Database User and enable public access into your cluster. - - - -## MongoDB Atlas CFN Resources used by the templates - -- [MongoDB::Atlas::Cluster](../../mongodbatlas/resource_mongodbatlas_cluster.go) -- [MongoDB::Atlas::ProjectIpAccessList](../../mongodbatlas/fw_resource_mongodbatlas_project_ip_access_list.go) -- [MongoDB::Atlas::DatabaseUser](../../mongodbatlas/fw_resource_mongodbatlas_database_user.go) -- [MongoDB::Atlas::Project](../../mongodbatlas/fw_resource_mongodbatlas_project.go) -- [MongoDB::Atlas::NetworkPeering](../../mongodbatlas/resource_mongodbatlas_network_peering.go) -- [MongoDB::Atlas::NetworkContainer](../../mongodbatlas/resource_mongodbatlas_network_container.go) -- [MongoDB::Atlas::PrivateEndpoint](../../mongodbatlas/resource_mongodbatlas_privatelink_endpoint.go) - - -## Environment Configured by the Partner Solution templates -All Partner Solutions templates will generate the following resources: -- An Atlas Project in the organization that was provided as input. -- An Atlas Cluster with authentication and authorization enabled, which cannot be accessed through the public internet. -- A Database user that can access the cluster. -- The IP address range provided as input will be added to the Atlas access list, allowing the cluster to be accessed through the public internet. - -The specific resources that will be created depend on which Partner Solutions template is used: - -- A new AWS VPC (Virtual Private Cloud) will be created. -- A VPC peering connection will be established between the MongoDB Atlas VPC (where your cluster is located) and the VPC on AWS. - diff --git a/modules/terraform-mongodbatlas-basic/aws-vpc.tf b/modules/terraform-mongodbatlas-basic/aws-vpc.tf deleted file mode 100644 index 6932444053..0000000000 --- a/modules/terraform-mongodbatlas-basic/aws-vpc.tf +++ /dev/null @@ -1,59 +0,0 @@ -resource "aws_vpc_endpoint" "vpce_east" { - vpc_id = aws_vpc.vpc_east.id - service_name = mongodbatlas_privatelink_endpoint.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 = var.aws_vpc_cidr_block - 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 = var.aws_route_table_cidr_block - gateway_id = aws_internet_gateway.ig_east.id -} - -resource "aws_subnet" "subnet_east_a" { - vpc_id = aws_vpc.vpc_east.id - cidr_block = var.aws_subnet_cidr_block1 - map_public_ip_on_launch = true - availability_zone = var.aws_subnet_availability_zone1 -} - -resource "aws_subnet" "subnet_east_b" { - vpc_id = aws_vpc.vpc_east.id - cidr_block = var.aws_subnet_cidr_block2 - map_public_ip_on_launch = false - availability_zone = var.aws_subnet_availability_zone2 -} - -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 = var.aws_sg_ingress_from_port - to_port = var.aws_sg_ingress_to_port - protocol = var.aws_sg_ingress_protocol - cidr_blocks = [ - var.aws_vpc_cidr_block, - ] - } - egress { - from_port = var.aws_sg_egress_from_port - to_port = var.aws_sg_egress_to_port - protocol = var.aws_sg_egress_protocol - cidr_blocks = [ - var.aws_vpc_cidr_block - ] - } -} diff --git a/modules/terraform-mongodbatlas-basic/main.tf b/modules/terraform-mongodbatlas-basic/main.tf deleted file mode 100644 index a2e222513b..0000000000 --- a/modules/terraform-mongodbatlas-basic/main.tf +++ /dev/null @@ -1,114 +0,0 @@ -provider "mongodbatlas" { - public_key = var.public_key - private_key = var.private_key -} -locals { - ip_address_list = [ - for ip in var.ip_address : - { - ip_address = ip - comment = "IP Address ${ip}" - } - ] - - cidr_block_list = [ - for cidr in var.cidr_block : - { - cidr_block = cidr - comment = "CIDR Block ${cidr}" - } - ] -} - -# Project Resource -resource "mongodbatlas_project" "project" { - name = var.project_name - org_id = var.atlas_org_id -} - - -# IP Access List with IP Address -resource "mongodbatlas_project_ip_access_list" "ip" { - for_each = { - for index, ip in local.ip_address_list : - ip.comment => ip - } - project_id =mongodbatlas_project.project.id - ip_address = each.value.ip_address - comment = each.value.comment -} - -# IP Access List with CIDR Block -resource "mongodbatlas_project_ip_access_list" "cidr" { - - for_each = { - for index, cidr in local.cidr_block_list : - cidr.comment => cidr - } - project_id =mongodbatlas_project.project.id - cidr_block = each.value.cidr_block - comment = each.value.comment -} - -resource "mongodbatlas_cluster" "cluster" { - project_id = mongodbatlas_project.project.id - name = var.cluster_name - mongo_db_major_version = var.mongo_version - cluster_type = var.cluster_type - replication_specs { - num_shards = var.num_shards - regions_config { - region_name = var.region - electable_nodes = var.electable_nodes - priority = var.priority - read_only_nodes = var.read_only_nodes - } - } - # Provider Settings "block" - auto_scaling_disk_gb_enabled = var.auto_scaling_disk_gb_enabled - provider_name = var.provider_name - disk_size_gb = var.disk_size_gb - provider_instance_size_name = var.provider_instance_size_name -} - -# DATABASE USER -resource "mongodbatlas_database_user" "user" { - count = length(var.db_users) - username = var.db_users[count.index] - password = var.db_passwords[count.index] - project_id = mongodbatlas_project.project.id - auth_database_name = "admin" - - roles { - role_name = var.role_name - database_name = var.database_names[count.index] - } - - labels { - key = "Name" - value = var.database_names[count.index] - } - - scopes { - name = mongodbatlas_cluster.cluster.name - type = "CLUSTER" - } -} - -resource "mongodbatlas_privatelink_endpoint" "pe_east" { - project_id = mongodbatlas_project.project.id - provider_name = var.provider_name - region = var.aws_region -} - -resource "mongodbatlas_privatelink_endpoint_service" "pe_east_service" { - project_id = mongodbatlas_project.project.id - private_link_id = mongodbatlas_privatelink_endpoint.pe_east.private_link_id - endpoint_service_id = aws_vpc_endpoint.vpce_east.id - provider_name = var.provider_name -} - - -output "project_id" { - value = mongodbatlas_project.project.id -} \ No newline at end of file diff --git a/modules/terraform-mongodbatlas-basic/outputs.tf b/modules/terraform-mongodbatlas-basic/outputs.tf deleted file mode 100644 index 8b13789179..0000000000 --- a/modules/terraform-mongodbatlas-basic/outputs.tf +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modules/terraform-mongodbatlas-basic/variables.tf b/modules/terraform-mongodbatlas-basic/variables.tf deleted file mode 100644 index 871ba46898..0000000000 --- a/modules/terraform-mongodbatlas-basic/variables.tf +++ /dev/null @@ -1,217 +0,0 @@ -variable "atlas_org_id" { - description = "Atlas organization id" - type = string -} -variable "public_key" { - description = "Public API key to authenticate to Atlas" - type = string -} -variable "private_key" { - description = "Private API key to authenticate to Atlas" - type = string -} - -# project -variable "project_name" { - description = "Atlas project name" - default = "TenantUpgradeTest" - type = string -} - -#cluster -variable "cluster_name" { - description = "Atlas cluster name" - default = "cluster" - type = string -} - -variable "cluster_type" { - description = "Atlas cluster type" - default = "REPLICASET" - type = string -} - -variable "num_shards" { - description = "Atlas cluster number of shards" - default = 1 - type = number -} - -variable "priority" { - description = "Atlas cluster priority" - default = 7 - type = number -} - -variable "read_only_nodes" { - description = "Atlas cluster number of read only nodes" - default = 0 - type = number -} -variable "electable_nodes" { - description = "Atlas cluster number of electable nodes" - default = 3 - type = number -} - -variable "auto_scaling_disk_gb_enabled" { - description = "Atlas cluster auto scaling disk enabled" - default = false - type = bool -} - -variable "disk_size_gb" { - description = "Atlas cluster disk size in GB" - default = 10 - type = number -} -variable "provider_name" { - description = "Atlas cluster provider name" - default = "AWS" - type = string -} -variable "backing_provider_name" { - description = "Atlas cluster backing provider name" - default = "AWS" - type = string -} -variable "provider_instance_size_name" { - description = "Atlas cluster provider instance name" - default = "M10" - type = string -} - -variable "region" { - description = "Atlas cluster region" - default = "US_EAST_1" - type = string -} -variable "aws_region"{ - description = "AWS region" - default = "us-east-1" - type = string -} - -variable "mongo_version" { - description = "Atlas cluster version" - default = "4.4" - type = string -} - - -variable "user" { - description = "MongoDB Atlas User" - type = list(string) - default = ["dbuser1", "dbuser2"] -} -variable "db_passwords" { - description = "MongoDB Atlas User Password" - type = list(string) -} -variable "database_names" { - description = "The Database in the cluster" - type = list(string) -} - -# database user -variable "role_name" { - description = "Atlas database user role name" - default = "readWrite" - type = string -} - -# IP Access List -variable "cidr_block" { - description = "IP Access List CIDRs" - type = list(string) -} - -variable "ip_address" { - description = "IP Access List IP Addresses" - type = list(string) -} -# aws - -variable "aws_vpc_cidr_block" { - description = "AWS VPC CIDR block" - default = "10.0.0.0/16" - type = string -} - -# aws vpc -variable "aws_vpc_ingress" { - description = "AWS VPC ingress CIDR block" - type = string -} - -variable "aws_vpc_egress" { - description = "AWS VPC egress CIDR block" - type = string -} - -variable "aws_route_table_cidr_block" { - description = "AWS route table CIDR block" - default = "0.0.0.0/0" - type = string -} - -variable "aws_subnet_cidr_block1" { - description = "AWS subnet CIDR block" - type = string -} -variable "aws_subnet_cidr_block2" { - description = "AWS subnet CIDR block" - type = string -} - -variable "aws_subnet_availability_zone1" { - description = "AWS subnet availability zone" - default = "us-east-1a" - type = string -} -variable "aws_subnet_availability_zone2" { - description = "AWS subnet availability zone" - default = "us-east-1b" - type = string -} - -variable "aws_sg_ingress_from_port" { - description = "AWS security group ingress from port" - default = 27017 - type = number -} - -variable "aws_sg_ingress_to_port" { - description = "AWS security group ingress to port" - default = 27017 - type = number -} - -variable "aws_sg_ingress_protocol" { - description = "AWS security group ingress protocol" - default = "tcp" - type = string -} - -variable "aws_sg_egress_from_port" { - description = "AWS security group egress from port" - default = 0 - type = number -} - -variable "aws_sg_egress_to_port" { - description = "AWS security group egress to port" - default = 0 - type = number -} - -variable "aws_sg_egress_protocol" { - description = "AWS security group egress protocol" - default = "-1" - type = string -} - -variable "db_users" { - description = "Atlas database users" - type = list(string) -} \ No newline at end of file diff --git a/modules/terraform-mongodbatlas-basic/versions.tf b/modules/terraform-mongodbatlas-basic/versions.tf deleted file mode 100644 index 051942514f..0000000000 --- a/modules/terraform-mongodbatlas-basic/versions.tf +++ /dev/null @@ -1,14 +0,0 @@ -terraform { - required_providers { - mongodbatlas = { - source = "mongodb/mongodbatlas" - version = "1.12.1" - } - aws = { - source = "hashicorp/aws" - version = "~> 5.0" - } - } - required_version = ">= 0.13" -} - From 494026a0f4b0dff7f95e0b278a632a3733656740 Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:33:15 +0200 Subject: [PATCH 2/2] gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 059f2a8a95..d359912656 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ terraform.tfplan terraform.tfstate .terraform.lock.hcl bin/ -modules-dev/ /pkg/ .vagrant/ *.backup