Skip to content

Commit

Permalink
fix: Fix apphub uri and id representation (#360)
Browse files Browse the repository at this point in the history
Co-authored-by: abhishek kumar tiwari <[email protected]>
  • Loading branch information
tjy9206 and q2w authored Oct 28, 2024
1 parent 31add8f commit 2782340
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Functional examples are included in the

| Name | Description |
|------|-------------|
| apphub\_service\_uri | Service URI in CAIS style to be used by Apphub. |
| apphub\_service\_uri | URI in CAIS style to be used by Apphub. |
| bucket | Bucket resource (for single use). |
| buckets | Bucket resources as list. |
| buckets\_map | Bucket resources by name. |
Expand Down
13 changes: 5 additions & 8 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,12 @@ spec:
defaultValue: {}
outputs:
- name: apphub_service_uri
description: Service URI in CAIS style to be used by Apphub.
description: URI in CAIS style to be used by Apphub.
type:
- object
- service_id:
- tuple
- - string
service_uri:
- tuple
- - string
- tuple
- - - object
- service_id: string
service_uri: string
- name: bucket
description: Bucket resource (for single use).
type:
Expand Down
1 change: 1 addition & 0 deletions modules/simple_bucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Functional examples are included in the

| Name | Description |
|------|-------------|
| apphub\_service\_uri | URI in CAIS style to be used by Apphub. |
| bucket | The created storage bucket |
| internal\_kms\_configuration | The intenal KMS Resource. |
| name | Bucket name. |
Expand Down
25 changes: 21 additions & 4 deletions modules/simple_bucket/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ spec:
varType: string
required: true
- name: location
description: The location of the bucket.
description: The location of the bucket. See https://cloud.google.com/storage/docs/locations.
varType: string
required: true
- name: storage_class
Expand Down Expand Up @@ -109,7 +109,7 @@ spec:
varType: any
defaultValue: []
- name: encryption
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.
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`.
varType: |-
object({
default_kms_key_name = string
Expand Down Expand Up @@ -155,7 +155,23 @@ spec:
retention_duration_seconds = optional(number)
})
defaultValue: {}
- name: internal_encryption_config
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"
varType: |-
object({
create_encryption_key = optional(bool, false)
prevent_destroy = optional(bool, false)
key_destroy_scheduled_duration = optional(string, null)
key_rotation_period = optional(string, "7776000s")
})
defaultValue: {}
outputs:
- name: apphub_service_uri
description: URI in CAIS style to be used by Apphub.
type:
- object
- service_id: string
service_uri: string
- name: bucket
description: The created storage bucket
type:
Expand Down Expand Up @@ -223,6 +239,7 @@ spec:
matches_suffix:
- list
- string
no_age: bool
noncurrent_time_before: string
num_newer_versions: number
send_age_if_zero: bool
Expand Down Expand Up @@ -273,6 +290,8 @@ spec:
- - object
- main_page_suffix: string
not_found_page: string
- name: internal_kms_configuration
description: The intenal KMS Resource.
- name: name
description: Bucket name.
type: string
Expand All @@ -296,5 +315,3 @@ spec:
providerVersions:
- source: hashicorp/google
version: ">= 5.43.0, < 7"
- source: hashicorp/random
version: ">= 2.1"
8 changes: 8 additions & 0 deletions modules/simple_bucket/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ output "internal_kms_configuration" {
description = "The intenal KMS Resource."
value = var.internal_encryption_config.create_encryption_key ? module.encryption_key[0] : null
}

output "apphub_service_uri" {
value = {
service_uri = "//storage.googleapis.com/${google_storage_bucket.bucket.name}"
service_id = substr(google_storage_bucket.bucket.name, 0, 63)
}
description = "URI in CAIS style to be used by Apphub."
}
10 changes: 5 additions & 5 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ output "hmac_keys" {
}

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

0 comments on commit 2782340

Please sign in to comment.