diff --git a/README.md b/README.md index b8ff6ed41..8905b8acf 100644 --- a/README.md +++ b/README.md @@ -874,6 +874,7 @@ module "cluster_pattern" { | [ibm_container_vpc_cluster.cluster](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/container_vpc_cluster) | resource | | [ibm_container_vpc_worker_pool.pool](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/container_vpc_worker_pool) | resource | | [ibm_cos_bucket.buckets](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cos_bucket) | resource | +| [ibm_cos_bucket_lifecycle_configuration.cos_bucket_lifecycle](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cos_bucket_lifecycle_configuration) | resource | | [ibm_iam_authorization_policy.cos_bucket_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource | | [ibm_iam_authorization_policy.policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource | | [ibm_is_placement_group.placement_group](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_placement_group) | resource | @@ -897,6 +898,7 @@ module "cluster_pattern" { | [time_sleep.wait_30_seconds](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | | [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | | [time_sleep.wait_for_authorization_policy_buckets](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | +| [time_sleep.wait_for_cos_bucket_lifecycle](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | | [time_sleep.wait_for_vpc_creation_data](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | | [ibm_container_addons.existing_addons](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/container_addons) | data source | | [ibm_container_cluster_versions.cluster_versions](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/container_cluster_versions) | data source | @@ -914,7 +916,7 @@ module "cluster_pattern" { | [appid](#input\_appid) | The App ID instance to be used for the teleport vsi deployments |
object({
name = optional(string)
resource_group = optional(string)
use_data = optional(bool)
keys = optional(list(string))
use_appid = bool
})
|
{
"use_appid": false
}
| no | | [atracker](#input\_atracker) | atracker variables |
object({
resource_group = string
receive_global_events = bool
collector_bucket_name = string
add_route = bool
})
| n/a | yes | | [clusters](#input\_clusters) | A list describing clusters workloads to create |
list(
object({
name = string # Name of Cluster
vpc_name = string # Name of VPC
subnet_names = list(string) # List of vpc subnets for cluster
workers_per_subnet = number # Worker nodes per subnet.
machine_type = string # Worker node flavor
kube_type = string # iks or openshift
kube_version = optional(string) # Can be a version from `ibmcloud ks versions` or `default`
entitlement = optional(string) # entitlement option for openshift
secondary_storage = optional(string) # Secondary storage type
pod_subnet = optional(string) # Portable subnet for pods
service_subnet = optional(string) # Portable subnet for services
resource_group = string # Resource Group used for cluster
cos_name = optional(string) # Name of COS instance Required only for OpenShift clusters
access_tags = optional(list(string), [])
boot_volume_crk_name = optional(string) # Boot volume encryption key name
disable_public_endpoint = optional(bool, true) # disable cluster public, leaving only private endpoint
disable_outbound_traffic_protection = optional(bool, false) # public outbound access from the cluster workers
cluster_force_delete_storage = optional(bool, false) # force the removal of persistent storage associated with the cluster during cluster deletion
operating_system = string # The operating system of the workers in the default worker pool. See https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_versions#openshift_versions_available .
kms_wait_for_apply = optional(bool, true) # make terraform wait until KMS is applied to master and it is ready and deployed
verify_cluster_network_readiness = optional(bool, true) # Flag to run a script will run kubectl commands to verify that all worker nodes can communicate successfully with the master. If the runtime does not have access to the kube cluster to run kubectl commands, this should be set to false.
use_ibm_cloud_private_api_endpoints = optional(bool, true) # Flag to force all cluster related api calls to use the IBM Cloud private endpoints.
import_default_worker_pool_on_create = optional(bool) # (Advanced users) Whether to handle the default worker pool as a stand-alone ibm_container_vpc_worker_pool resource on cluster creation. Only set to false if you understand the implications of managing the default worker pool as part of the cluster resource. Set to true to import the default worker pool as a separate resource. Set to false to manage the default worker pool as part of the cluster resource.
allow_default_worker_pool_replacement = optional(bool) # (Advanced users) Set to true to allow the module to recreate a default worker pool. Only use in the case where you are getting an error indicating that the default worker pool cannot be replaced on apply. Once the default worker pool is handled as a stand-alone ibm_container_vpc_worker_pool, if you wish to make any change to the default worker pool which requires the re-creation of the default pool set this variable to true
labels = optional(map(string)) # A list of labels that you want to add to the default worker pool.
addons = optional(object({ # Map of OCP cluster add-on versions to install
debug-tool = optional(string)
image-key-synchronizer = optional(string)
openshift-data-foundation = optional(string)
vpc-file-csi-driver = optional(string)
static-route = optional(string)
cluster-autoscaler = optional(string)
vpc-block-csi-driver = optional(string)
ibm-storage-operator = optional(string)
}), {})
manage_all_addons = optional(bool, false) # Instructs Terraform to manage all cluster addons, even if addons were installed outside of the module. If set to 'true' this module will destroy any addons that were installed by other sources.
kms_config = optional(
object({
crk_name = string # Name of key
private_endpoint = optional(bool) # Private endpoint
})
)
worker_pools = optional(
list(
object({
name = string # Worker pool name
vpc_name = string # VPC name
workers_per_subnet = number # Worker nodes per subnet
flavor = string # Worker node flavor
subnet_names = list(string) # List of vpc subnets for worker pool
entitlement = optional(string) # entitlement option for openshift
secondary_storage = optional(string) # Secondary storage type
boot_volume_crk_name = optional(string) # Boot volume encryption key name
operating_system = string # The operating system of the workers in the worker pool. See https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_versions#openshift_versions_available .
labels = optional(map(string)) # A list of labels that you want to add to all the worker nodes in the worker pool.
})
)
)
})
)
| n/a | yes | -| [cos](#input\_cos) | Object describing the cloud object storage instance, buckets, and keys. Set `use_data` to false to create instance |
list(
object({
name = string
use_data = optional(bool)
resource_group = string
plan = optional(string)
random_suffix = optional(bool) # Use a random suffix for COS instance
access_tags = optional(list(string), [])
skip_kms_s2s_auth_policy = optional(bool, false) # skip auth policy between this instance and kms instance, useful if existing resources are used
skip_flowlogs_s2s_auth_policy = optional(bool, false) # skip auth policy between flow logs service and this instance, set to true if this policy is already in place on account
skip_atracker_s2s_auth_policy = optional(bool, false) # skip auth policyt between atracker service and this instance, set to true if this is existing recipient of atracker already
buckets = list(object({
name = string
storage_class = string
endpoint_type = string
force_delete = bool
single_site_location = optional(string)
region_location = optional(string)
cross_region_location = optional(string)
kms_key = optional(string)
access_tags = optional(list(string), [])
allowed_ip = optional(list(string), [])
hard_quota = optional(number)
archive_rule = optional(object({
days = number
enable = bool
rule_id = optional(string)
type = string
}))
expire_rule = optional(object({
days = optional(number)
date = optional(string)
enable = bool
expired_object_delete_marker = optional(string)
prefix = optional(string)
rule_id = optional(string)
}))
activity_tracking = optional(object({
activity_tracker_crn = string
read_data_events = bool
write_data_events = bool
management_events = bool
}))
metrics_monitoring = optional(object({
metrics_monitoring_crn = string
request_metrics_enabled = optional(bool)
usage_metrics_enabled = optional(bool)
}))
}))
keys = optional(
list(object({
name = string
role = string
enable_HMAC = bool
}))
)

})
)
| n/a | yes | +| [cos](#input\_cos) | Object describing the cloud object storage instance, buckets, and keys. Set `use_data` to false to create instance |
list(
object({
name = string
use_data = optional(bool)
resource_group = string
plan = optional(string)
random_suffix = optional(bool) # Use a random suffix for COS instance
access_tags = optional(list(string), [])
skip_kms_s2s_auth_policy = optional(bool, false) # skip auth policy between this instance and kms instance, useful if existing resources are used
skip_flowlogs_s2s_auth_policy = optional(bool, false) # skip auth policy between flow logs service and this instance, set to true if this policy is already in place on account
skip_atracker_s2s_auth_policy = optional(bool, false) # skip auth policyt between atracker service and this instance, set to true if this is existing recipient of atracker already
buckets = list(object({
name = string
storage_class = string
endpoint_type = string
force_delete = bool
single_site_location = optional(string)
region_location = optional(string)
cross_region_location = optional(string)
kms_key = optional(string)
access_tags = optional(list(string), [])
allowed_ip = optional(list(string), [])
hard_quota = optional(number)
archive_rule = optional(object({
days = number
archive_filter_prefix = optional(string)
enable = bool
rule_id = optional(string)
type = string
}))
expire_rule = optional(object({
days = optional(number)
expire_filter_prefix = optional(string)
date = optional(string)
enable = bool
expired_object_delete_marker = optional(string)
prefix = optional(string)
rule_id = optional(string)
}))
activity_tracking = optional(object({
activity_tracker_crn = string
read_data_events = bool
write_data_events = bool
management_events = bool
}))
metrics_monitoring = optional(object({
metrics_monitoring_crn = string
request_metrics_enabled = optional(bool)
usage_metrics_enabled = optional(bool)
}))
}))
keys = optional(
list(object({
name = string
role = string
enable_HMAC = bool
}))
)

})
)
| n/a | yes | | [enable\_transit\_gateway](#input\_enable\_transit\_gateway) | Create transit gateway | `bool` | `true` | no | | [existing\_vpc\_cbr\_zone\_id](#input\_existing\_vpc\_cbr\_zone\_id) | ID of the existing CBR (Context-based restrictions) network zone, with context set to the VPC. This zone is used in a CBR rule, which allows traffic to flow only from the landing zone VPCs to specific cloud services. | `string` | `null` | no | | [f5\_template\_data](#input\_f5\_template\_data) | Data for all f5 templates |
object({
tmos_admin_password = optional(string)
license_type = optional(string)
byol_license_basekey = optional(string)
license_host = optional(string)
license_username = optional(string)
license_password = optional(string)
license_pool = optional(string)
license_sku_keyword_1 = optional(string)
license_sku_keyword_2 = optional(string)
license_unit_of_measure = optional(string)
do_declaration_url = optional(string)
as3_declaration_url = optional(string)
ts_declaration_url = optional(string)
phone_home_url = optional(string)
template_source = optional(string)
template_version = optional(string)
app_id = optional(string)
tgactive_url = optional(string)
tgstandby_url = optional(string)
tgrefresh_url = optional(string)
})
|
{
"license_type": "none"
}
| no | diff --git a/common-dev-assets b/common-dev-assets index a82b82a51..151f5e7fb 160000 --- a/common-dev-assets +++ b/common-dev-assets @@ -1 +1 @@ -Subproject commit a82b82a515e442958a736cae705b72891d6a60f4 +Subproject commit 151f5e7fb5a775ed3bea62d9ba5b326cd5fbdc80 diff --git a/cos.tf b/cos.tf index cabd4dc0b..aff1fdd2d 100644 --- a/cos.tf +++ b/cos.tf @@ -98,38 +98,6 @@ resource "ibm_cos_bucket" "buckets" { key.crn if key.name == each.value.kms_key ][0] - dynamic "expire_rule" { - for_each = ( - each.value.expire_rule == null - ? [] - : [each.value.expire_rule] - ) - - content { - days = expire_rule.value.days - date = expire_rule.value.date - enable = expire_rule.value.enable - expired_object_delete_marker = expire_rule.value.expired_object_delete_marker - prefix = expire_rule.value.prefix - rule_id = expire_rule.value.rule_id - } - } - - dynamic "archive_rule" { - for_each = ( - each.value.archive_rule == null - ? [] - : [each.value.archive_rule] - ) - - content { - days = archive_rule.value.days - enable = archive_rule.value.enable - rule_id = archive_rule.value.rule_id - type = archive_rule.value.type - } - } - dynamic "activity_tracking" { for_each = ( each.value.activity_tracking == null @@ -160,6 +128,69 @@ resource "ibm_cos_bucket" "buckets" { } } +resource "time_sleep" "wait_for_cos_bucket_lifecycle" { + count = length(local.buckets_map) > 0 ? 1 : 0 + + # workaround for https://github.com/IBM-Cloud/terraform-provider-ibm/issues/5778 + create_duration = "90s" +} + +resource "ibm_cos_bucket_lifecycle_configuration" "cos_bucket_lifecycle" { + for_each = { + for key, value in local.buckets_map : + key => value if( + value.expire_rule != null || value.archive_rule != null + ) + } + + depends_on = [time_sleep.wait_for_cos_bucket_lifecycle] + + bucket_crn = ibm_cos_bucket.buckets[each.key].crn + bucket_location = compact([var.region, each.value.cross_region_location, each.value.single_site_location])[0] + + dynamic "lifecycle_rule" { + ## This for_each block is NOT a loop to attach to multiple expiration blocks. + ## This block is only used to conditionally add expiration block depending on expire rule is enabled. + for_each = ( + each.value.expire_rule == null + ? [] + : [each.value.expire_rule] + ) + content { + expiration { + days = expire_rule.value.days + } + filter { + prefix = expire_rule.value.expire_filter_prefix != null ? expire_rule.value.expire_filter_prefix : "" + } + rule_id = "expiry-rule" + status = "enable" + } + } + dynamic "lifecycle_rule" { + ## This for_each block is NOT a loop to attach to multiple transition blocks. + ## This block is only used to conditionally add retention block depending on archive rule is enabled. + for_each = ( + each.value.archive_rule == null + ? [] + : [each.value.archive_rule] + ) + content { + transition { + days = archive_rule.value.days + ## The new values changed from Capatalized to all Upper case, avoid having to change values in new release + storage_class = upper(each.value.archive_type) + + } + filter { + prefix = archive_rule.value.archive_filter_prefix != null ? archive_rule.value.archive_filter_prefix : "" + } + rule_id = "archive-rule" + status = "enable" + } + } +} + resource "ibm_resource_tag" "bucket_tag" { for_each = local.buckets_map resource_id = ibm_cos_bucket.buckets[each.key].crn diff --git a/tests/pr_test.go b/tests/pr_test.go index 19c480ea6..6881f534f 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -32,7 +32,7 @@ const overrideExampleTerraformDir = "examples/override-example" const resourceGroup = "geretain-test-resources" const yamlLocation = "../common-dev-assets/common-go-assets/common-permanent-resources.yaml" -// Setting "add_atracker_route" to false for VPC and VSI tests to avoid hitting AT route quota, right now its 4 routes per account. +// Setting "add_atracker_route" to false for VPC and VSI tests to avoid hitting AT route quota, right now its 4 routes per account const add_atracker_route = false const user_data = `{ @@ -421,7 +421,7 @@ func setupOptionsSchematics(t *testing.T, prefix string, dir string) *testschema Prefix: prefix, Tags: []string{"test-schematic"}, DeleteWorkspaceOnFail: false, - WaitJobCompleteMinutes: 90, + WaitJobCompleteMinutes: 120, CloudInfoService: sharedInfoSvc, }) diff --git a/variables.tf b/variables.tf index 090f720f0..4e29edb55 100644 --- a/variables.tf +++ b/variables.tf @@ -540,13 +540,15 @@ variable "cos" { allowed_ip = optional(list(string), []) hard_quota = optional(number) archive_rule = optional(object({ - days = number - enable = bool - rule_id = optional(string) - type = string + days = number + archive_filter_prefix = optional(string) + enable = bool + rule_id = optional(string) + type = string })) expire_rule = optional(object({ days = optional(number) + expire_filter_prefix = optional(string) date = optional(string) enable = bool expired_object_delete_marker = optional(string)