Skip to content

Commit 2782340

Browse files
tjy9206q2w
andauthored
fix: Fix apphub uri and id representation (#360)
Co-authored-by: abhishek kumar tiwari <[email protected]>
1 parent 31add8f commit 2782340

File tree

6 files changed

+41
-18
lines changed

6 files changed

+41
-18
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Functional examples are included in the
9292

9393
| Name | Description |
9494
|------|-------------|
95-
| apphub\_service\_uri | Service URI in CAIS style to be used by Apphub. |
95+
| apphub\_service\_uri | URI in CAIS style to be used by Apphub. |
9696
| bucket | Bucket resource (for single use). |
9797
| buckets | Bucket resources as list. |
9898
| buckets\_map | Bucket resources by name. |

metadata.yaml

+5-8
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,12 @@ spec:
240240
defaultValue: {}
241241
outputs:
242242
- name: apphub_service_uri
243-
description: Service URI in CAIS style to be used by Apphub.
243+
description: URI in CAIS style to be used by Apphub.
244244
type:
245-
- object
246-
- service_id:
247-
- tuple
248-
- - string
249-
service_uri:
250-
- tuple
251-
- - string
245+
- tuple
246+
- - - object
247+
- service_id: string
248+
service_uri: string
252249
- name: bucket
253250
description: Bucket resource (for single use).
254251
type:

modules/simple_bucket/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Functional examples are included in the
6464

6565
| Name | Description |
6666
|------|-------------|
67+
| apphub\_service\_uri | URI in CAIS style to be used by Apphub. |
6768
| bucket | The created storage bucket |
6869
| internal\_kms\_configuration | The intenal KMS Resource. |
6970
| name | Bucket name. |

modules/simple_bucket/metadata.yaml

+21-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ spec:
4747
varType: string
4848
required: true
4949
- name: location
50-
description: The location of the bucket.
50+
description: The location of the bucket. See https://cloud.google.com/storage/docs/locations.
5151
varType: string
5252
required: true
5353
- name: storage_class
@@ -109,7 +109,7 @@ spec:
109109
varType: any
110110
defaultValue: []
111111
- name: encryption
112-
description: A Cloud KMS key that will be used to encrypt objects inserted into this bucket. If default_kms_key_name is set to 'null' a new keyring and key pair will be created and used to encrypt bucket using CMEK.
112+
description: A Cloud KMS key that will be used to encrypt objects inserted into this bucket. To use a Cloud KMS key automatically created by the module use `internal_encryption_config`.
113113
varType: |-
114114
object({
115115
default_kms_key_name = string
@@ -155,7 +155,23 @@ spec:
155155
retention_duration_seconds = optional(number)
156156
})
157157
defaultValue: {}
158+
- name: internal_encryption_config
159+
description: " Configuration for the creation of an internal Google Cloud Key Management Service (KMS) Key for use as Customer-managed encryption key (CMEK) for the GCS Bucket\n instead of creating one in advance and providing the key in the variable `encryption.default_kms_key_name`.\n create_encryption_key: If `true` a Google Cloud Key Management Service (KMS) KeyRing and a Key will be created\n prevent_destroy: Set the prevent_destroy lifecycle attribute on keys.\n key_destroy_scheduled_duration: Set the period of time that versions of keys spend in the `DESTROY_SCHEDULED` state before transitioning to `DESTROYED`.\n key_rotation_period: Generate a new key every time this period passes.\n"
160+
varType: |-
161+
object({
162+
create_encryption_key = optional(bool, false)
163+
prevent_destroy = optional(bool, false)
164+
key_destroy_scheduled_duration = optional(string, null)
165+
key_rotation_period = optional(string, "7776000s")
166+
})
167+
defaultValue: {}
158168
outputs:
169+
- name: apphub_service_uri
170+
description: URI in CAIS style to be used by Apphub.
171+
type:
172+
- object
173+
- service_id: string
174+
service_uri: string
159175
- name: bucket
160176
description: The created storage bucket
161177
type:
@@ -223,6 +239,7 @@ spec:
223239
matches_suffix:
224240
- list
225241
- string
242+
no_age: bool
226243
noncurrent_time_before: string
227244
num_newer_versions: number
228245
send_age_if_zero: bool
@@ -273,6 +290,8 @@ spec:
273290
- - object
274291
- main_page_suffix: string
275292
not_found_page: string
293+
- name: internal_kms_configuration
294+
description: The intenal KMS Resource.
276295
- name: name
277296
description: Bucket name.
278297
type: string
@@ -296,5 +315,3 @@ spec:
296315
providerVersions:
297316
- source: hashicorp/google
298317
version: ">= 5.43.0, < 7"
299-
- source: hashicorp/random
300-
version: ">= 2.1"

modules/simple_bucket/outputs.tf

+8
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ output "internal_kms_configuration" {
3333
description = "The intenal KMS Resource."
3434
value = var.internal_encryption_config.create_encryption_key ? module.encryption_key[0] : null
3535
}
36+
37+
output "apphub_service_uri" {
38+
value = {
39+
service_uri = "//storage.googleapis.com/${google_storage_bucket.bucket.name}"
40+
service_id = substr(google_storage_bucket.bucket.name, 0, 63)
41+
}
42+
description = "URI in CAIS style to be used by Apphub."
43+
}

outputs.tf

+5-5
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ output "hmac_keys" {
7070
}
7171

7272
output "apphub_service_uri" {
73-
value = {
74-
service_uri = local.buckets_list[*].self_link
75-
service_id = local.buckets_list[*].name
76-
}
77-
description = "Service URI in CAIS style to be used by Apphub."
73+
value = [for bucket in local.buckets_list : {
74+
service_uri = "//storage.googleapis.com/${bucket.name}"
75+
service_id = substr(bucket.name, 0, 63)
76+
}]
77+
description = "URI in CAIS style to be used by Apphub."
7878
}

0 commit comments

Comments
 (0)