From d1f690e62c08d55a8c87c5f9f4498805cb095ce5 Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Sat, 6 Nov 2021 10:22:52 -0400 Subject: [PATCH] feat: add new attribute reference `zookeeper_connect_string_tls` and variable to configure timeout settings (#1) --- README.md | 8 +++++--- examples/basic/README.md | 3 ++- examples/basic/outputs.tf | 5 +++++ examples/basic/versions.tf | 2 +- examples/complete/README.md | 5 +++-- examples/complete/outputs.tf | 5 +++++ examples/complete/versions.tf | 2 +- main.tf | 6 ++++++ outputs.tf | 37 ++++++++++++++++++++--------------- variables.tf | 8 +++++++- versions.tf | 2 +- 11 files changed, 57 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index abec48f..6d2da14 100644 --- a/README.md +++ b/README.md @@ -132,13 +132,13 @@ Security scanning results provided by Bridgecrew. Bridgecrew is the leading full | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.43 | +| [aws](#requirement\_aws) | >= 3.60 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.43 | +| [aws](#provider\_aws) | >= 3.60 | ## Modules @@ -187,7 +187,7 @@ No modules. | [firehose\_logs\_enabled](#input\_firehose\_logs\_enabled) | Indicates whether you want to enable or disable streaming broker logs to Kinesis Data Firehose | `bool` | `false` | no | | [jmx\_exporter\_enabled](#input\_jmx\_exporter\_enabled) | Indicates whether you want to enable or disable the JMX Exporter | `bool` | `false` | no | | [kafka\_version](#input\_kafka\_version) | Specify the desired Kafka software version | `string` | `null` | no | -| [name](#input\_name) | Name of the MSK cluster | `string` | `""` | no | +| [name](#input\_name) | Name of the MSK cluster | `string` | `"msk"` | no | | [node\_exporter\_enabled](#input\_node\_exporter\_enabled) | Indicates whether you want to enable or disable the Node Exporter | `bool` | `false` | no | | [number\_of\_broker\_nodes](#input\_number\_of\_broker\_nodes) | The desired total number of broker nodes in the kafka cluster. It must be a multiple of the number of specified client subnets | `number` | `null` | no | | [s3\_logs\_bucket](#input\_s3\_logs\_bucket) | Name of the S3 bucket to deliver logs to | `string` | `null` | no | @@ -200,6 +200,7 @@ No modules. | [schemas](#input\_schemas) | A map schemas to be created within the schema registry | `map(any)` | `{}` | no | | [scram\_secret\_association\_secret\_arn\_list](#input\_scram\_secret\_association\_secret\_arn\_list) | List of AWS Secrets Manager secret ARNs to associate with SCRAM | `list(string)` | `[]` | no | | [tags](#input\_tags) | A map of tags to assign to the resources created | `map(string)` | `{}` | no | +| [timeouts](#input\_timeouts) | Create, update, and delete timeout configurations for the cluster | `map(string)` | `{}` | no | ## Outputs @@ -218,6 +219,7 @@ No modules. | [schemas](#output\_schemas) | A map of output attributes for the schemas created | | [scram\_secret\_association\_id](#output\_scram\_secret\_association\_id) | Amazon Resource Name (ARN) of the MSK cluster | | [zookeeper\_connect\_string](#output\_zookeeper\_connect\_string) | A comma separated list of one or more hostname:port pairs to use to connect to the Apache Zookeeper cluster. The returned values are sorted alphbetically | +| [zookeeper\_connect\_string\_tls](#output\_zookeeper\_connect\_string\_tls) | A comma separated list of one or more hostname:port pairs to use to connect to the Apache Zookeeper cluster via TLS. The returned values are sorted alphbetically | ## License diff --git a/examples/basic/README.md b/examples/basic/README.md index 9041353..ab63805 100644 --- a/examples/basic/README.md +++ b/examples/basic/README.md @@ -23,7 +23,7 @@ Note that this example may create resources which will incur monetary charges on | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.43 | +| [aws](#requirement\_aws) | >= 3.60 | ## Providers @@ -61,6 +61,7 @@ No inputs. | [current\_version](#output\_current\_version) | Current version of the MSK Cluster used for updates, e.g. `K13V1IB3VIYZZH` | | [scram\_secret\_association\_id](#output\_scram\_secret\_association\_id) | Amazon Resource Name (ARN) of the MSK cluster | | [zookeeper\_connect\_string](#output\_zookeeper\_connect\_string) | A comma separated list of one or more hostname:port pairs to use to connect to the Apache Zookeeper cluster. The returned values are sorted alphbetically | +| [zookeeper\_connect\_string\_tls](#output\_zookeeper\_connect\_string\_tls) | A comma separated list of one or more hostname:port pairs to use to connect to the Apache Zookeeper cluster via TLS. The returned values are sorted alphbetically | Apache-2.0 Licensed. See [LICENSE](../../LICENSE). diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf index 6487f6e..bb70125 100644 --- a/examples/basic/outputs.tf +++ b/examples/basic/outputs.tf @@ -43,6 +43,11 @@ output "zookeeper_connect_string" { value = module.msk_cluster.zookeeper_connect_string } +output "zookeeper_connect_string_tls" { + description = "A comma separated list of one or more hostname:port pairs to use to connect to the Apache Zookeeper cluster via TLS. The returned values are sorted alphbetically" + value = module.msk_cluster.zookeeper_connect_string_tls +} + # Configuration output "configuration_arn" { description = "Amazon Resource Name (ARN) of the configuration" diff --git a/examples/basic/versions.tf b/examples/basic/versions.tf index 94347e4..3b3f4fc 100644 --- a/examples/basic/versions.tf +++ b/examples/basic/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.43" + version = ">= 3.60" } } } diff --git a/examples/complete/README.md b/examples/complete/README.md index 2fa3bd6..09277c7 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -22,13 +22,13 @@ Note that this example may create resources which will incur monetary charges on | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.43 | +| [aws](#requirement\_aws) | >= 3.60 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.43 | +| [aws](#provider\_aws) | >= 3.60 | | [random](#provider\_random) | n/a | ## Modules @@ -71,6 +71,7 @@ No inputs. | [current\_version](#output\_current\_version) | Current version of the MSK Cluster used for updates, e.g. `K13V1IB3VIYZZH` | | [scram\_secret\_association\_id](#output\_scram\_secret\_association\_id) | Amazon Resource Name (ARN) of the MSK cluster | | [zookeeper\_connect\_string](#output\_zookeeper\_connect\_string) | A comma separated list of one or more hostname:port pairs to use to connect to the Apache Zookeeper cluster. The returned values are sorted alphbetically | +| [zookeeper\_connect\_string\_tls](#output\_zookeeper\_connect\_string\_tls) | A comma separated list of one or more hostname:port pairs to use to connect to the Apache Zookeeper cluster via TLS. The returned values are sorted alphbetically | Apache-2.0 Licensed. See [LICENSE](../../LICENSE). diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf index 6487f6e..bb70125 100644 --- a/examples/complete/outputs.tf +++ b/examples/complete/outputs.tf @@ -43,6 +43,11 @@ output "zookeeper_connect_string" { value = module.msk_cluster.zookeeper_connect_string } +output "zookeeper_connect_string_tls" { + description = "A comma separated list of one or more hostname:port pairs to use to connect to the Apache Zookeeper cluster via TLS. The returned values are sorted alphbetically" + value = module.msk_cluster.zookeeper_connect_string_tls +} + # Configuration output "configuration_arn" { description = "Amazon Resource Name (ARN) of the configuration" diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 94347e4..3b3f4fc 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.43" + version = ">= 3.60" } } } diff --git a/main.tf b/main.tf index 7d63906..2d0c4c3 100644 --- a/main.tf +++ b/main.tf @@ -86,6 +86,12 @@ resource "aws_msk_cluster" "this" { } } + timeouts { + create = lookup(var.timeouts, "create", null) + update = lookup(var.timeouts, "update", null) + delete = lookup(var.timeouts, "delete", null) + } + # required for appautoscaling lifecycle { ignore_changes = [broker_node_group_info[0].ebs_volume_size] diff --git a/outputs.tf b/outputs.tf index cb89790..e07d226 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,64 +1,69 @@ # Cluster output "arn" { description = "Amazon Resource Name (ARN) of the MSK cluster" - value = element(concat(aws_msk_cluster.this[*].arn, [""]), 0) + value = try(aws_msk_cluster.this[0].arn, "") } output "bootstrap_brokers" { description = "Comma separated list of one or more hostname:port pairs of kafka brokers suitable to bootstrap connectivity to the kafka cluster" - value = element(concat(compact([ - element(concat(aws_msk_cluster.this[*].bootstrap_brokers, [""]), 0), - element(concat(aws_msk_cluster.this[*].bootstrap_brokers_sasl_iam, [""]), 0), - element(concat(aws_msk_cluster.this[*].bootstrap_brokers_sasl_scram, [""]), 0), - element(concat(aws_msk_cluster.this[*].bootstrap_brokers_tls, [""]), 0), - ]), [""]), 0) + value = compact([ + try(aws_msk_cluster.this[0].bootstrap_brokers, ""), + try(aws_msk_cluster.this[0].bootstrap_brokers_sasl_iam, ""), + try(aws_msk_cluster.this[0].bootstrap_brokers_sasl_scram, ""), + try(aws_msk_cluster.this[0].bootstrap_brokers_tls, ""), + ]) } output "bootstrap_brokers_plaintext" { description = "Comma separated list of one or more hostname:port pairs of kafka brokers suitable to bootstrap connectivity to the kafka cluster. Contains a value if `encryption_in_transit_client_broker` is set to `PLAINTEXT` or `TLS_PLAINTEXT`" - value = element(concat(aws_msk_cluster.this[*].bootstrap_brokers, [""]), 0) + value = try(aws_msk_cluster.this[0].bootstrap_brokers, "") } output "bootstrap_brokers_sasl_iam" { description = "One or more DNS names (or IP addresses) and SASL IAM port pairs. This attribute will have a value if `encryption_in_transit_client_broker` is set to `TLS_PLAINTEXT` or `TLS` and `client_authentication_sasl_iam` is set to `true`" - value = element(concat(aws_msk_cluster.this[*].bootstrap_brokers_sasl_iam, [""]), 0) + value = try(aws_msk_cluster.this[0].bootstrap_brokers_sasl_iam, "") } output "bootstrap_brokers_sasl_scram" { description = "One or more DNS names (or IP addresses) and SASL SCRAM port pairs. This attribute will have a value if `encryption_in_transit_client_broker` is set to `TLS_PLAINTEXT` or `TLS` and `client_authentication_sasl_scram` is set to `true`" - value = element(concat(aws_msk_cluster.this[*].bootstrap_brokers_sasl_scram, [""]), 0) + value = try(aws_msk_cluster.this[0].bootstrap_brokers_sasl_scram, "") } output "bootstrap_brokers_tls" { description = "One or more DNS names (or IP addresses) and TLS port pairs. This attribute will have a value if `encryption_in_transit_client_broker` is set to `TLS_PLAINTEXT` or `TLS`" - value = element(concat(aws_msk_cluster.this[*].bootstrap_brokers_tls, [""]), 0) + value = try(aws_msk_cluster.this[0].bootstrap_brokers_tls, "") } output "current_version" { description = "Current version of the MSK Cluster used for updates, e.g. `K13V1IB3VIYZZH`" - value = element(concat(aws_msk_cluster.this[*].current_version, [""]), 0) + value = try(aws_msk_cluster.this[0].current_version, "") } output "zookeeper_connect_string" { description = "A comma separated list of one or more hostname:port pairs to use to connect to the Apache Zookeeper cluster. The returned values are sorted alphbetically" - value = element(concat(aws_msk_cluster.this[*].zookeeper_connect_string, [""]), 0) + value = try(aws_msk_cluster.this[0].zookeeper_connect_string, "") +} + +output "zookeeper_connect_string_tls" { + description = "A comma separated list of one or more hostname:port pairs to use to connect to the Apache Zookeeper cluster via TLS. The returned values are sorted alphbetically" + value = try(aws_msk_cluster.this[0].zookeeper_connect_string_tls, "") } # Configuration output "configuration_arn" { description = "Amazon Resource Name (ARN) of the configuration" - value = element(concat(aws_msk_configuration.this[*].arn, [""]), 0) + value = try(aws_msk_configuration.this[0].arn, "") } output "configuration_latest_revision" { description = "Latest revision of the configuration" - value = element(concat(aws_msk_configuration.this[*].latest_revision, [""]), 0) + value = try(aws_msk_configuration.this[0].latest_revision, "") } # SCRAM secret association output "scram_secret_association_id" { description = "Amazon Resource Name (ARN) of the MSK cluster" - value = element(concat(aws_msk_scram_secret_association.this[*].id, [""]), 0) + value = try(aws_msk_scram_secret_association.this[0].id, "") } # Schema registry diff --git a/variables.tf b/variables.tf index 82a6563..7b76dee 100644 --- a/variables.tf +++ b/variables.tf @@ -8,7 +8,7 @@ variable "create" { variable "name" { description = "Name of the MSK cluster" type = string - default = "" + default = "msk" # to avoid: Error: cluster_name must be 1 characters or higher } variable "kafka_version" { @@ -137,6 +137,12 @@ variable "s3_logs_prefix" { default = null } +variable "timeouts" { + description = "Create, update, and delete timeout configurations for the cluster" + type = map(string) + default = {} +} + variable "tags" { description = "A map of tags to assign to the resources created" type = map(string) diff --git a/versions.tf b/versions.tf index 94347e4..3b3f4fc 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.43" + version = ">= 3.60" } } }