diff --git a/.changelog/17571.txt b/.changelog/17571.txt new file mode 100644 index 00000000000..af769263bcc --- /dev/null +++ b/.changelog/17571.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_msk_configuration: `kafka_versions` argument is optional +``` \ No newline at end of file diff --git a/aws/resource_aws_msk_configuration.go b/aws/resource_aws_msk_configuration.go index 345aa0eed1a..1fcc3fd2837 100644 --- a/aws/resource_aws_msk_configuration.go +++ b/aws/resource_aws_msk_configuration.go @@ -32,7 +32,7 @@ func resourceAwsMskConfiguration() *schema.Resource { }, "kafka_versions": { Type: schema.TypeSet, - Required: true, + Optional: true, ForceNew: true, Elem: &schema.Schema{ Type: schema.TypeString, @@ -59,7 +59,6 @@ func resourceAwsMskConfigurationCreate(d *schema.ResourceData, meta interface{}) conn := meta.(*AWSClient).kafkaconn input := &kafka.CreateConfigurationInput{ - KafkaVersions: expandStringSet(d.Get("kafka_versions").(*schema.Set)), Name: aws.String(d.Get("name").(string)), ServerProperties: []byte(d.Get("server_properties").(string)), } @@ -68,6 +67,10 @@ func resourceAwsMskConfigurationCreate(d *schema.ResourceData, meta interface{}) input.Description = aws.String(v.(string)) } + if v, ok := d.GetOk("kafka_versions"); ok && v.(*schema.Set).Len() > 0 { + input.KafkaVersions = expandStringSet(v.(*schema.Set)) + } + output, err := conn.CreateConfiguration(input) if err != nil { diff --git a/aws/resource_aws_msk_configuration_test.go b/aws/resource_aws_msk_configuration_test.go index 398af256ee7..c3194e161e1 100644 --- a/aws/resource_aws_msk_configuration_test.go +++ b/aws/resource_aws_msk_configuration_test.go @@ -91,7 +91,7 @@ func TestAccAWSMskConfiguration_basic(t *testing.T) { testAccCheckMskConfigurationExists(resourceName, &configuration1), testAccMatchResourceAttrRegionalARN(resourceName, "arn", "kafka", regexp.MustCompile(`configuration/.+`)), resource.TestCheckResourceAttr(resourceName, "description", ""), - resource.TestCheckResourceAttr(resourceName, "kafka_versions.#", "1"), + resource.TestCheckResourceAttr(resourceName, "kafka_versions.#", "0"), resource.TestCheckResourceAttr(resourceName, "latest_revision", "1"), resource.TestCheckResourceAttr(resourceName, "name", rName), resource.TestMatchResourceAttr(resourceName, "server_properties", regexp.MustCompile(`auto.create.topics.enable = true`)), @@ -177,6 +177,8 @@ func TestAccAWSMskConfiguration_KafkaVersions(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckMskConfigurationExists(resourceName, &configuration1), resource.TestCheckResourceAttr(resourceName, "kafka_versions.#", "2"), + resource.TestCheckTypeSetElemAttr(resourceName, "kafka_versions.*", "2.6.0"), + resource.TestCheckTypeSetElemAttr(resourceName, "kafka_versions.*", "2.7.0"), ), }, { @@ -286,8 +288,7 @@ func testAccCheckMskConfigurationExists(resourceName string, configuration *kafk func testAccMskConfigurationConfig(rName string) string { return fmt.Sprintf(` resource "aws_msk_configuration" "test" { - kafka_versions = ["2.1.0"] - name = %[1]q + name = %[1]q server_properties = <