Skip to content

Commit

Permalink
Merge pull request #18070 from agranig/b-aws_mq_configuration-add_mis…
Browse files Browse the repository at this point in the history
…sing_auth_strategy

r/aws_mq_configuration: add missing authentication_strategy
  • Loading branch information
YakDriver authored Mar 24, 2021
2 parents b6e34c1 + eca06c0 commit 3d8e0fa
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 55 deletions.
3 changes: 3 additions & 0 deletions .changelog/18070.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_mq_configuration: Add `ldap` as an `authentication_strategy` and `RabbitMQ` as an `engine_type`
```
22 changes: 15 additions & 7 deletions aws/resource_aws_mq_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ func resourceAwsMqConfiguration() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"authentication_strategy": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice(mq.AuthenticationStrategy_Values(), true),
},
"data": {
Type: schema.TypeString,
Required: true,
Expand All @@ -52,12 +58,10 @@ func resourceAwsMqConfiguration() *schema.Resource {
Optional: true,
},
"engine_type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
mq.EngineTypeActivemq,
}, true),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice(mq.EngineType_Values(), true),
},
"engine_version": {
Type: schema.TypeString,
Expand Down Expand Up @@ -87,6 +91,9 @@ func resourceAwsMqConfigurationCreate(d *schema.ResourceData, meta interface{})
Name: aws.String(d.Get("name").(string)),
}

if v, ok := d.GetOk("authentication_strategy"); ok {
input.AuthenticationStrategy = aws.String(v.(string))
}
if v, ok := d.GetOk("tags"); ok {
input.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().MqTags()
}
Expand Down Expand Up @@ -121,11 +128,12 @@ func resourceAwsMqConfigurationRead(d *schema.ResourceData, meta interface{}) er
}

d.Set("arn", out.Arn)
d.Set("authentication_strategy", out.AuthenticationStrategy)
d.Set("description", out.LatestRevision.Description)
d.Set("engine_type", out.EngineType)
d.Set("engine_version", out.EngineVersion)
d.Set("name", out.Name)
d.Set("latest_revision", out.LatestRevision.Revision)
d.Set("name", out.Name)

rOut, err := conn.DescribeConfigurationRevision(&mq.DescribeConfigurationRevisionInput{
ConfigurationId: aws.String(d.Id()),
Expand Down
150 changes: 114 additions & 36 deletions aws/resource_aws_mq_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,30 @@ import (
)

func TestAccAWSMqConfiguration_basic(t *testing.T) {
configurationName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5))
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_mq_configuration.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSMq(t) },
PreCheck: func() {
testAccPreCheck(t)
testAccPartitionHasServicePreCheck(mq.EndpointsID, t)
testAccPreCheckAWSMq(t)
},
ErrorCheck: testAccErrorCheck(t, mq.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsMqConfigurationDestroy,
Steps: []resource.TestStep{
{
Config: testAccMqConfigurationConfig(configurationName),
Config: testAccMqConfigurationConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsMqConfigurationExists(resourceName),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "mq", regexp.MustCompile(`configuration:+.`)),
resource.TestCheckResourceAttr(resourceName, "authentication_strategy", "simple"),
resource.TestCheckResourceAttr(resourceName, "description", "TfAccTest MQ Configuration"),
resource.TestCheckResourceAttr(resourceName, "engine_type", "ActiveMQ"),
resource.TestCheckResourceAttr(resourceName, "engine_version", "5.15.0"),
resource.TestCheckResourceAttr(resourceName, "latest_revision", "2"),
resource.TestCheckResourceAttr(resourceName, "name", configurationName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
),
},
{
Expand All @@ -40,41 +45,81 @@ func TestAccAWSMqConfiguration_basic(t *testing.T) {
ImportStateVerify: true,
},
{
Config: testAccMqConfigurationConfig_descriptionUpdated(configurationName),
Config: testAccMqConfigurationConfig_descriptionUpdated(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsMqConfigurationExists(resourceName),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "mq", regexp.MustCompile(`configuration:+.`)),
resource.TestCheckResourceAttr(resourceName, "description", "TfAccTest MQ Configuration Updated"),
resource.TestCheckResourceAttr(resourceName, "engine_type", "ActiveMQ"),
resource.TestCheckResourceAttr(resourceName, "engine_version", "5.15.0"),
resource.TestCheckResourceAttr(resourceName, "latest_revision", "3"),
resource.TestCheckResourceAttr(resourceName, "name", configurationName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
),
},
},
})
}

func TestAccAWSMqConfiguration_withData(t *testing.T) {
configurationName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5))
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_mq_configuration.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSMq(t) },
PreCheck: func() {
testAccPreCheck(t)
testAccPartitionHasServicePreCheck(mq.EndpointsID, t)
testAccPreCheckAWSMq(t)
},
ErrorCheck: testAccErrorCheck(t, mq.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsMqConfigurationDestroy,
Steps: []resource.TestStep{
{
Config: testAccMqConfigurationWithDataConfig(configurationName),
Config: testAccMqConfigurationWithDataConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsMqConfigurationExists(resourceName),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "mq", regexp.MustCompile(`configuration:+.`)),
resource.TestCheckResourceAttr(resourceName, "description", "TfAccTest MQ Configuration"),
resource.TestCheckResourceAttr(resourceName, "engine_type", "ActiveMQ"),
resource.TestCheckResourceAttr(resourceName, "engine_version", "5.15.0"),
resource.TestCheckResourceAttr(resourceName, "latest_revision", "2"),
resource.TestCheckResourceAttr(resourceName, "name", configurationName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSMqConfiguration_withLdapData(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_mq_configuration.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
testAccPartitionHasServicePreCheck(mq.EndpointsID, t)
testAccPreCheckAWSMq(t)
},
ErrorCheck: testAccErrorCheck(t, mq.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsMqConfigurationDestroy,
Steps: []resource.TestStep{
{
Config: testAccMqConfigurationWithLdapDataConfig(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsMqConfigurationExists(resourceName),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "mq", regexp.MustCompile(`configuration:+.`)),
resource.TestCheckResourceAttr(resourceName, "authentication_strategy", "ldap"),
resource.TestCheckResourceAttr(resourceName, "description", "TfAccTest MQ Configuration"),
resource.TestCheckResourceAttr(resourceName, "engine_type", "ActiveMQ"),
resource.TestCheckResourceAttr(resourceName, "engine_version", "5.15.0"),
resource.TestCheckResourceAttr(resourceName, "latest_revision", "2"),
resource.TestCheckResourceAttr(resourceName, "name", rName),
),
},
{
Expand All @@ -87,17 +132,21 @@ func TestAccAWSMqConfiguration_withData(t *testing.T) {
}

func TestAccAWSMqConfiguration_updateTags(t *testing.T) {
configurationName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5))
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_mq_configuration.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSMq(t) },
PreCheck: func() {
testAccPreCheck(t)
testAccPartitionHasServicePreCheck(mq.EndpointsID, t)
testAccPreCheckAWSMq(t)
},
ErrorCheck: testAccErrorCheck(t, mq.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsMqConfigurationDestroy,
Steps: []resource.TestStep{
{
Config: testAccMqConfigurationConfig_updateTags1(configurationName),
Config: testAccMqConfigurationConfig_updateTags1(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsMqConfigurationExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
Expand All @@ -110,7 +159,7 @@ func TestAccAWSMqConfiguration_updateTags(t *testing.T) {
ImportStateVerify: true,
},
{
Config: testAccMqConfigurationConfig_updateTags2(configurationName),
Config: testAccMqConfigurationConfig_updateTags2(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsMqConfigurationExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"),
Expand All @@ -119,7 +168,7 @@ func TestAccAWSMqConfiguration_updateTags(t *testing.T) {
),
},
{
Config: testAccMqConfigurationConfig_updateTags3(configurationName),
Config: testAccMqConfigurationConfig_updateTags3(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsMqConfigurationExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
Expand Down Expand Up @@ -169,28 +218,29 @@ func testAccCheckAwsMqConfigurationExists(name string) resource.TestCheckFunc {
}
}

func testAccMqConfigurationConfig(configurationName string) string {
func testAccMqConfigurationConfig(rName string) string {
return fmt.Sprintf(`
resource "aws_mq_configuration" "test" {
description = "TfAccTest MQ Configuration"
name = "%s"
engine_type = "ActiveMQ"
engine_version = "5.15.0"
description = "TfAccTest MQ Configuration"
name = %[1]q
engine_type = "ActiveMQ"
engine_version = "5.15.0"
authentication_strategy = "simple"
data = <<DATA
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<broker xmlns="http://activemq.apache.org/schema/core">
</broker>
DATA
}
`, configurationName)
`, rName)
}

func testAccMqConfigurationConfig_descriptionUpdated(configurationName string) string {
func testAccMqConfigurationConfig_descriptionUpdated(rName string) string {
return fmt.Sprintf(`
resource "aws_mq_configuration" "test" {
description = "TfAccTest MQ Configuration Updated"
name = "%s"
name = %[1]q
engine_type = "ActiveMQ"
engine_version = "5.15.0"
Expand All @@ -200,14 +250,14 @@ resource "aws_mq_configuration" "test" {
</broker>
DATA
}
`, configurationName)
`, rName)
}

func testAccMqConfigurationWithDataConfig(configurationName string) string {
func testAccMqConfigurationWithDataConfig(rName string) string {
return fmt.Sprintf(`
resource "aws_mq_configuration" "test" {
description = "TfAccTest MQ Configuration"
name = "%s"
name = %[1]q
engine_type = "ActiveMQ"
engine_version = "5.15.0"
Expand Down Expand Up @@ -235,14 +285,42 @@ resource "aws_mq_configuration" "test" {
</broker>
DATA
}
`, configurationName)
`, rName)
}

func testAccMqConfigurationWithLdapDataConfig(rName string) string {
return fmt.Sprintf(`
resource "aws_mq_configuration" "test" {
description = "TfAccTest MQ Configuration"
name = %[1]q
engine_type = "ActiveMQ"
engine_version = "5.15.0"
authentication_strategy = "ldap"
data = <<DATA
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<broker xmlns="http://activemq.apache.org/schema/core">
<plugins>
<authorizationPlugin>
<map>
<cachedLDAPAuthorizationMap legacyGroupMapping="false" queueSearchBase="ou=Queue,ou=Destination,ou=ActiveMQ,dc=example,dc=org" refreshInterval="0" tempSearchBase="ou=Temp,ou=Destination,ou=ActiveMQ,dc=example,dc=org" topicSearchBase="ou=Topic,ou=Destination,ou=ActiveMQ,dc=example,dc=org"/>
</map>
</authorizationPlugin>
<forcePersistencyModeBrokerPlugin persistenceFlag="true"/>
<statisticsBrokerPlugin/>
<timeStampingBrokerPlugin ttlCeiling="86400000" zeroExpirationOverride="86400000"/>
</plugins>
</broker>
DATA
}
`, rName)
}

func testAccMqConfigurationConfig_updateTags1(configurationName string) string {
func testAccMqConfigurationConfig_updateTags1(rName string) string {
return fmt.Sprintf(`
resource "aws_mq_configuration" "test" {
description = "TfAccTest MQ Configuration"
name = "%s"
name = %[1]q
engine_type = "ActiveMQ"
engine_version = "5.15.0"
Expand All @@ -256,14 +334,14 @@ DATA
env = "test"
}
}
`, configurationName)
`, rName)
}

func testAccMqConfigurationConfig_updateTags2(configurationName string) string {
func testAccMqConfigurationConfig_updateTags2(rName string) string {
return fmt.Sprintf(`
resource "aws_mq_configuration" "test" {
description = "TfAccTest MQ Configuration"
name = "%s"
name = %[1]q
engine_type = "ActiveMQ"
engine_version = "5.15.0"
Expand All @@ -278,14 +356,14 @@ DATA
role = "test-role"
}
}
`, configurationName)
`, rName)
}

func testAccMqConfigurationConfig_updateTags3(configurationName string) string {
func testAccMqConfigurationConfig_updateTags3(rName string) string {
return fmt.Sprintf(`
resource "aws_mq_configuration" "test" {
description = "TfAccTest MQ Configuration"
name = "%s"
name = %[1]q
engine_type = "ActiveMQ"
engine_version = "5.15.0"
Expand All @@ -299,5 +377,5 @@ DATA
role = "test-role"
}
}
`, configurationName)
`, rName)
}
Loading

0 comments on commit 3d8e0fa

Please sign in to comment.