Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_mq_broker: Add RabbitMQ engine type #16108

Merged
merged 21 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e5e552f
resource/aws_mq_broker: Added RabbitMQ engine type
yardensachs Nov 19, 2020
e3e43df
resource/aws_mq_broker: Add changelog
YakDriver Mar 5, 2021
e2ddcdd
docs/resource/mq_broker: Describe RabbitMQ limits
YakDriver Mar 5, 2021
2e17c5e
docs/resource/mq_broker: Clean up docs
YakDriver Mar 5, 2021
b37c5e5
resource/mq_broker: Make security groups optional
YakDriver Mar 5, 2021
3674002
resource/mq_broker: Move expanders/flatteners to resource file
YakDriver Mar 5, 2021
0af1a36
resource/mq_broker: Allow logging to be unset (AWS provides default)
YakDriver Mar 5, 2021
db133d6
resource/mq_broker: Add storage and authentication arguments
YakDriver Mar 5, 2021
fefe3a2
docs/resource/mq_broker: Add storage and authentication arguments
YakDriver Mar 5, 2021
8492260
tests/resource/mq_broker: Add storage and authentication arguments
YakDriver Mar 5, 2021
2dbc9b7
data-source/mq_broker: Add storage and authentication arguments
YakDriver Mar 5, 2021
97387c3
tests/data-source/mq_broker: Add storage and authentication arguments
YakDriver Mar 5, 2021
19dd6ed
tests/resource/mq_broker: MQ capitalization issues
YakDriver Mar 5, 2021
c78fc4e
resource/mq_broker: Rework with waiter
YakDriver Mar 5, 2021
73433fc
docs/resource/mq_broker: Update docs with new attributes
YakDriver Mar 5, 2021
7798234
resource/mq_broker: Avoid nil pointer panic
YakDriver Mar 5, 2021
ed284c7
resource/mq_broker: Move state waiting to waiter
YakDriver Mar 5, 2021
05a5bc0
resource/mq_broker: Fix waiter
YakDriver Mar 5, 2021
1a4e838
resource/mq_broker: Update changelog
YakDriver Mar 5, 2021
785535a
tests/resource/mq_broker: Allow sweeper to retry in some cases
YakDriver Mar 5, 2021
b0df885
resource/mq_broker: Use const for error code
YakDriver Mar 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/16108.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_mq_broker: Add RabbitMQ as option for `engine_type`, and new arguments `authentication_strategy`, `ldap_server_metadata`, and `storage_type`. Improve handling of eventual consistency.
```
79 changes: 70 additions & 9 deletions aws/data_source_aws_mq_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ func dataSourceAwsMqBroker() *schema.Resource {
Read: dataSourceAwsmQBrokerRead,

Schema: map[string]*schema.Schema{
"arn": {
Type: schema.TypeString,
Computed: true,
},
"authentication_strategy": {
Type: schema.TypeString,
Computed: true,
},
"auto_minor_version_upgrade": {
Type: schema.TypeBool,
Computed: true,
},
"broker_id": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -25,14 +37,6 @@ func dataSourceAwsMqBroker() *schema.Resource {
Computed: true,
ConflictsWith: []string{"broker_id"},
},
"auto_minor_version_upgrade": {
Type: schema.TypeBool,
Computed: true,
},
"arn": {
Type: schema.TypeString,
Computed: true,
},
"configuration": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -90,15 +94,68 @@ func dataSourceAwsMqBroker() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"endpoints": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"ip_address": {
Type: schema.TypeString,
Computed: true,
},
"endpoints": {
},
},
},
"ldap_server_metadata": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"hosts": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"role_base": {
Type: schema.TypeString,
Computed: true,
},
"role_name": {
Type: schema.TypeString,
Computed: true,
},
"role_search_matching": {
Type: schema.TypeString,
Computed: true,
},
"role_search_subtree": {
Type: schema.TypeBool,
Computed: true,
},
"service_account_password": {
Type: schema.TypeString,
Computed: true,
},
"service_account_username": {
Type: schema.TypeString,
Computed: true,
},
"user_base": {
Type: schema.TypeString,
Computed: true,
},
"user_role_name": {
Type: schema.TypeString,
Computed: true,
},
"user_search_matching": {
Type: schema.TypeString,
Computed: true,
},
"user_search_subtree": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
Expand Down Expand Up @@ -155,6 +212,10 @@ func dataSourceAwsMqBroker() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"storage_type": {
Type: schema.TypeString,
Computed: true,
},
"subnet_ids": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Expand Down
2 changes: 2 additions & 0 deletions aws/data_source_aws_mq_broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestAccDataSourceAWSMqBroker_basic(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceByIdName, "arn", resourceName, "arn"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "broker_name", resourceName, "broker_name"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "authentication_strategy", resourceName, "authentication_strategy"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "auto_minor_version_upgrade", resourceName, "auto_minor_version_upgrade"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "deployment_mode", resourceName, "deployment_mode"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "configuration.#", resourceName, "configuration.#"),
Expand All @@ -40,6 +41,7 @@ func TestAccDataSourceAWSMqBroker_basic(t *testing.T) {
resource.TestCheckResourceAttrPair(dataSourceByIdName, "maintenance_window_start_time.#", resourceName, "maintenance_window_start_time.#"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "publicly_accessible", resourceName, "publicly_accessible"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "security_groups.#", resourceName, "security_groups.#"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "storage_type", resourceName, "storage_type"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "subnet_ids.#", resourceName, "subnet_ids.#"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "tags.%", resourceName, "tags.%"),
resource.TestCheckResourceAttrPair(dataSourceByIdName, "user.#", resourceName, "user.#"),
Expand Down
30 changes: 30 additions & 0 deletions aws/internal/service/mq/waiter/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package waiter

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/mq"
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func BrokerStatus(conn *mq.MQ, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
output, err := conn.DescribeBroker(&mq.DescribeBrokerInput{
BrokerId: aws.String(id),
})

if tfawserr.ErrCodeEquals(err, mq.ErrCodeNotFoundException) {
return nil, "", nil
}

if err != nil {
return nil, "", err
}

if output == nil {
return nil, "", nil
}

return output, aws.StringValue(output.BrokerState), nil
}
}
71 changes: 71 additions & 0 deletions aws/internal/service/mq/waiter/waiter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package waiter

import (
"time"

"github.com/aws/aws-sdk-go/service/mq"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

const (
BrokerCreateTimeout = 30 * time.Minute
BrokerDeleteTimeout = 30 * time.Minute
BrokerRebootTimeout = 30 * time.Minute
)

func BrokerCreated(conn *mq.MQ, id string) (*mq.DescribeBrokerResponse, error) {
stateConf := resource.StateChangeConf{
Pending: []string{
mq.BrokerStateCreationInProgress,
mq.BrokerStateRebootInProgress,
},
Target: []string{mq.BrokerStateRunning},
Timeout: BrokerCreateTimeout,
Refresh: BrokerStatus(conn, id),
}
outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*mq.DescribeBrokerResponse); ok {
return output, err
}

return nil, err
}

func BrokerDeleted(conn *mq.MQ, id string) (*mq.DescribeBrokerResponse, error) {
stateConf := resource.StateChangeConf{
Pending: []string{
mq.BrokerStateRunning,
mq.BrokerStateRebootInProgress,
mq.BrokerStateDeletionInProgress,
},
Target: []string{},
Timeout: BrokerDeleteTimeout,
Refresh: BrokerStatus(conn, id),
}
outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*mq.DescribeBrokerResponse); ok {
return output, err
}

return nil, err
}

func BrokerRebooted(conn *mq.MQ, id string) (*mq.DescribeBrokerResponse, error) {
stateConf := resource.StateChangeConf{
Pending: []string{
mq.BrokerStateRebootInProgress,
},
Target: []string{mq.BrokerStateRunning},
Timeout: BrokerRebootTimeout,
Refresh: BrokerStatus(conn, id),
}
outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*mq.DescribeBrokerResponse); ok {
return output, err
}

return nil, err
}
Loading