Skip to content

Commit

Permalink
Examples of terratest upgrade (#431)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
coderGo93 and Edgar López authored Apr 20, 2021
1 parent 135e66f commit 1bda102
Show file tree
Hide file tree
Showing 16 changed files with 508 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
example.tf
terraform.tfplan
terraform.tfstate
.terraform.lock.hcl
bin/
modules-dev/
/pkg/
Expand Down
30 changes: 30 additions & 0 deletions examples/test-upgrade/v090/cluster/v082/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
resource "mongodbatlas_project" "test" {
name = var.project_name
org_id = var.org_id
}

resource "mongodbatlas_cluster" "test" {
project_id = mongodbatlas_project.test.id
name = var.cluster_name
disk_size_gb = 100
num_shards = 1
replication_factor = 3
provider_backup_enabled = true
pit_enabled = true
auto_scaling_disk_gb_enabled = true
mongo_db_major_version = var.mongodb_major_version

// Provider Settings "block"
provider_name = "AWS"
provider_disk_iops = 300
provider_encrypt_ebs_volume = false
provider_instance_size_name = "M30"
provider_region_name = "EU_CENTRAL_1"
}

output "project_id" {
value = mongodbatlas_project.test.id
}
output "cluster_name" {
value = mongodbatlas_cluster.test.name
}
24 changes: 24 additions & 0 deletions examples/test-upgrade/v090/cluster/v082/variables.tf
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 "org_id" {
description = "The organization ID"
default = ""
}
variable "cluster_name" {
description = "Cluster name"
default = ""
}
variable "mongodb_major_version" {
description = "MongoDB major version"
default = ""
}
9 changes: 9 additions & 0 deletions examples/test-upgrade/v090/cluster/v082/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
mongodbatlas = {
source = "mongodb/mongodbatlas"
version = "0.8.2"
}
}
required_version = ">= 0.13"
}
30 changes: 30 additions & 0 deletions examples/test-upgrade/v090/cluster/v090/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
resource "mongodbatlas_project" "test" {
name = var.project_name
org_id = var.org_id
}

resource "mongodbatlas_cluster" "test" {
project_id = mongodbatlas_project.test.id
name = var.cluster_name
disk_size_gb = 100
num_shards = 1
replication_factor = 3
provider_backup_enabled = true
pit_enabled = true
auto_scaling_disk_gb_enabled = true
mongo_db_major_version = var.mongodb_major_version

// Provider Settings "block"
provider_name = "AWS"
provider_disk_iops = 300
provider_encrypt_ebs_volume = false
provider_instance_size_name = "M30"
provider_region_name = "EU_CENTRAL_1"
}

output "project_id" {
value = mongodbatlas_project.test.id
}
output "cluster_name" {
value = mongodbatlas_cluster.test.name
}
24 changes: 24 additions & 0 deletions examples/test-upgrade/v090/cluster/v090/variables.tf
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 "org_id" {
description = "The organization ID"
default = ""
}
variable "cluster_name" {
description = "Cluster name"
default = ""
}
variable "mongodb_major_version" {
description = "MongoDB major version"
default = ""
}
9 changes: 9 additions & 0 deletions examples/test-upgrade/v090/cluster/v090/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
mongodbatlas = {
source = "mongodb/mongodbatlas"
version = "0.7.0"
}
}
required_version = ">= 0.13"
}
31 changes: 31 additions & 0 deletions examples/test-upgrade/v090/database-user/v082/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
resource "mongodbatlas_project" "test" {
name = var.project_name
org_id = var.org_id
}

resource "mongodbatlas_database_user" "test" {
username = var.username
x509_type = "CUSTOMER"
project_id = mongodbatlas_project.test.id
auth_database_name = "$external"

roles {
role_name = var.role_name
database_name = "admin"
}

labels {
key = "First Key"
value = "First Value"
}
}

output "project_id" {
value = mongodbatlas_project.test.id
}
output "username" {
value = mongodbatlas_database_user.test.username
}
output "auth_database_name" {
value = mongodbatlas_database_user.test.auth_database_name
}
24 changes: 24 additions & 0 deletions examples/test-upgrade/v090/database-user/v082/variables.tf
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 "org_id" {
description = "The organization ID"
default = ""
}
variable "username" {
description = "Username"
default = ""
}
variable "role_name" {
description = "The role name"
default = ""
}
9 changes: 9 additions & 0 deletions examples/test-upgrade/v090/database-user/v082/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
mongodbatlas = {
source = "mongodb/mongodbatlas"
version = "0.8.2"
}
}
required_version = ">= 0.13"
}
21 changes: 21 additions & 0 deletions examples/test-upgrade/v090/database-user/v090/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "mongodbatlas_project" "test" {
name = var.project_name
org_id = var.org_id
}

resource "mongodbatlas_database_user" "test" {
username = var.username
ldap_auth_type = "USER"
project_id = mongodbatlas_project.test.id
auth_database_name = "$external"

roles {
role_name = var.role_name
database_name = "admin"
}

labels {
key = "First Key"
value = "First Value"
}
}
24 changes: 24 additions & 0 deletions examples/test-upgrade/v090/database-user/v090/variables.tf
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 "org_id" {
description = "The organization ID"
default = ""
}
variable "username" {
description = "Username"
default = ""
}
variable "role_name" {
description = "The role name"
default = ""
}
10 changes: 10 additions & 0 deletions examples/test-upgrade/v090/database-user/v090/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_providers {
mongodbatlas = {
source = "mongodb/mongodbatlas"
version = "0.7.0"
}
}
required_version = ">= 0.13"
}

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.14
require (
github.com/client9/misspell v0.3.4
github.com/go-test/deep v1.0.7
github.com/gruntwork-io/terratest v0.32.3
github.com/gruntwork-io/terratest v0.32.20
github.com/hashicorp/terraform-plugin-sdk v1.14.0
github.com/mongodb-forks/digest v1.0.1
github.com/mwielbut/pointy v1.1.0
Expand Down
Loading

0 comments on commit 1bda102

Please sign in to comment.