Skip to content

Commit

Permalink
Merge pull request #17571 from ryan-dyer-sp/14324
Browse files Browse the repository at this point in the history
14324 - Fix kafka_versions being a required field
  • Loading branch information
ewbankkit authored May 26, 2021
2 parents a774dfa + 7440f1f commit 8a4d82b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .changelog/17571.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_msk_configuration: `kafka_versions` argument is optional
```
7 changes: 5 additions & 2 deletions aws/resource_aws_msk_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)),
}
Expand All @@ -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 {
Expand Down
17 changes: 8 additions & 9 deletions aws/resource_aws_msk_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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`)),
Expand Down Expand Up @@ -181,6 +181,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"),
),
},
{
Expand Down Expand Up @@ -291,8 +293,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 = <<PROPERTIES
auto.create.topics.enable = true
Expand All @@ -305,9 +306,8 @@ PROPERTIES
func testAccMskConfigurationConfigDescription(rName, description string) string {
return fmt.Sprintf(`
resource "aws_msk_configuration" "test" {
description = %[2]q
kafka_versions = ["2.1.0"]
name = %[1]q
description = %[2]q
name = %[1]q
server_properties = <<PROPERTIES
auto.create.topics.enable = true
Expand All @@ -319,7 +319,7 @@ PROPERTIES
func testAccMskConfigurationConfigKafkaVersions(rName string) string {
return fmt.Sprintf(`
resource "aws_msk_configuration" "test" {
kafka_versions = ["1.1.1", "2.1.0"]
kafka_versions = ["2.6.0", "2.7.0"]
name = %[1]q
server_properties = <<PROPERTIES
Expand All @@ -332,8 +332,7 @@ PROPERTIES
func testAccMskConfigurationConfigServerProperties(rName string, serverProperty string) string {
return fmt.Sprintf(`
resource "aws_msk_configuration" "test" {
kafka_versions = ["2.1.0"]
name = %[1]q
name = %[1]q
server_properties = <<PROPERTIES
%[2]s
Expand Down

0 comments on commit 8a4d82b

Please sign in to comment.