#No kafka_versions property
resource aws_msk_configuration no_arg_config {
name = "no_arg_config"
server_properties = <<PROPERTIES
auto.create.topics.enable = true
delete.topic.enable = true
PROPERTIES
}
# kafka_versions null property
resource aws_msk_configuration null_kafka_versions_config {
name = "null_kafka_versions_config"
kafka_versions = null
server_properties = <<PROPERTIES
auto.create.topics.enable = true
delete.topic.enable = true
PROPERTIES
}
#No kafka_versions property output
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
cd "msk-configs"; \
terraform plan
Error: Missing required argument
on .terraform/modules/msk-configs/modules/msk-configs/main.tf line 23, in resource "aws_msk_configuration" "no_arg_config":
23: resource aws_msk_configuration no_arg_config {
The argument "kafka_versions" is required, but no definition was found.
#kafka_versions null property output
cd "msk-configs"; \
terraform plan
Error: "kafka_versions": required field is not set
on .terraform/modules/msk-configs/modules/msk-configs/main.tf line 23, in resource "aws_msk_configuration" "null_kafka_versions_config":
23: resource aws_msk_configuration null_kafka_versions_config {
N/A
I expected to create MSK configuration without specifying any Kafka Versions (see actual behaviour) but this property is currently mandatory on Terraform level even though it is optional on SDK level.
FTR it is fine that empty list and/or null fail but I expected that at least unset kafka_versions would get through
AWS UI and CLI allow to create MSK configuration without specifying Kafka version
In CLI --kafka-versions is optional parameter however Terraform resource requires this parameter to be set (see https://www.terraform.io/docs/providers/aws/r/msk_configuration.html#kafka_versions)
I tried following settings on terraform level:
1) Leave kafka_versions unset in TF resource - this does not work, see first output above for details
2) Set kafka_versions to null - this does not work either, see second output
3) Set kafka_versions to empty list ([]) - unfortunately this does not work either. I checked the cloudtrails and it shows following trace:
"requestParameters": {
"name": "ConfigEmptyVersion",
"kafkaVersions": [],
"serverProperties": "YXV0by5jcmVhdGUudG9waWNzLmVuYWJsZSA9IHRydWUKZGVsZXRlLnRvcGljLmVuYWJsZSA9IHRydWUK"
},
"responseElements": {
"message": "The provided value is not valid.",
"invalidParameter": "kafkaVersions"
}
I also created configuration without versions using UI just to check how should the request look like and got following results:
"requestParameters": {
"name": "NoneConfigTest",
"description": "Some desc",
"serverProperties": "YXV0by5jcmVhdGUudG9waWNzLmVuYWJsZT1mYWxzZQ=="
},
"responseElements": {
"name": "NoneConfigTest",
"creationTime": "2020-07-23T14:49:11.474Z",
"arn": "arn:aws:kafka:us-west-2:942795021942:configuration/NoneConfigTest/d97b9c42-9500-4f45-906d-9e86fe8bc2d7-4",
"latestRevision": {
"creationTime": "2020-07-23T14:49:11.474Z",
"revision": 1,
"description": "Some desc"
}
},
So it looks like the request works as long as kafka_versions is not specified, however given that null, empty list and property omissions don't work I am not able to achieve that from Terraform level.
This is can be useful when creating cluster with some config and then upgrading it to higher version when it becomes available (config is not version specific so chances are high that it will apply to higher version as well).
I think kafka_versions property should be optional on Terraform level as it is on AWS SDK level.
Try to create aws_msk_configuration with either:
1) Unset kafka_versions
2) kafka_versions set to null
3) kafka_versions set to []
Given that kafka_versions is optional on SDK level I would expect that 1) should be supported. I am fine with 2) and 3) not working
It looks like AWS is actively working on providing more features WRT MSK configurations so it may be that kafka_versions property was mandatory at some point
I did some digging around. In aws-sdk-go, the KafkaVersions used to be a required field up until May. Compare the schema changes:
I think terraform-provider-aws should make that field optional too.
Good point @mantkiewicz . I think they had to make it optional when introducing Kafka upgrade feature. If you upgrade Kafka from 2.3.1 to 2.4.1 and have config for 2.3.1 then things may become inconsistent (cluster could end up on 2.4.1 but config would be still for 2.3.1). Therefore possibility to have config without Kafka version may be useful. So this one is partly related to #13547
Most helpful comment
Good point @mantkiewicz . I think they had to make it optional when introducing Kafka upgrade feature. If you upgrade Kafka from 2.3.1 to 2.4.1 and have config for 2.3.1 then things may become inconsistent (cluster could end up on 2.4.1 but config would be still for 2.3.1). Therefore possibility to have config without Kafka version may be useful. So this one is partly related to #13547