Skip to content

Commit ec13c1c

Browse files
feat: use the terraform-ibm-cos module to provision COS instance (#139)
1 parent a9c06c2 commit ec13c1c

File tree

11 files changed

+248
-49
lines changed

11 files changed

+248
-49
lines changed

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2023-04-29T00:18:57Z",
6+
"generated_at": "2023-05-02T10:24:50Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,14 @@ Optionally, you need the following permissions to attach Access Management tags
135135
| Name | Version |
136136
|------|---------|
137137
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
138-
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.49.0 |
138+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.51.0 |
139139
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.2.1 |
140140

141141
## Modules
142142

143-
No modules.
143+
| Name | Source | Version |
144+
|------|--------|---------|
145+
| <a name="module_cos_instance"></a> [cos\_instance](#module\_cos\_instance) | git::https://github.com/terraform-ibm-modules/terraform-ibm-cos.git | v6.1.0 |
144146

145147
## Resources
146148

@@ -150,7 +152,6 @@ No modules.
150152
| [ibm_container_vpc_cluster.cluster](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/container_vpc_cluster) | resource |
151153
| [ibm_container_vpc_worker_pool.autoscaling_pool](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/container_vpc_worker_pool) | resource |
152154
| [ibm_container_vpc_worker_pool.pool](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/container_vpc_worker_pool) | resource |
153-
| [ibm_resource_instance.cos_instance](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_instance) | resource |
154155
| [ibm_resource_tag.cluster_access_tag](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_tag) | resource |
155156
| [ibm_resource_tag.cos_access_tag](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_tag) | resource |
156157
| [null_resource.confirm_network_healthy](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |

examples/add_rules_to_sg/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module to ensure lowest version still works
55
ibm = {
66
source = "ibm-cloud/ibm"
7-
version = "1.49.0"
7+
version = "1.51.0"
88
}
99
}
1010
}

examples/apply_taints/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module to ensure lowest version still works
55
ibm = {
66
source = "ibm-cloud/ibm"
7-
version = "1.49.0"
7+
version = "1.51.0"
88
}
99
}
1010
}

examples/existing_cos/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module to ensure lowest version still works
55
ibm = {
66
source = "ibm-cloud/ibm"
7-
version = "1.49.0"
7+
version = "1.51.0"
88
}
99
}
1010
}

examples/multiple_mzr_clusters/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module to ensure lowest version still works
55
ibm = {
66
source = "ibm-cloud/ibm"
7-
version = "1.49.0"
7+
version = "1.51.0"
88
}
99
# The kubernetes provider is not actually required by the module itself, just this example, so OK to use ">=" here instead of locking into a version
1010
kubernetes = {

examples/single_zone_cluster/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module to ensure lowest version still works
55
ibm = {
66
source = "ibm-cloud/ibm"
7-
version = "1.49.0"
7+
version = "1.51.0"
88
}
99
}
1010
}

examples/standard/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module to ensure lowest version still works
55
ibm = {
66
source = "ibm-cloud/ibm"
7-
version = "1.49.0"
7+
version = "1.51.0"
88
}
99
}
1010
}

main.tf

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ locals {
1616
cos_name = var.use_existing_cos == true || (var.use_existing_cos == false && var.cos_name != null) ? var.cos_name : "${var.cluster_name}_cos"
1717
cos_location = "global"
1818
cos_plan = "standard"
19-
cos_instance_crn = var.use_existing_cos != false ? var.existing_cos_id : ibm_resource_instance.cos_instance[0].id
19+
cos_instance_crn = var.use_existing_cos != false ? var.existing_cos_id : module.cos_instance[0].cos_instance_id
2020

2121
# Validation approach based on https://stackoverflow.com/a/66682419
2222
validate_condition = var.use_existing_cos == true && var.existing_cos_id == null
@@ -37,19 +37,26 @@ data "ibm_container_cluster_versions" "cluster_versions" {
3737
region = var.region
3838
}
3939

40-
resource "ibm_resource_instance" "cos_instance" {
40+
module "cos_instance" {
4141
count = var.use_existing_cos ? 0 : 1
4242

43-
name = local.cos_name
44-
resource_group_id = var.resource_group_id
45-
service = "cloud-object-storage"
46-
plan = local.cos_plan
47-
location = local.cos_location
43+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-cos.git?ref=v6.1.0"
44+
cos_instance_name = local.cos_name
45+
resource_group_id = var.resource_group_id
46+
cos_plan = local.cos_plan
47+
cos_location = local.cos_location
48+
encryption_enabled = false
49+
create_cos_bucket = false
50+
}
51+
52+
moved {
53+
from = ibm_resource_instance.cos_instance[0]
54+
to = module.cos_instance[0].ibm_resource_instance.cos_instance[0]
4855
}
4956

5057
resource "ibm_resource_tag" "cos_access_tag" {
5158
count = var.use_existing_cos || length(var.access_tags) == 0 ? 0 : 1
52-
resource_id = ibm_resource_instance.cos_instance[0].crn
59+
resource_id = module.cos_instance[0].cos_instance_id
5360
tags = var.access_tags
5461
tag_type = "access"
5562
}

0 commit comments

Comments
 (0)