Skip to content

Commit 1bda102

Browse files
coderGo93Edgar López
andauthored
Examples of terratest upgrade (#431)
* chore: updated terratest sdk * test: added terratest for upgrade in some resources * made changes suggested by angel and melissa * added newline to avoid github linter error Co-authored-by: Edgar López <[email protected]>
1 parent 135e66f commit 1bda102

File tree

16 files changed

+508
-1
lines changed

16 files changed

+508
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
example.tf
55
terraform.tfplan
66
terraform.tfstate
7+
.terraform.lock.hcl
78
bin/
89
modules-dev/
910
/pkg/
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
resource "mongodbatlas_project" "test" {
2+
name = var.project_name
3+
org_id = var.org_id
4+
}
5+
6+
resource "mongodbatlas_cluster" "test" {
7+
project_id = mongodbatlas_project.test.id
8+
name = var.cluster_name
9+
disk_size_gb = 100
10+
num_shards = 1
11+
replication_factor = 3
12+
provider_backup_enabled = true
13+
pit_enabled = true
14+
auto_scaling_disk_gb_enabled = true
15+
mongo_db_major_version = var.mongodb_major_version
16+
17+
// Provider Settings "block"
18+
provider_name = "AWS"
19+
provider_disk_iops = 300
20+
provider_encrypt_ebs_volume = false
21+
provider_instance_size_name = "M30"
22+
provider_region_name = "EU_CENTRAL_1"
23+
}
24+
25+
output "project_id" {
26+
value = mongodbatlas_project.test.id
27+
}
28+
output "cluster_name" {
29+
value = mongodbatlas_cluster.test.name
30+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
variable "public_key" {
2+
description = "The public API key for MongoDB Atlas"
3+
default = ""
4+
}
5+
variable "private_key" {
6+
description = "The private API key for MongoDB Atlas"
7+
default = ""
8+
}
9+
variable "project_name" {
10+
description = "Atlas project name"
11+
default = ""
12+
}
13+
variable "org_id" {
14+
description = "The organization ID"
15+
default = ""
16+
}
17+
variable "cluster_name" {
18+
description = "Cluster name"
19+
default = ""
20+
}
21+
variable "mongodb_major_version" {
22+
description = "MongoDB major version"
23+
default = ""
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_providers {
3+
mongodbatlas = {
4+
source = "mongodb/mongodbatlas"
5+
version = "0.8.2"
6+
}
7+
}
8+
required_version = ">= 0.13"
9+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
resource "mongodbatlas_project" "test" {
2+
name = var.project_name
3+
org_id = var.org_id
4+
}
5+
6+
resource "mongodbatlas_cluster" "test" {
7+
project_id = mongodbatlas_project.test.id
8+
name = var.cluster_name
9+
disk_size_gb = 100
10+
num_shards = 1
11+
replication_factor = 3
12+
provider_backup_enabled = true
13+
pit_enabled = true
14+
auto_scaling_disk_gb_enabled = true
15+
mongo_db_major_version = var.mongodb_major_version
16+
17+
// Provider Settings "block"
18+
provider_name = "AWS"
19+
provider_disk_iops = 300
20+
provider_encrypt_ebs_volume = false
21+
provider_instance_size_name = "M30"
22+
provider_region_name = "EU_CENTRAL_1"
23+
}
24+
25+
output "project_id" {
26+
value = mongodbatlas_project.test.id
27+
}
28+
output "cluster_name" {
29+
value = mongodbatlas_cluster.test.name
30+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
variable "public_key" {
2+
description = "The public API key for MongoDB Atlas"
3+
default = ""
4+
}
5+
variable "private_key" {
6+
description = "The private API key for MongoDB Atlas"
7+
default = ""
8+
}
9+
variable "project_name" {
10+
description = "Atlas project name"
11+
default = ""
12+
}
13+
variable "org_id" {
14+
description = "The organization ID"
15+
default = ""
16+
}
17+
variable "cluster_name" {
18+
description = "Cluster name"
19+
default = ""
20+
}
21+
variable "mongodb_major_version" {
22+
description = "MongoDB major version"
23+
default = ""
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_providers {
3+
mongodbatlas = {
4+
source = "mongodb/mongodbatlas"
5+
version = "0.7.0"
6+
}
7+
}
8+
required_version = ">= 0.13"
9+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
resource "mongodbatlas_project" "test" {
2+
name = var.project_name
3+
org_id = var.org_id
4+
}
5+
6+
resource "mongodbatlas_database_user" "test" {
7+
username = var.username
8+
x509_type = "CUSTOMER"
9+
project_id = mongodbatlas_project.test.id
10+
auth_database_name = "$external"
11+
12+
roles {
13+
role_name = var.role_name
14+
database_name = "admin"
15+
}
16+
17+
labels {
18+
key = "First Key"
19+
value = "First Value"
20+
}
21+
}
22+
23+
output "project_id" {
24+
value = mongodbatlas_project.test.id
25+
}
26+
output "username" {
27+
value = mongodbatlas_database_user.test.username
28+
}
29+
output "auth_database_name" {
30+
value = mongodbatlas_database_user.test.auth_database_name
31+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
variable "public_key" {
2+
description = "The public API key for MongoDB Atlas"
3+
default = ""
4+
}
5+
variable "private_key" {
6+
description = "The private API key for MongoDB Atlas"
7+
default = ""
8+
}
9+
variable "project_name" {
10+
description = "Atlas project name"
11+
default = ""
12+
}
13+
variable "org_id" {
14+
description = "The organization ID"
15+
default = ""
16+
}
17+
variable "username" {
18+
description = "Username"
19+
default = ""
20+
}
21+
variable "role_name" {
22+
description = "The role name"
23+
default = ""
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_providers {
3+
mongodbatlas = {
4+
source = "mongodb/mongodbatlas"
5+
version = "0.8.2"
6+
}
7+
}
8+
required_version = ">= 0.13"
9+
}

0 commit comments

Comments
 (0)