Skip to content

Commit

Permalink
feat: added new outputs bucket_region, cos_instance_name and `cos…
Browse files Browse the repository at this point in the history
…_instance_crn` (#540)
  • Loading branch information
rajatagarwal-ibm authored Feb 26, 2024
1 parent d51031f commit c6d7455
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,13 @@ You need the following permissions to run this module.
| <a name="output_bucket_crn"></a> [bucket\_crn](#output\_bucket\_crn) | Bucket CRN |
| <a name="output_bucket_id"></a> [bucket\_id](#output\_bucket\_id) | Bucket id |
| <a name="output_bucket_name"></a> [bucket\_name](#output\_bucket\_name) | Bucket name |
| <a name="output_bucket_region"></a> [bucket\_region](#output\_bucket\_region) | Bucket region if you create a regional bucket |
| <a name="output_bucket_storage_class"></a> [bucket\_storage\_class](#output\_bucket\_storage\_class) | Bucket Storage Class |
| <a name="output_cbr_rule_ids"></a> [cbr\_rule\_ids](#output\_cbr\_rule\_ids) | List of all rule ids |
| <a name="output_cos_instance_guid"></a> [cos\_instance\_guid](#output\_cos\_instance\_guid) | The GUID of the Cloud Object Storage Instance where the buckets are created |
| <a name="output_cos_instance_id"></a> [cos\_instance\_id](#output\_cos\_instance\_id) | The ID of the Cloud Object Storage Instance where the buckets are created |
| <a name="output_cos_instance_crn"></a> [cos\_instance\_crn](#output\_cos\_instance\_crn) | The CRN of the Cloud Object Storage instance |
| <a name="output_cos_instance_guid"></a> [cos\_instance\_guid](#output\_cos\_instance\_guid) | The GUID of the Cloud Object Storage instance |
| <a name="output_cos_instance_id"></a> [cos\_instance\_id](#output\_cos\_instance\_id) | The ID of the Cloud Object Storage instance |
| <a name="output_cos_instance_name"></a> [cos\_instance\_name](#output\_cos\_instance\_name) | The name of the Cloud Object Storage instance |
| <a name="output_instance_cbr_rules"></a> [instance\_cbr\_rules](#output\_instance\_cbr\_rules) | COS instance rules |
| <a name="output_kms_key_crn"></a> [kms\_key\_crn](#output\_kms\_key\_crn) | The CRN of the KMS key used to encrypt the COS bucket |
| <a name="output_resource_group_id"></a> [resource\_group\_id](#output\_resource\_group\_id) | Resource Group ID |
Expand Down
5 changes: 5 additions & 0 deletions examples/fscloud/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ output "cos_instance_guid" {
value = module.cos_fscloud.cos_instance_guid
}

output "cos_instance_crn" {
description = "COS instance crn"
value = module.cos_fscloud.cos_instance_crn
}

output "bucket_cbr_rules" {
description = "COS bucket rules"
value = module.cos_fscloud.bucket_cbr_rules
Expand Down
3 changes: 3 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ resource "ibm_resource_key" "resource_key" {
locals {
cos_instance_id = var.create_cos_instance ? ibm_resource_instance.cos_instance[0].id : var.existing_cos_instance_id
cos_instance_guid = var.create_cos_instance ? ibm_resource_instance.cos_instance[0].guid : element(split(":", var.existing_cos_instance_id), length(split(":", var.existing_cos_instance_id)) - 3)
cos_instance_name = var.create_cos_instance ? ibm_resource_instance.cos_instance[0].name : null
cos_instance_crn = var.create_cos_instance ? ibm_resource_instance.cos_instance[0].crn : null
create_access_policy_kms = var.kms_encryption_enabled && var.create_cos_bucket && !var.skip_iam_authorization_policy
kms_service = local.create_access_policy_kms ? (
can(regex(".*kms.*", var.kms_key_crn)) ? "kms" : (
Expand Down Expand Up @@ -277,6 +279,7 @@ resource "ibm_cos_bucket" "cos_bucket1" {
locals {
bucket_crn = var.create_cos_bucket ? (var.kms_encryption_enabled ? ibm_cos_bucket.cos_bucket[0].crn : ibm_cos_bucket.cos_bucket1[0].crn) : null
bucket_id = var.create_cos_bucket ? (var.kms_encryption_enabled ? ibm_cos_bucket.cos_bucket[0].id : ibm_cos_bucket.cos_bucket1[0].id) : null
bucket_region = var.create_cos_bucket ? (var.kms_encryption_enabled ? ibm_cos_bucket.cos_bucket[0].region_location : ibm_cos_bucket.cos_bucket1[0].region_location) : null
bucket_name = var.create_cos_bucket ? (var.kms_encryption_enabled ? ibm_cos_bucket.cos_bucket[0].bucket_name : ibm_cos_bucket.cos_bucket1[0].bucket_name) : null
bucket_storage_class = var.create_cos_bucket ? (var.kms_encryption_enabled ? ibm_cos_bucket.cos_bucket[0].storage_class : ibm_cos_bucket.cos_bucket1[0].storage_class) : null
s3_endpoint_public = var.create_cos_bucket ? (var.kms_encryption_enabled ? ibm_cos_bucket.cos_bucket[0].s3_endpoint_public : ibm_cos_bucket.cos_bucket1[0].s3_endpoint_public) : null
Expand Down
2 changes: 2 additions & 0 deletions modules/fscloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ No resources.
| <a name="output_bucket_cbr_rules"></a> [bucket\_cbr\_rules](#output\_bucket\_cbr\_rules) | COS bucket rules |
| <a name="output_buckets"></a> [buckets](#output\_buckets) | List of buckets created |
| <a name="output_cbr_rule_ids"></a> [cbr\_rule\_ids](#output\_cbr\_rule\_ids) | List of all rule ids |
| <a name="output_cos_instance_crn"></a> [cos\_instance\_crn](#output\_cos\_instance\_crn) | COS instance crn |
| <a name="output_cos_instance_guid"></a> [cos\_instance\_guid](#output\_cos\_instance\_guid) | COS instance guid |
| <a name="output_cos_instance_id"></a> [cos\_instance\_id](#output\_cos\_instance\_id) | COS instance id |
| <a name="output_cos_instance_name"></a> [cos\_instance\_name](#output\_cos\_instance\_name) | COS instance name |
| <a name="output_instance_cbr_rules"></a> [instance\_cbr\_rules](#output\_instance\_cbr\_rules) | COS instance rules |
| <a name="output_resource_group_id"></a> [resource\_group\_id](#output\_resource\_group\_id) | Resource Group ID |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
10 changes: 10 additions & 0 deletions modules/fscloud/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ output "cos_instance_guid" {
value = module.cos_instance.cos_instance_guid
}

output "cos_instance_name" {
description = "COS instance name"
value = module.cos_instance.cos_instance_name
}

output "cos_instance_crn" {
description = "COS instance crn"
value = module.cos_instance.cos_instance_crn
}

output "bucket_cbr_rules" {
description = "COS bucket rules"
value = module.buckets.cbr_rules
Expand Down
19 changes: 17 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,36 @@ output "bucket_storage_class" {
value = local.bucket_storage_class
}

output "bucket_region" {
description = "Bucket region if you create a regional bucket"
value = local.bucket_region
}

output "kms_key_crn" {
description = "The CRN of the KMS key used to encrypt the COS bucket"
value = var.kms_key_crn
}

output "cos_instance_id" {
description = "The ID of the Cloud Object Storage Instance where the buckets are created"
description = "The ID of the Cloud Object Storage instance"
value = local.cos_instance_id
}

output "cos_instance_guid" {
description = "The GUID of the Cloud Object Storage Instance where the buckets are created"
description = "The GUID of the Cloud Object Storage instance"
value = local.cos_instance_guid
}

output "cos_instance_name" {
description = "The name of the Cloud Object Storage instance"
value = local.cos_instance_name
}

output "cos_instance_crn" {
description = "The CRN of the Cloud Object Storage instance"
value = local.cos_instance_crn
}

output "bucket_cbr_rules" {
description = "COS bucket rules"
value = module.bucket_cbr_rule
Expand Down
2 changes: 1 addition & 1 deletion tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestRunFSCloudExample(t *testing.T) {
logger.Log(t, fmt.Sprintf("Waiting %.f minutes for CBRs to be picked up...", delayMinutes))
time.Sleep(delayDuration)

expectedOutputs := []string{"cos_instance_id", "cos_instance_guid", "buckets", "bucket_cbr_rules", "instance_cbr_rules"}
expectedOutputs := []string{"cos_instance_id", "cos_instance_guid", "cos_instance_crn", "buckets", "bucket_cbr_rules", "instance_cbr_rules"}
_, tfOutputsErr := testhelper.ValidateTerraformOutputs(outputs, expectedOutputs...)
if assert.Nil(t, tfOutputsErr, tfOutputsErr) {
// Retrieve the API key from the environment variable
Expand Down

0 comments on commit c6d7455

Please sign in to comment.