Skip to content

Commit 9ce03ed

Browse files
authored
Merge pull request #16108 from yardensachs/f-mq-rabbitmq-support
resource/aws_mq_broker: Add RabbitMQ engine type
2 parents a5dc3d0 + b0df885 commit 9ce03ed

9 files changed

Lines changed: 828 additions & 411 deletions

File tree

.changelog/16108.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
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.
3+
```

aws/data_source_aws_mq_broker.go

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ func dataSourceAwsMqBroker() *schema.Resource {
1313
Read: dataSourceAwsmQBrokerRead,
1414

1515
Schema: map[string]*schema.Schema{
16+
"arn": {
17+
Type: schema.TypeString,
18+
Computed: true,
19+
},
20+
"authentication_strategy": {
21+
Type: schema.TypeString,
22+
Computed: true,
23+
},
24+
"auto_minor_version_upgrade": {
25+
Type: schema.TypeBool,
26+
Computed: true,
27+
},
1628
"broker_id": {
1729
Type: schema.TypeString,
1830
Optional: true,
@@ -25,14 +37,6 @@ func dataSourceAwsMqBroker() *schema.Resource {
2537
Computed: true,
2638
ConflictsWith: []string{"broker_id"},
2739
},
28-
"auto_minor_version_upgrade": {
29-
Type: schema.TypeBool,
30-
Computed: true,
31-
},
32-
"arn": {
33-
Type: schema.TypeString,
34-
Computed: true,
35-
},
3640
"configuration": {
3741
Type: schema.TypeList,
3842
Computed: true,
@@ -90,15 +94,68 @@ func dataSourceAwsMqBroker() *schema.Resource {
9094
Type: schema.TypeString,
9195
Computed: true,
9296
},
97+
"endpoints": {
98+
Type: schema.TypeList,
99+
Computed: true,
100+
Elem: &schema.Schema{Type: schema.TypeString},
101+
},
93102
"ip_address": {
94103
Type: schema.TypeString,
95104
Computed: true,
96105
},
97-
"endpoints": {
106+
},
107+
},
108+
},
109+
"ldap_server_metadata": {
110+
Type: schema.TypeList,
111+
Computed: true,
112+
Elem: &schema.Resource{
113+
Schema: map[string]*schema.Schema{
114+
"hosts": {
98115
Type: schema.TypeList,
99116
Computed: true,
100117
Elem: &schema.Schema{Type: schema.TypeString},
101118
},
119+
"role_base": {
120+
Type: schema.TypeString,
121+
Computed: true,
122+
},
123+
"role_name": {
124+
Type: schema.TypeString,
125+
Computed: true,
126+
},
127+
"role_search_matching": {
128+
Type: schema.TypeString,
129+
Computed: true,
130+
},
131+
"role_search_subtree": {
132+
Type: schema.TypeBool,
133+
Computed: true,
134+
},
135+
"service_account_password": {
136+
Type: schema.TypeString,
137+
Computed: true,
138+
},
139+
"service_account_username": {
140+
Type: schema.TypeString,
141+
Computed: true,
142+
},
143+
"user_base": {
144+
Type: schema.TypeString,
145+
Computed: true,
146+
},
147+
"user_role_name": {
148+
Type: schema.TypeString,
149+
Computed: true,
150+
},
151+
"user_search_matching": {
152+
Type: schema.TypeString,
153+
Computed: true,
154+
},
155+
"user_search_subtree": {
156+
Type: schema.TypeBool,
157+
Computed: true,
158+
},
102159
},
103160
},
104161
},
@@ -155,6 +212,10 @@ func dataSourceAwsMqBroker() *schema.Resource {
155212
Elem: &schema.Schema{Type: schema.TypeString},
156213
Computed: true,
157214
},
215+
"storage_type": {
216+
Type: schema.TypeString,
217+
Computed: true,
218+
},
158219
"subnet_ids": {
159220
Type: schema.TypeSet,
160221
Elem: &schema.Schema{Type: schema.TypeString},

aws/data_source_aws_mq_broker_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func TestAccDataSourceAWSMqBroker_basic(t *testing.T) {
2727
Check: resource.ComposeAggregateTestCheckFunc(
2828
resource.TestCheckResourceAttrPair(dataSourceByIdName, "arn", resourceName, "arn"),
2929
resource.TestCheckResourceAttrPair(dataSourceByIdName, "broker_name", resourceName, "broker_name"),
30+
resource.TestCheckResourceAttrPair(dataSourceByIdName, "authentication_strategy", resourceName, "authentication_strategy"),
3031
resource.TestCheckResourceAttrPair(dataSourceByIdName, "auto_minor_version_upgrade", resourceName, "auto_minor_version_upgrade"),
3132
resource.TestCheckResourceAttrPair(dataSourceByIdName, "deployment_mode", resourceName, "deployment_mode"),
3233
resource.TestCheckResourceAttrPair(dataSourceByIdName, "configuration.#", resourceName, "configuration.#"),
@@ -40,6 +41,7 @@ func TestAccDataSourceAWSMqBroker_basic(t *testing.T) {
4041
resource.TestCheckResourceAttrPair(dataSourceByIdName, "maintenance_window_start_time.#", resourceName, "maintenance_window_start_time.#"),
4142
resource.TestCheckResourceAttrPair(dataSourceByIdName, "publicly_accessible", resourceName, "publicly_accessible"),
4243
resource.TestCheckResourceAttrPair(dataSourceByIdName, "security_groups.#", resourceName, "security_groups.#"),
44+
resource.TestCheckResourceAttrPair(dataSourceByIdName, "storage_type", resourceName, "storage_type"),
4345
resource.TestCheckResourceAttrPair(dataSourceByIdName, "subnet_ids.#", resourceName, "subnet_ids.#"),
4446
resource.TestCheckResourceAttrPair(dataSourceByIdName, "tags.%", resourceName, "tags.%"),
4547
resource.TestCheckResourceAttrPair(dataSourceByIdName, "user.#", resourceName, "user.#"),
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package waiter
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws"
5+
"github.com/aws/aws-sdk-go/service/mq"
6+
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8+
)
9+
10+
func BrokerStatus(conn *mq.MQ, id string) resource.StateRefreshFunc {
11+
return func() (interface{}, string, error) {
12+
output, err := conn.DescribeBroker(&mq.DescribeBrokerInput{
13+
BrokerId: aws.String(id),
14+
})
15+
16+
if tfawserr.ErrCodeEquals(err, mq.ErrCodeNotFoundException) {
17+
return nil, "", nil
18+
}
19+
20+
if err != nil {
21+
return nil, "", err
22+
}
23+
24+
if output == nil {
25+
return nil, "", nil
26+
}
27+
28+
return output, aws.StringValue(output.BrokerState), nil
29+
}
30+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package waiter
2+
3+
import (
4+
"time"
5+
6+
"github.com/aws/aws-sdk-go/service/mq"
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8+
)
9+
10+
const (
11+
BrokerCreateTimeout = 30 * time.Minute
12+
BrokerDeleteTimeout = 30 * time.Minute
13+
BrokerRebootTimeout = 30 * time.Minute
14+
)
15+
16+
func BrokerCreated(conn *mq.MQ, id string) (*mq.DescribeBrokerResponse, error) {
17+
stateConf := resource.StateChangeConf{
18+
Pending: []string{
19+
mq.BrokerStateCreationInProgress,
20+
mq.BrokerStateRebootInProgress,
21+
},
22+
Target: []string{mq.BrokerStateRunning},
23+
Timeout: BrokerCreateTimeout,
24+
Refresh: BrokerStatus(conn, id),
25+
}
26+
outputRaw, err := stateConf.WaitForState()
27+
28+
if output, ok := outputRaw.(*mq.DescribeBrokerResponse); ok {
29+
return output, err
30+
}
31+
32+
return nil, err
33+
}
34+
35+
func BrokerDeleted(conn *mq.MQ, id string) (*mq.DescribeBrokerResponse, error) {
36+
stateConf := resource.StateChangeConf{
37+
Pending: []string{
38+
mq.BrokerStateRunning,
39+
mq.BrokerStateRebootInProgress,
40+
mq.BrokerStateDeletionInProgress,
41+
},
42+
Target: []string{},
43+
Timeout: BrokerDeleteTimeout,
44+
Refresh: BrokerStatus(conn, id),
45+
}
46+
outputRaw, err := stateConf.WaitForState()
47+
48+
if output, ok := outputRaw.(*mq.DescribeBrokerResponse); ok {
49+
return output, err
50+
}
51+
52+
return nil, err
53+
}
54+
55+
func BrokerRebooted(conn *mq.MQ, id string) (*mq.DescribeBrokerResponse, error) {
56+
stateConf := resource.StateChangeConf{
57+
Pending: []string{
58+
mq.BrokerStateRebootInProgress,
59+
},
60+
Target: []string{mq.BrokerStateRunning},
61+
Timeout: BrokerRebootTimeout,
62+
Refresh: BrokerStatus(conn, id),
63+
}
64+
outputRaw, err := stateConf.WaitForState()
65+
66+
if output, ok := outputRaw.(*mq.DescribeBrokerResponse); ok {
67+
return output, err
68+
}
69+
70+
return nil, err
71+
}

0 commit comments

Comments
 (0)