Skip to content

Commit c47d7cb

Browse files
authored
Add support to output GUID for instance / firewall for bucket / kms encryption for bucket (#14)
* Add guid output for instance and Firewall for bucket * update readme files * Add encrypton key crn to storage bucket * Change name of variable for encryption * Update examples with changes Co-authored-by: Adam Geiger <ageiger@us.ibm.com>
1 parent ea1cf67 commit c47d7cb

File tree

12 files changed

+65
-8
lines changed

12 files changed

+65
-8
lines changed

examples/bucket/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ module "cos_bucket" {
9797
| logdna\_crn | instance crn of logdna that will receive object event data | string | n/a | no |
9898
| read\_data\_events | If set to true, all object write events will be sent to Activity Tracke/logdna | bool | `true` | no |
9999
| write\_data\_events | If set to true, all object write events will be sent to Activity Tracke/logdna | bool | `true` | no |
100-
100+
| allowed_ip | A list of IPs you want to allow access to your bucket. | list | n/a | no |
101+
| kms_key_crn | The CRN of the root key that you want to use to encrypt data | string | n/a | no |
101102

102103
## NOTE:
103104

104105
* If we want to make use of a particular version of module, then set the argument "version" to respective module version.
105106

106-
* To attach a key to cos instance, enbale it by setting `bind_resource_key` argument to true (which is by default false). And set the `resource_key_name` and `role` parameters accordingly (which are by deafult empty) in variables.tf file.
107+
* To attach a key to cos instance, enbale it by setting `bind_resource_key` argument to true (which is by default false). And set the `resource_key_name` and `role` parameters accordingly (which are by deafult empty) in variables.tf file.

examples/bucket/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ module "cos_bucket" {
6161
force_delete = var.force_delete
6262
endpoint_type = var.endpoint_type
6363
activity_tracker_crn = local.crn_list[count.index]
64+
allowed_ip = var.allowed_ip
65+
kms_key_crn = var.kms_key_crn
6466
archive_rule = {
6567
rule_id = local.archive_rule_id
6668
enable = true

examples/bucket/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ variable "role" {
5050
default = ""
5151
}
5252

53+
variable "allowed_ip" {
54+
description = "A list of IPv4 or IPv6 addresses in CIDR notation that you want to allow access to your IBM Cloud Object Storage bucket"
55+
type = list(string)
56+
default = null
57+
}
58+
59+
variable "kms_key_crn" {
60+
description = "The CRN of the encryption root key that you want to use to encrypt data"
61+
type = string
62+
default = null
63+
}
5364

5465
variable "cos_instance_name" {
5566
description = "Enter Name of the cos instance with bucket to be attached"

examples/configure-bucket/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ module "cos_bucket" {
9191
| force\_delete | COS buckets need to be empty before they can be deleted | bool | `true` | no |
9292
| read\_data\_events | If set to true, all object write events will be sent to Activity Tracke/logdna | bool | `true` | no |
9393
| write\_data\_events | If set to true, all object write events will be sent to Activity Tracke/logdna | bool | `true` | no |
94-
94+
| allowed_ip | A list of IPs you want to allow access to your bucket. | list | n/a | no |
95+
| kms_key_crn | The CRN of the root key that you want to use to encrypt data | string | n/a | no |
9596

9697
## NOTE :
9798

9899
* If we want to make use of a particular version of module, then set the argument "version" to respective module version.
99100

100101
* Set the `archive_rule_enabled` argument to true only for regional cos bucket creation. For cross region and singleSite location set to false.
101102

102-
* To attach a key to cos instance, enbale it by setting `bind_resource_key` argument to true (which is by default false). And set the `resource_key_name` and `role` parameters accordingly (which are by deafult empty) in variables.tf file.
103+
* To attach a key to cos instance, enbale it by setting `bind_resource_key` argument to true (which is by default false). And set the `resource_key_name` and `role` parameters accordingly (which are by deafult empty) in variables.tf file.

examples/configure-bucket/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ module "cos_bucket" {
5050
force_delete = var.force_delete
5151
endpoint_type = var.endpoint_type
5252
activity_tracker_crn = ibm_resource_instance.at_instance.id
53+
allowed_ip = var.allowed_ip
54+
kms_key_crn = var.kms_key_crn
5355
archive_rule = {
5456
rule_id = local.archive_rule_id
5557
enable = true

examples/configure-bucket/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ variable "force_delete" {
5050
default = true
5151
}
5252

53+
variable "allowed_ip" {
54+
description = "A list of IPv4 or IPv6 addresses in CIDR notation that you want to allow access to your IBM Cloud Object Storage bucket"
55+
type = list(string)
56+
default = null
57+
}
58+
59+
variable "kms_key_crn" {
60+
description = "The CRN of the encryption root key that you want to use to encrypt data"
61+
type = string
62+
default = null
63+
}
64+
5365
variable "read_data_events" {
5466
description = "If set to true, all object read events will be sent to Activity Tracker/logdna"
5567
type = bool

examples/instance/output.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ output "cos_instance_id" {
88
value = module.cos.cos_instance_id
99
}
1010

11+
output "cos_instance_guid" {
12+
description = "The GUID of the cos instance"
13+
value = module.cos.cos_instance_guid
14+
}
15+
1116
output "cos_key_id" {
1217
description = "The ID of the key"
1318
value = concat(module.cos.*.cos_key_id, [""])[0]

modules/bucket/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,7 @@ module "cos_bucket" {
4545
| plan | The name of the plan type supported by service. | string | n/a | yes |
4646
| region | Target location or environment to create the resource instance. | string | n/a | yes |
4747
| resource\_group | Name of the resource group | string | n/a | yes |
48+
| allowed_ip | A list of IPs you want to allow access to your bucket. | string | list | n/a | no |
49+
| kms_key_crn | The CRN of the root key that you want to use to encrypt data | string | n/a | no |
4850

49-
## NOTE: If we want to make use of a particular version of module, then set the argument "version" to respective module version.
51+
## NOTE: If we want to make use of a particular version of module, then set the argument "version" to respective module version.

modules/bucket/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ resource "ibm_cos_bucket" "bucket" {
2121
storage_class = var.storage_class
2222
force_delete = (var.force_delete != null ? var.force_delete : true)
2323
endpoint_type = (var.endpoint_type != null ? var.endpoint_type : "public")
24+
allowed_ip = (var.allowed_ip != null ? var.allowed_ip : null)
25+
key_protect = (var.kms_key_crn != null ? var.kms_key_crn : null)
2426

2527
dynamic "activity_tracking" {
2628
for_each = var.activity_tracker_crn == "" ? [] : [1]
@@ -65,4 +67,4 @@ resource "ibm_cos_bucket" "bucket" {
6567

6668
}
6769
}
68-
}
70+
}

modules/bucket/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ variable "storage_class" {
2424
type = string
2525
}
2626

27+
variable "kms_key_crn" {
28+
description = "The CRN of the encryption root key that you want to use to encrypt data"
29+
type = string
30+
default = null
31+
}
32+
2733
variable "cos_instance_id" {
2834
description = "Cos instance id"
2935
type = string
@@ -34,6 +40,13 @@ variable "endpoint_type" {
3440
type = string
3541
default = null
3642
}
43+
44+
variable "allowed_ip" {
45+
description = "A list of IPv4 or IPv6 addresses in CIDR notation that you want to allow access to your IBM Cloud Object Storage bucket"
46+
type = list(string)
47+
default = null
48+
}
49+
3750
variable "force_delete" {
3851
description = "COS buckets need to be empty before they can be deleted. force_delete option empty the bucket and delete it"
3952
type = bool

0 commit comments

Comments
 (0)