-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INTMDB-128: Modified design when you can get .id from various resourc…
…es (#471) * refactor: added func to get encoded id, when you want to use by implicit depedency with id from various resources instead of another id like container_id * fixes linter * added terrates to show it passes * update sate id Co-authored-by: Edgar López <[email protected]>
- Loading branch information
Showing
34 changed files
with
553 additions
and
38 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
examples/test-upgrade/v100/design-id-reference/alert-configuration/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
data "mongodbatlas_project" "test" { | ||
name = var.project_name | ||
} | ||
|
||
resource "mongodbatlas_alert_configuration" "test" { | ||
project_id = data.mongodbatlas_project.test.id | ||
event_type = "OUTSIDE_METRIC_THRESHOLD" | ||
enabled = true | ||
|
||
notification { | ||
type_name = "GROUP" | ||
interval_min = 5 | ||
delay_min = 0 | ||
sms_enabled = false | ||
email_enabled = true | ||
} | ||
|
||
matcher { | ||
field_name = "HOSTNAME_AND_PORT" | ||
operator = "EQUALS" | ||
value = "SECONDARY" | ||
} | ||
|
||
metric_threshold = { | ||
metric_name = "ASSERT_REGULAR" | ||
operator = "LESS_THAN" | ||
threshold = 99.0 | ||
units = "RAW" | ||
mode = "AVERAGE" | ||
} | ||
} | ||
|
||
data "mongodbatlas_alert_configuration" "test" { | ||
project_id = mongodbatlas_alert_configuration.test.project_id | ||
alert_configuration_id = mongodbatlas_alert_configuration.test.id | ||
} | ||
|
||
output "alert_id_state" { | ||
value = mongodbatlas_alert_configuration.test.id | ||
} | ||
output "alert_configuration_id" { | ||
value = mongodbatlas_alert_configuration.test.alert_configuration_id | ||
} |
12 changes: 12 additions & 0 deletions
12
examples/test-upgrade/v100/design-id-reference/alert-configuration/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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 = "" | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/test-upgrade/v100/design-id-reference/alert-configuration/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
required_providers { | ||
mongodbatlas = { | ||
source = "mongodb/mongodbatlas" | ||
version = "0.1.0-dev" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} |
38 changes: 38 additions & 0 deletions
38
examples/test-upgrade/v100/design-id-reference/network/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
data "mongodbatlas_project" "test" { | ||
name = var.project_name | ||
} | ||
|
||
resource "mongodbatlas_network_container" "test" { | ||
project_id = data.mongodbatlas_project.test.id | ||
atlas_cidr_block = "192.168.208.0/21" | ||
provider_name = "AWS" | ||
region_name = var.region_name | ||
} | ||
|
||
resource "mongodbatlas_network_peering" "test" { | ||
accepter_region_name = lower(replace(var.region_name, "_", "-")) | ||
project_id = data.mongodbatlas_project.test.id | ||
container_id = mongodbatlas_network_container.test.id | ||
provider_name = "AWS" | ||
route_table_cidr_block = var.route_table_cidr_block | ||
vpc_id = var.vpc_id | ||
aws_account_id = var.aws_account_id | ||
} | ||
|
||
data "mongodbatlas_network_peering" "test" { | ||
project_id = data.mongodbatlas_project.test.id | ||
peering_id = mongodbatlas_network_peering.test.peer_id | ||
} | ||
|
||
output "container_id_state" { | ||
value = mongodbatlas_network_container.test.id | ||
} | ||
output "container_id" { | ||
value = mongodbatlas_network_container.test.container_id | ||
} | ||
output "peering_id_state" { | ||
value = mongodbatlas_network_peering.test.id | ||
} | ||
output "peer_id" { | ||
value = mongodbatlas_network_peering.test.peer_id | ||
} |
30 changes: 30 additions & 0 deletions
30
examples/test-upgrade/v100/design-id-reference/network/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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 "region_name" { | ||
description = "AWS region " | ||
default = "" | ||
} | ||
variable "route_table_cidr_block" { | ||
description = "CIDR Block" | ||
default = "" | ||
} | ||
variable "vpc_id" { | ||
description = "AWS VPC ID" | ||
default = "" | ||
} | ||
variable "aws_account_id" { | ||
description = "AWS account id" | ||
default = "" | ||
} | ||
|
||
|
9 changes: 9 additions & 0 deletions
9
examples/test-upgrade/v100/design-id-reference/network/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
required_providers { | ||
mongodbatlas = { | ||
source = "mongodb/mongodbatlas" | ||
version = "0.1.0-dev" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} |
56 changes: 56 additions & 0 deletions
56
examples/test-upgrade/v100/design-id-reference/privatelink/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
data "mongodbatlas_project" "test" { | ||
name = var.project_name | ||
} | ||
|
||
provider "aws" { | ||
region = "us-west-1" | ||
access_key = var.aws_access_key | ||
secret_key = var.aws_secret_key | ||
} | ||
|
||
resource "mongodbatlas_privatelink_endpoint" "test" { | ||
project_id = data.mongodbatlas_project.test.id | ||
provider_name = "AWS" | ||
region = "us-west-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 = data.mongodbatlas_project.test.id | ||
private_link_id = mongodbatlas_privatelink_endpoint.test.id | ||
endpoint_service_id = aws_vpc_endpoint.ptfe_service.id | ||
provider_name = "AWS" | ||
} | ||
|
||
data "mongodbatlas_privatelink_endpoint" "test" { | ||
project_id = data.mongodbatlas_project.test.id | ||
private_link_id = mongodbatlas_privatelink_endpoint.test.id | ||
provider_name = "AWS" | ||
} | ||
|
||
data "mongodbatlas_privatelink_endpoint_service" "test" { | ||
project_id = data.mongodbatlas_project.test.id | ||
private_link_id = mongodbatlas_privatelink_endpoint_service.test.id | ||
endpoint_service_id = mongodbatlas_privatelink_endpoint_service.test.endpoint_service_id | ||
provider_name = "AWS" | ||
} | ||
|
||
output "privatelink_id_state" { | ||
value = mongodbatlas_privatelink_endpoint.test.id | ||
} | ||
output "private_link_id" { | ||
value = mongodbatlas_privatelink_endpoint.test.private_link_id | ||
} | ||
output "privatelink_endpoint_service_state" { | ||
value = mongodbatlas_privatelink_endpoint_service.test.id | ||
} | ||
output "endpoint_service_id" { | ||
value = mongodbatlas_privatelink_endpoint_service.test.endpoint_service_id | ||
} |
41 changes: 41 additions & 0 deletions
41
examples/test-upgrade/v100/design-id-reference/privatelink/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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 "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 = "" | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
examples/test-upgrade/v100/design-id-reference/privatelink/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_providers { | ||
mongodbatlas = { | ||
source = "mongodb/mongodbatlas" | ||
version = "0.1.0-dev" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
examples/test-upgrade/v100/design-id-reference/project/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "mongodbatlas_project" "test" { | ||
name = var.project_name | ||
org_id = var.org_id | ||
} | ||
|
||
output "project_id" { | ||
value = mongodbatlas_project.test.id | ||
} |
16 changes: 16 additions & 0 deletions
16
examples/test-upgrade/v100/design-id-reference/project/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
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 = "" | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/test-upgrade/v100/design-id-reference/project/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
required_providers { | ||
mongodbatlas = { | ||
source = "mongodb/mongodbatlas" | ||
version = "0.1.0-dev" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} |
51 changes: 51 additions & 0 deletions
51
examples/test-upgrade/v100/design-id-reference/snapshot-restore/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
data "mongodbatlas_project" "test" { | ||
name = var.project_name | ||
} | ||
|
||
resource "mongodbatlas_cluster" "my_cluster" { | ||
project_id = data.mongodbatlas_project.test.id | ||
name = var.cluster_name | ||
disk_size_gb = 5 | ||
|
||
// Provider Settings "block" | ||
provider_name = "AWS" | ||
provider_region_name = "US_EAST_1" | ||
provider_instance_size_name = "M10" | ||
provider_backup_enabled = true //enable cloud provider snapshots | ||
provider_encrypt_ebs_volume = false | ||
} | ||
|
||
resource "mongodbatlas_cloud_provider_snapshot" "test" { | ||
project_id = data.mongodbatlas_project.test.id | ||
cluster_name = mongodbatlas_cluster.my_cluster.name | ||
description = var.description | ||
retention_in_days = var.retention_in_days | ||
} | ||
|
||
resource "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { | ||
project_id = data.mongodbatlas_project.test.id | ||
cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name | ||
snapshot_id = mongodbatlas_cloud_provider_snapshot.test.id | ||
delivery_type = { | ||
download = true | ||
} | ||
} | ||
|
||
data "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { | ||
project_id = data.mongodbatlas_project.test.id | ||
cluster_name = mongodbatlas_cloud_provider_snapshot_restore_job.test.cluster_name | ||
job_id = mongodbatlas_cloud_provider_snapshot_restore_job.test.id | ||
} | ||
|
||
output "snapshot_id_state" { | ||
value = mongodbatlas_cloud_provider_snapshot.test.id | ||
} | ||
output "snapshot_id" { | ||
value = mongodbatlas_cloud_provider_snapshot.test.snapshot_id | ||
} | ||
output "snapshot_restore_id_state" { | ||
value = mongodbatlas_cloud_provider_snapshot_restore_job.test.id | ||
} | ||
output "snapshot_restore_job_id" { | ||
value = mongodbatlas_cloud_provider_snapshot_restore_job.test.snapshot_restore_job_id | ||
} |
24 changes: 24 additions & 0 deletions
24
examples/test-upgrade/v100/design-id-reference/snapshot-restore/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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 "cluster_name" { | ||
description = "Cluster name" | ||
default = "" | ||
} | ||
variable "description" { | ||
description = "Description" | ||
default = "" | ||
} | ||
variable "retention_in_days" { | ||
description = "Retention in days" | ||
default = "" | ||
} |
10 changes: 10 additions & 0 deletions
10
examples/test-upgrade/v100/design-id-reference/snapshot-restore/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_providers { | ||
mongodbatlas = { | ||
source = "mongodb/mongodbatlas" | ||
version = "0.1.0-dev" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} | ||
|
Oops, something went wrong.