Skip to content

Commit aca906b

Browse files
feat: added existing instance test and refactored tests
1 parent ca80ff5 commit aca906b

File tree

13 files changed

+146
-37
lines changed

13 files changed

+146
-37
lines changed

examples/backup-restore/README.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ This example provides an end-to-end executable flow of how a Elasticsearch DB ca
44

55
- Create a new resource group if one is not passed in.
66
- Create a new ICD Elasticsearch database instance if no existing backup crn is provided.
7-
- Create a restored ICD Elasticsearch database instance pointing to the backup of the first instance.
7+
- Create a restored ICD Elasticsearch database instance pointing to the backup of the first instance.

examples/backup-restore/catalogValidationValues.json.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"region": "us-south",
44
"resource_tags": $TAGS,
55
"prefix": $PREFIX
6-
}
6+
}

examples/backup-restore/main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ data "ibm_database_backups" "backup_database" {
1616
}
1717
# New elasticsearch instance pointing to the backup instance
1818
module "restored_icd_elasticsearch" {
19-
source = "../.."
20-
resource_group_id = module.resource_group.resource_group_id
21-
name = "${var.prefix}-elasticsearch-restored"
19+
source = "../.."
20+
resource_group_id = module.resource_group.resource_group_id
21+
name = "${var.prefix}-elasticsearch-restored"
2222
elasticsearch_version = var.elasticsearch_version
23-
region = var.region
24-
tags = var.resource_tags
25-
access_tags = var.access_tags
26-
member_host_flavor = "multitenant"
27-
backup_crn = data.ibm_database_backups.backup_database.backups[0].backup_id
28-
}
23+
region = var.region
24+
tags = var.resource_tags
25+
access_tags = var.access_tags
26+
member_host_flavor = "multitenant"
27+
backup_crn = data.ibm_database_backups.backup_database.backups[0].backup_id
28+
}

examples/backup-restore/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ output "restored_icd_elasticsearch_id" {
99
output "restored_icd_elasticsearch_version" {
1010
description = "Restored elasticsearch instance version"
1111
value = module.restored_icd_elasticsearch.version
12-
}
12+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
provider "ibm" {
22
ibmcloud_api_key = var.ibmcloud_api_key
33
region = var.region
4-
}
4+
}

examples/backup-restore/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ variable "region" {
1313
variable "prefix" {
1414
type = string
1515
description = "Prefix to append to all resources created by this example"
16-
default = "backup"
16+
default = "backup"
1717
}
1818

1919
variable "elasticsearch_version" {
2020
type = string
21-
description = "Version of the elasticsearch instance. If no value passed, the current ICD preferred version is used."
21+
description = "Version of the elasticsearch instance. If no value passed, the current ICD preferred version is used."
2222
default = null
2323
}
2424
variable "resource_group" {
@@ -43,4 +43,4 @@ variable "elasticsearch_db_backup_crn" {
4343
type = string
4444
description = "The existing CRN of a backup resource to restore from. If null then it will create a new instance first and then create another instance pointing to the backup of the first instance."
4545
default = null
46-
}
46+
}

examples/backup-restore/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ terraform {
88
version = ">=1.70.0, <2.0.0"
99
}
1010
}
11-
}
11+
}

examples/basic/main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ module "resource_group" {
1313
# Elasticsearch Instance
1414
##############################################################################
1515

16-
module "icd_elasticsearch" {
16+
module "database" {
1717
source = "../../"
1818
resource_group_id = module.resource_group.resource_group_id
19-
name = "${var.prefix}-elasticsearch"
19+
name = "${var.prefix}-data-store"
2020
region = var.region
2121
elasticsearch_version = var.elasticsearch_version
2222
tags = var.resource_tags
2323
access_tags = var.access_tags
24+
service_endpoints = var.service_endpoints
25+
member_host_flavor = var.member_host_flavor
2426
service_credential_names = {
2527
"elasticsearch_admin" : "Administrator",
2628
"elasticsearch_operator" : "Operator",
@@ -32,7 +34,7 @@ module "icd_elasticsearch" {
3234
# wait 60 secs to allow IAM credential access to kick in before configuring instance
3335
# without the wait, you can intermittently get "Error 401 (Unauthorized)"
3436
resource "time_sleep" "wait" {
35-
depends_on = [module.icd_elasticsearch]
37+
depends_on = [module.database]
3638
create_duration = "60s"
3739
}
3840

examples/basic/outputs.tf

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,37 @@
22
# Outputs
33
##############################################################################
44
output "id" {
5-
description = "Elasticsearch id"
6-
value = module.icd_elasticsearch.id
5+
description = "Database instance id"
6+
value = module.database.id
7+
}
8+
9+
output "elasticsearch_crn" {
10+
description = "Elasticsearch CRN"
11+
value = module.database.crn
712
}
813

914
output "version" {
1015
description = "Enterprise DB instance version"
11-
value = module.icd_elasticsearch.version
16+
value = module.database.version
1217
}
1318

1419
output "adminuser" {
1520
description = "Database admin user name"
16-
value = module.icd_elasticsearch.adminuser
21+
value = module.database.adminuser
1722
}
1823

1924
output "hostname" {
2025
description = "Database connection hostname"
21-
value = module.icd_elasticsearch.hostname
26+
value = module.database.hostname
2227
}
2328

2429
output "port" {
2530
description = "Database connection port"
26-
value = module.icd_elasticsearch.port
31+
value = module.database.port
2732
}
2833

2934
output "certificate_base64" {
3035
description = "Database connection certificate"
31-
value = module.icd_elasticsearch.certificate_base64
36+
value = module.database.certificate_base64
3237
sensitive = true
3338
}

examples/basic/provider.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ provider "ibm" {
44
}
55

66
provider "elasticsearch" {
7-
username = module.icd_elasticsearch.service_credentials_object.credentials["elasticsearch_admin"].username
8-
password = module.icd_elasticsearch.service_credentials_object.credentials["elasticsearch_admin"].password
9-
url = "https://${module.icd_elasticsearch.service_credentials_object.hostname}:${module.icd_elasticsearch.service_credentials_object.port}"
10-
cacert_file = base64decode(module.icd_elasticsearch.service_credentials_object.certificate)
7+
username = module.database.service_credentials_object.credentials["elasticsearch_admin"].username
8+
password = module.database.service_credentials_object.credentials["elasticsearch_admin"].password
9+
url = "https://${module.database.service_credentials_object.hostname}:${module.database.service_credentials_object.port}"
10+
cacert_file = base64decode(module.database.service_credentials_object.certificate)
1111
}

0 commit comments

Comments
 (0)