Skip to content

Commit f1e002d

Browse files
author
vijay-stephen
committed
Merge pull request #1 from sourcefuse/feature/rabbitmq
Terraform Module for Amazon MQ Broker Deployment
1 parent 1979918 commit f1e002d

File tree

1 file changed

+186
-0
lines changed
  • docs/arc-iac-docs/modules/terraform-aws-arc-mq-broker

1 file changed

+186
-0
lines changed
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
![Module Structure](./static/banner.png)
2+
# [terraform-aws-arc-mq-broker](https://github.com/sourcefuse/terraform-aws-arc-mq-broker)
3+
4+
<a href="https://github.com/sourcefuse/terraform-aws-arc-mq-broker/releases/latest"><img src="https://img.shields.io/github/release/sourcefuse/terraform-aws-arc-mq-broker.svg?style=for-the-badge" alt="Latest Release"/></a> <a href="https://github.com/sourcefuse/terraform-aws-arc-mq-broker/commits"><img src="https://img.shields.io/github/last-commit/sourcefuse/terraform-aws-arc-mq-broker.svg?style=for-the-badge" alt="Last Updated"/></a> ![Terraform](https://img.shields.io/badge/terraform-%235835CC.svg?style=for-the-badge&logo=terraform&logoColor=white) ![GitHub Actions](https://img.shields.io/badge/github%20actions-%232671E5.svg?style=for-the-badge&logo=githubactions&logoColor=white)
5+
6+
[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=sourcefuse_terraform-aws-arc-mq-broker&token=4b8c1e882ad792f7a14686684a563bccb5e6ee4c)](https://sonarcloud.io/summary/new_code?id=sourcefuse_terraform-aws-arc-mq-broker)
7+
8+
[![Known Vulnerabilities](https://github.com/sourcefuse/terraform-aws-arc-mq-broker/actions/workflows/snyk.yaml/badge.svg)](https://github.com/sourcefuse/terraform-aws-arc-mq-broker/actions/workflows/snyk.yaml)
9+
10+
11+
## Overview
12+
13+
SourceFuse AWS Reference Architecture (ARC) Terraform module provides an easy and scalable way to deploy and manage Amazon MQ brokers. It supports various deployment options and configurations, including engine types (ActiveMQ and RabbitMQ), instance classes, storage types, and security settings. The module simplifies the setup of brokers for message-oriented middleware with high availability and fault tolerance.
14+
15+
## Usage
16+
17+
See the `example` folder for a working module example.
18+
19+
```hcl
20+
################################################################################
21+
## RabbitMQ
22+
################################################################################
23+
module "mq_broker" {
24+
source = "sourcefuse/arc-mq-broker/aws"
25+
version = "0.0.1"
26+
name = var.name
27+
broker_type = var.broker_type
28+
engine_version = var.engine_version
29+
host_instance_type = var.host_instance_type
30+
vpc_id = data.aws_vpc.default.id
31+
subnet_ids = data.aws_subnets.private.ids
32+
deployment_mode = var.deployment_mode
33+
users = var.users
34+
enable_logging = var.enable_logging
35+
security_group_data = local.security_group_data
36+
tags = module.tags.tags
37+
38+
}
39+
40+
################################################################################
41+
## Apache ActiveMQ
42+
################################################################################
43+
module "mq_broker" {
44+
source = "sourcefuse/arc-mq-broker/aws"
45+
version = "0.0.1"
46+
name = var.name
47+
broker_type = var.broker_type
48+
engine_version = var.engine_version
49+
host_instance_type = var.host_instance_type
50+
vpc_id = data.aws_vpc.default.id
51+
subnet_ids = data.aws_subnets.private.ids
52+
storage_type = var.storage_type
53+
deployment_mode = var.deployment_mode
54+
users_replica = var.users_replica
55+
users = var.users
56+
enable_logging = var.enable_logging
57+
security_group_data = local.security_group_data
58+
tags = module.tags.tags
59+
60+
}
61+
```
62+
63+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
64+
## Requirements
65+
66+
| Name | Version |
67+
|------|---------|
68+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.0 |
69+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |
70+
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0 |
71+
72+
## Providers
73+
74+
| Name | Version |
75+
|------|---------|
76+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.80.0 |
77+
| <a name="provider_random"></a> [random](#provider\_random) | 3.6.3 |
78+
79+
## Modules
80+
81+
| Name | Source | Version |
82+
|------|--------|---------|
83+
| <a name="module_arc_security_group"></a> [arc\_security\_group](#module\_arc\_security\_group) | git::[email protected]:sourcefuse/terraform-aws-arc-security-group.git | 0.0.1 |
84+
85+
## Resources
86+
87+
| Name | Type |
88+
|------|------|
89+
| [aws_mq_broker.active-mq](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/mq_broker) | resource |
90+
| [aws_mq_broker.rabbit-mq](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/mq_broker) | resource |
91+
| [aws_ssm_parameter.replication_user](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
92+
| [aws_ssm_parameter.replication_user_password](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
93+
| [aws_ssm_parameter.user_name](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
94+
| [aws_ssm_parameter.user_password](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
95+
| [random_password.mq_broker](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
96+
97+
## Inputs
98+
99+
| Name | Description | Type | Default | Required |
100+
|------|-------------|------|---------|:--------:|
101+
| <a name="input_apply_immediately"></a> [apply\_immediately](#input\_apply\_immediately) | Whether changes should be applied immediately. | `bool` | `true` | no |
102+
| <a name="input_auto_minor_version_upgrade"></a> [auto\_minor\_version\_upgrade](#input\_auto\_minor\_version\_upgrade) | Indicates whether minor engine upgrades are applied automatically to the instance during the maintenance window. | `bool` | `true` | no |
103+
| <a name="input_broker_type"></a> [broker\_type](#input\_broker\_type) | Specify the broker type: RabbitMQ or ActiveMQ | `string` | `"RabbitMQ"` | no |
104+
| <a name="input_data_replication_primary_broker_arn"></a> [data\_replication\_primary\_broker\_arn](#input\_data\_replication\_primary\_broker\_arn) | The ARN of the primary broker for data replication | `string` | `""` | no |
105+
| <a name="input_deployment_mode"></a> [deployment\_mode](#input\_deployment\_mode) | Deployment mode for the RabbitMQ or ActiveMQ broker. | `string` | `"SINGLE_INSTANCE"` | no |
106+
| <a name="input_enable_data_replication"></a> [enable\_data\_replication](#input\_enable\_data\_replication) | Enable or disable data replication for the broker | `bool` | `false` | no |
107+
| <a name="input_enable_logging"></a> [enable\_logging](#input\_enable\_logging) | Enable general logging for the RabbitMQ broker. | `bool` | `false` | no |
108+
| <a name="input_encryption_options"></a> [encryption\_options](#input\_encryption\_options) | Encryption options for the resource. | <pre>object({<br> use_aws_owned_key = bool<br> kms_key_id = string<br> })</pre> | <pre>{<br> "kms_key_id": null,<br> "use_aws_owned_key": true<br>}</pre> | no |
109+
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | Version of the RabbitMQ or ActiveMQ engine. | `string` | `"3.8.26"` | no |
110+
| <a name="input_environment"></a> [environment](#input\_environment) | Name of the environment, i.e. dev, stage, prod | `string` | `"dev"` | no |
111+
| <a name="input_host_instance_type"></a> [host\_instance\_type](#input\_host\_instance\_type) | Instance type for the RabbitMQ or ActiveMQ broker. | `string` | `"mq.t3.micro"` | no |
112+
| <a name="input_ldap_config"></a> [ldap\_config](#input\_ldap\_config) | Configuration for LDAP server | <pre>object({<br> required = bool<br> hosts = list(string)<br> role_base = string<br> role_name = string<br> role_search_matching = string<br> role_search_subtree = bool<br> service_account_password = string<br> service_account_username = string<br> user_base = string<br> user_role_name = string<br> user_search_matching = string<br> user_search_subtree = bool<br> })</pre> | <pre>{<br> "hosts": [],<br> "required": false,<br> "role_base": "",<br> "role_name": "",<br> "role_search_matching": "",<br> "role_search_subtree": false,<br> "service_account_password": "",<br> "service_account_username": "",<br> "user_base": "",<br> "user_role_name": "",<br> "user_search_matching": "",<br> "user_search_subtree": false<br>}</pre> | no |
113+
| <a name="input_maintenance_window"></a> [maintenance\_window](#input\_maintenance\_window) | Maintenance window configuration including day, time, and time zone. | <pre>object({<br> day_of_week = string<br> time_of_day = string<br> time_zone = string<br> })</pre> | <pre>{<br> "day_of_week": "MONDAY",<br> "time_of_day": "02:00",<br> "time_zone": "UTC"<br>}</pre> | no |
114+
| <a name="input_name"></a> [name](#input\_name) | Name of the RabbitMQ or ActiveMQ broker. | `string` | n/a | yes |
115+
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace of the project, i.e. arc | `string` | `"arc"` | no |
116+
| <a name="input_publicly_accessible"></a> [publicly\_accessible](#input\_publicly\_accessible) | Whether the RabbitMQ or ActiveMQ broker is publicly accessible. | `bool` | `false` | no |
117+
| <a name="input_security_group_data"></a> [security\_group\_data](#input\_security\_group\_data) | (optional) Security Group data | <pre>object({<br> security_group_ids_to_attach = optional(list(string), [])<br> create = optional(bool, true)<br> description = optional(string, null)<br> ingress_rules = optional(list(object({<br> description = optional(string, null)<br> cidr_block = optional(string, null)<br> source_security_group_id = optional(string, null)<br> from_port = number<br> ip_protocol = string<br> to_port = string<br> self = optional(bool, false)<br> })), [])<br> egress_rules = optional(list(object({<br> description = optional(string, null)<br> cidr_block = optional(string, null)<br> destination_security_group_id = optional(string, null)<br> from_port = number<br> ip_protocol = string<br> to_port = string<br> prefix_list_id = optional(string, null)<br> })), [])<br> })</pre> | <pre>{<br> "create": false<br>}</pre> | no |
118+
| <a name="input_storage_type"></a> [storage\_type](#input\_storage\_type) | Storage type for the RabbitMQ or ActiveMQ or ActiveMQ broker. | `string` | `"ebs"` | no |
119+
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | List of subnet IDs for the RabbitMQ or ActiveMQ broker. | `list(string)` | `[]` | no |
120+
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to apply to resources | `map(string)` | n/a | yes |
121+
| <a name="input_users"></a> [users](#input\_users) | List of users for the ActiveMQ broker | <pre>object({<br> username = optional(string)<br> groups = optional(list(string), [])<br> })</pre> | `{}` | no |
122+
| <a name="input_users_replica"></a> [users\_replica](#input\_users\_replica) | List of users for the ActiveMQ broker | <pre>object({<br> replication_username = optional(string)<br> groups = optional(list(string), [])<br> })</pre> | `{}` | no |
123+
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC ID for the VPC endpoint. | `string` | `null` | no |
124+
125+
## Outputs
126+
127+
| Name | Description |
128+
|------|-------------|
129+
| <a name="output_broker_id"></a> [broker\_id](#output\_broker\_id) | The ID of the MQ broker (RabbitMQ or ActiveMQ) based on the broker type. |
130+
| <a name="output_replication_user_password_ssm_parameter"></a> [replication\_user\_password\_ssm\_parameter](#output\_replication\_user\_password\_ssm\_parameter) | The SSM parameter storing the replication user password for ActiveMQ. |
131+
| <a name="output_security_group_id"></a> [security\_group\_id](#output\_security\_group\_id) | The ID of the created security group for brokerMQ. |
132+
| <a name="output_user_password_ssm_parameter"></a> [user\_password\_ssm\_parameter](#output\_user\_password\_ssm\_parameter) | The SSM parameter storing the brokerMQ user password. |
133+
| <a name="output_user_ssm_parameter"></a> [user\_ssm\_parameter](#output\_user\_ssm\_parameter) | The SSM parameter storing the brokerMQ username. |
134+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
135+
136+
## Versioning
137+
This project uses a `.version` file at the root of the repo which the pipeline reads from and does a git tag.
138+
139+
When you intend to commit to `main`, you will need to increment this version. Once the project is merged,
140+
the pipeline will kick off and tag the latest git commit.
141+
142+
## Development
143+
144+
### Prerequisites
145+
146+
- [terraform](https://learn.hashicorp.com/terraform/getting-started/install#installing-terraform)
147+
- [terraform-docs](https://github.com/segmentio/terraform-docs)
148+
- [pre-commit](https://pre-commit.com/#install)
149+
- [golang](https://golang.org/doc/install#install)
150+
- [golint](https://github.com/golang/lint#installation)
151+
152+
### Configurations
153+
154+
- Configure pre-commit hooks
155+
```sh
156+
pre-commit install
157+
```
158+
159+
### Versioning
160+
161+
while Contributing or doing git commit please specify the breaking change in your commit message whether its major,minor or patch
162+
163+
For Example
164+
165+
```sh
166+
git commit -m "your commit message #major"
167+
```
168+
By specifying this , it will bump the version and if you don't specify this in your commit message then by default it will consider patch and will bump that accordingly
169+
170+
### Tests
171+
- Tests are available in `test` directory
172+
- Configure the dependencies
173+
```sh
174+
cd test/
175+
go mod init github.com/sourcefuse/terraform-aws-refarch-<module_name>
176+
go get github.com/gruntwork-io/terratest/modules/terraform
177+
```
178+
- Now execute the test
179+
```sh
180+
go test -timeout 30m
181+
```
182+
183+
## Authors
184+
185+
This project is authored by:
186+
- SourceFuse ARC Team

0 commit comments

Comments
 (0)