Giter Site home page Giter Site logo

cloudposse / terraform-aws-mq-broker Goto Github PK

View Code? Open in Web Editor NEW
37.0 19.0 63.0 1.25 MB

Terraform module for provisioning an AmazonMQ broker

Home Page: https://cloudposse.com/accelerate

License: Apache License 2.0

Makefile 5.91% HCL 81.83% Go 12.26%

terraform-aws-mq-broker's Introduction

Project Banner

Latest ReleaseLast UpdatedSlack Community

Terraform module to provision AmazonMQ resources on AWS

Tip

๐Ÿ‘ฝ Use Atmos with Terraform

Cloud Posse uses atmos to easily orchestrate multiple environments using Terraform.
Works with Github Actions, Atlantis, or Spacelift.

Watch demo of using Atmos with Terraform
Example of running atmos to manage infrastructure from our Quick Start tutorial.

Introduction

This module provisions the following resources:

  • ActiveMQ broker
  • RabbitMQ broker
  • Security group rules to allow access to the broker

Admin and application users are created and credentials written to SSM if not passed in as variables.

Usage

For a complete example, see examples/complete.

For automated tests of the complete example using bats and Terratest (which tests and deploys the example on AWS), see test.

  module "mq_broker" {
    source = "cloudposse/mq-broker/aws"
    # Cloud Posse recommends pinning every module to a specific version
    # version     = "x.x.x"

    namespace                  = "eg"
    stage                      = "test"
    name                       = "mq-broker"
    apply_immediately          = true
    auto_minor_version_upgrade = true
    deployment_mode            = "ACTIVE_STANDBY_MULTI_AZ"
    engine_type                = "ActiveMQ"
    engine_version             = "5.15.14"
    host_instance_type         = "mq.t3.micro"
    publicly_accessible        = false
    general_log_enabled        = true
    audit_log_enabled          = true
    encryption_enabled         = true
    use_aws_owned_key          = true
    vpc_id                     = var.vpc_id
    subnet_ids                 = var.subnet_ids
    security_groups            = var.security_groups
  }

Important

In Cloud Posse's examples, we avoid pinning modules to specific versions to prevent discrepancies between the documentation and the latest released versions. However, for your own projects, we strongly advise pinning each module to the exact version you're using. This practice ensures the stability of your infrastructure. Additionally, we recommend implementing a systematic approach for updating versions to avoid unexpected changes.

Makefile Targets

Available targets:

  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen
  lint                                Lint terraform code

Requirements

Name Version
terraform >= 1.0.0
aws >= 3.0
random >= 3.0

Providers

Name Version
aws >= 3.0
random >= 3.0

Modules

Name Source Version
security_group cloudposse/security-group/aws 2.2.0
this cloudposse/label/null 0.25.0

Resources

Name Type
aws_mq_broker.default resource
aws_ssm_parameter.mq_application_password resource
aws_ssm_parameter.mq_application_username resource
aws_ssm_parameter.mq_master_password resource
aws_ssm_parameter.mq_master_username resource
random_password.mq_admin_password resource
random_password.mq_application_password resource
random_pet.mq_admin_user resource
random_pet.mq_application_user resource

Inputs

Name Description Type Default Required
additional_security_group_rules A list of Security Group rule objects to add to the created security group, in addition to the ones
this module normally creates. (To suppress the module's rules, set create_security_group to false
and supply your own security group(s) via associated_security_group_ids.)
The keys and values of the objects are fully compatible with the aws_security_group_rule resource, except
for security_group_id which will be ignored, and the optional "key" which, if provided, must be unique and known at "plan" time.
For more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule
and https://github.com/cloudposse/terraform-aws-security-group.
list(any) [] no
additional_tag_map Additional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration.
map(string) {} no
allow_all_egress If true, the created security group will allow egress on all ports and protocols to all IP addresses.
If this is false and no egress rules are otherwise specified, then no egress will be allowed.
bool true no
allowed_cidr_blocks A list of IPv4 CIDRs to allow access to the security group created by this module.
The length of this list must be known at "plan" time.
list(string) [] no
allowed_ingress_ports List of TCP ports to allow access to in the created security group.
Default is to allow access to all ports. Set create_security_group to false to disable.
Note: List of ports must be known at "plan" time.
list(number) [] no
allowed_ipv6_cidr_blocks A list of IPv6 CIDRs to allow access to the security group created by this module.
The length of this list must be known at "plan" time.
list(string) [] no
allowed_ipv6_prefix_list_ids A list of IPv6 Prefix Lists IDs to allow access to the security group created by this module.
The length of this list must be known at "plan" time.
list(string) [] no
allowed_security_group_ids A list of IDs of Security Groups to allow access to the security group created by this module.
The length of this list must be known at "plan" time.
list(string) [] no
allowed_security_groups DEPRECATED: Use allowed_security_group_ids instead.
A list of Security Group IDs to to be allowed to connect to the broker instance.
list(string) [] no
apply_immediately Specifies whether any cluster modifications are applied immediately, or during the next maintenance window bool false no
associated_security_group_ids A list of IDs of Security Groups to associate the created resource with, in addition to the created security group.
These security groups will not be modified and, if create_security_group is false, must have rules providing the desired access.
list(string) [] no
attributes ID element. Additional attributes (e.g. workers or cluster) to add to id,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the delimiter
and treated as a single ID element.
list(string) [] no
audit_log_enabled Enables audit logging. User management action made using JMX or the ActiveMQ Web Console is logged bool true no
auto_minor_version_upgrade Enables automatic upgrades to new minor versions for brokers, as Apache releases the versions bool false no
context Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
any
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
no
create_security_group Set true to create and configure a new security group. If false, associated_security_group_ids must be provided. bool true no
delimiter Delimiter to be used between ID elements.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
string null no
deployment_mode The deployment mode of the broker. Supported: SINGLE_INSTANCE and ACTIVE_STANDBY_MULTI_AZ string "ACTIVE_STANDBY_MULTI_AZ" no
descriptor_formats Describe additional descriptors to be output in the descriptors output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
{<br> format = string<br> labels = list(string)<br>}
(Type is any so the map values can later be enhanced to provide additional options.)
format is a Terraform format string to be passed to the format() function.
labels is a list of labels, in order, to pass to format() function.
Label values will be normalized before being passed to format() so they will be
identical to how they appear in id.
Default is {} (descriptors output will be empty).
any {} no
enabled Set to false to prevent the module from creating any resources bool null no
encryption_enabled Flag to enable/disable Amazon MQ encryption at rest bool true no
engine_type Type of broker engine, ActiveMQ or RabbitMQ string "ActiveMQ" no
engine_version The version of the broker engine. See https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/broker-engine.html for more details string "5.17.6" no
environment ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' string null no
existing_security_groups DEPRECATED: Use associated_security_group_ids instead.
List of existing Security Group IDs to place the broker into.
list(string) [] no
general_log_enabled Enables general logging via CloudWatch bool true no
host_instance_type The broker's instance type. e.g. mq.t2.micro or mq.m4.large string "mq.t3.micro" no
id_length_limit Limit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for keep the existing setting, which defaults to 0.
Does not affect id_full.
number null no
kms_mq_key_arn ARN of the AWS KMS key used for Amazon MQ encryption string null no
kms_ssm_key_arn ARN of the AWS KMS key used for SSM encryption string "alias/aws/ssm" no
label_key_case Controls the letter case of the tags keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the tags input.
Possible values: lower, title, upper.
Default value: title.
string null no
label_order The order in which the labels (ID elements) appear in the id.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.
list(string) null no
label_value_case Controls the letter case of ID elements (labels) as included in id,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the tags input.
Possible values: lower, title, upper and none (no transformation).
Set this to title and set delimiter to "" to yield Pascal Case IDs.
Default value: lower.
string null no
labels_as_tags Set of labels (ID elements) to include as tags in the tags output.
Default is to include all labels.
Tags with empty values will not be included in the tags output.
Set to [] to suppress all generated tags.
Notes:
The value of the name tag, if included, will be the id, not the name.
Unlike other null-label inputs, the initial setting of labels_as_tags cannot be
changed in later chained modules. Attempts to change it will be silently ignored.
set(string)
[
"default"
]
no
maintenance_day_of_week The maintenance day of the week. e.g. MONDAY, TUESDAY, or WEDNESDAY string "SUNDAY" no
maintenance_time_of_day The maintenance time, in 24-hour format. e.g. 02:00 string "03:00" no
maintenance_time_zone The maintenance time zone, in either the Country/City format, or the UTC offset format. e.g. CET string "UTC" no
mq_admin_password Admin password list(string) [] no
mq_admin_password_ssm_parameter_name SSM parameter name for Admin password string "mq_admin_password" no
mq_admin_user Admin username list(string) [] no
mq_admin_user_ssm_parameter_name SSM parameter name for Admin username string "mq_admin_username" no
mq_application_password Application password list(string) [] no
mq_application_password_ssm_parameter_name SSM parameter name for Application password string "mq_application_password" no
mq_application_user Application username list(string) [] no
mq_application_user_ssm_parameter_name SSM parameter name for Application username string "mq_application_username" no
name ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a tag.
The "name" tag is set to the full id string. There is no tag with the value of the name input.
string null no
namespace ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique string null no
preserve_security_group_id When false and security_group_create_before_destroy is true, changes to security group rules
cause a new security group to be created with the new rules, and the existing security group is then
replaced with the new one, eliminating any service interruption.
When true or when changing the value (from false to true or from true to false),
existing security group rules will be deleted before new ones are created, resulting in a service interruption,
but preserving the security group itself.
NOTE: Setting this to true does not guarantee the security group will never be replaced,
it only keeps changes to the security group rules from triggering a replacement.
See the terraform-aws-security-group README for further discussion.
bool false no
publicly_accessible Whether to enable connections from applications outside of the VPC that hosts the broker's subnets bool false no
regex_replace_chars Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
string null no
security_group_create_before_destroy Set true to enable Terraform create_before_destroy behavior on the created security group.
We only recommend setting this false if you are importing an existing security group
that you do not want replaced and therefore need full control over its name.
Note that changing this value will always cause the security group to be replaced.
bool true no
security_group_create_timeout How long to wait for the security group to be created. string "10m" no
security_group_delete_timeout How long to retry on DependencyViolation errors during security group deletion from
lingering ENIs left by certain AWS services such as Elastic Load Balancing.
string "15m" no
security_group_description The description to assign to the created Security Group.
Warning: Changing the description causes the security group to be replaced.
string "Managed by Terraform" no
security_group_name The name to assign to the created security group. Must be unique within the VPC.
If not provided, will be derived from the null-label.context passed in.
If create_before_destroy is true, will be used as a name prefix.
list(string) [] no
ssm_parameter_name_format SSM parameter name format string "/%s/%s" no
ssm_path The first parameter to substitute in ssm_parameter_name_format string "mq" no
stage ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' string null no
subnet_ids List of VPC subnet IDs list(string) n/a yes
tags Additional tags (e.g. {'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.
map(string) {} no
tenant ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for string null no
use_aws_owned_key Boolean to enable an AWS owned Key Management Service (KMS) Customer Master Key (CMK) for Amazon MQ encryption that is not in your account bool true no
use_existing_security_groups DEPRECATED: Use create_security_group instead.
Historical description: Set to true to disable Security Group creation
bool null no
vpc_id The ID of the VPC to create the broker in string n/a yes

Outputs

Name Description
admin_username AmazonMQ admin username
application_username AmazonMQ application username
broker_arn AmazonMQ broker ARN
broker_id AmazonMQ broker ID
primary_amqp_ssl_endpoint AmazonMQ primary AMQP+SSL endpoint
primary_console_url AmazonMQ active web console URL
primary_ip_address AmazonMQ primary IP address
primary_mqtt_ssl_endpoint AmazonMQ primary MQTT+SSL endpoint
primary_ssl_endpoint AmazonMQ primary SSL endpoint
primary_stomp_ssl_endpoint AmazonMQ primary STOMP+SSL endpoint
primary_wss_endpoint AmazonMQ primary WSS endpoint
secondary_amqp_ssl_endpoint AmazonMQ secondary AMQP+SSL endpoint
secondary_console_url AmazonMQ secondary web console URL
secondary_ip_address AmazonMQ secondary IP address
secondary_mqtt_ssl_endpoint AmazonMQ secondary MQTT+SSL endpoint
secondary_ssl_endpoint AmazonMQ secondary SSL endpoint
secondary_stomp_ssl_endpoint AmazonMQ secondary STOMP+SSL endpoint
secondary_wss_endpoint AmazonMQ secondary WSS endpoint
security_group_arn The ARN of the created security group
security_group_id The ID of the created security group
security_group_name The name of the created security group

Related Projects

Check out these related projects.

Tip

Use Terraform Reference Architectures for AWS

Use Cloud Posse's ready-to-go terraform architecture blueprints for AWS to get up and running quickly.

โœ… We build it together with your team.
โœ… Your team owns everything.
โœ… 100% Open Source and backed by fanatical support.

Request Quote

๐Ÿ“š Learn More

Cloud Posse is the leading DevOps Accelerator for funded startups and enterprises.

Your team can operate like a pro today.

Ensure that your team succeeds by using Cloud Posse's proven process and turnkey blueprints. Plus, we stick around until you succeed.

Day-0: Your Foundation for Success

  • Reference Architecture. You'll get everything you need from the ground up built using 100% infrastructure as code.
  • Deployment Strategy. Adopt a proven deployment strategy with GitHub Actions, enabling automated, repeatable, and reliable software releases.
  • Site Reliability Engineering. Gain total visibility into your applications and services with Datadog, ensuring high availability and performance.
  • Security Baseline. Establish a secure environment from the start, with built-in governance, accountability, and comprehensive audit logs, safeguarding your operations.
  • GitOps. Empower your team to manage infrastructure changes confidently and efficiently through Pull Requests, leveraging the full power of GitHub Actions.

Request Quote

Day-2: Your Operational Mastery

  • Training. Equip your team with the knowledge and skills to confidently manage the infrastructure, ensuring long-term success and self-sufficiency.
  • Support. Benefit from a seamless communication over Slack with our experts, ensuring you have the support you need, whenever you need it.
  • Troubleshooting. Access expert assistance to quickly resolve any operational challenges, minimizing downtime and maintaining business continuity.
  • Code Reviews. Enhance your teamโ€™s code quality with our expert feedback, fostering continuous improvement and collaboration.
  • Bug Fixes. Rely on our team to troubleshoot and resolve any issues, ensuring your systems run smoothly.
  • Migration Assistance. Accelerate your migration process with our dedicated support, minimizing disruption and speeding up time-to-value.
  • Customer Workshops. Engage with our team in weekly workshops, gaining insights and strategies to continuously improve and innovate.

Request Quote

โœจ Contributing

This project is under active development, and we encourage contributions from our community.

Many thanks to our outstanding contributors:

For ๐Ÿ› bug reports & feature requests, please use the issue tracker.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Review our Code of Conduct and Contributor Guidelines.
  2. Fork the repo on GitHub
  3. Clone the project to your own machine
  4. Commit changes to your own branch
  5. Push your work back up to your fork
  6. Submit a Pull Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

๐ŸŒŽ Slack Community

Join our Open Source Community on Slack. It's FREE for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally sweet infrastructure.

๐Ÿ“ฐ Newsletter

Sign up for our newsletter and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. Dropped straight into your Inbox every week โ€” and usually a 5-minute read.

๐Ÿ“† Office Hours

Join us every Wednesday via Zoom for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a live Q&A that you canโ€™t find anywhere else. It's FREE for everyone!

License

License

Preamble to the Apache License, Version 2.0

Complete license is available in the LICENSE file.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.

Trademarks

All other trademarks referenced herein are the property of their respective owners.


Copyright ยฉ 2017-2024 Cloud Posse, LLC

README footer

Beacon

terraform-aws-mq-broker's People

Contributors

actions-user avatar aknysh avatar andruccho avatar cloudpossebot avatar dependabot[bot] avatar gberenice avatar hans-d avatar heathsnow avatar johncblandii avatar joshmyers avatar joshuabalduff avatar luizbossoi avatar max-lobur avatar maximmi avatar milldr avatar osterman avatar renovate[bot] avatar sweetops avatar treksler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-aws-mq-broker's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

ENH: Defining allowed port without traffic source returns no feedback

Describe the Feature

Additional feedback when allowed_ingress_ports argument is set, but no source SG or CIDR is set.

Expected Behavior

Error or Warning output that setting allowed_ingress_ports also requires a source.

Use Case

Any time allowed_ingress_ports is set to non-default value.

Describe Ideal Solution

Check that a source is set.

add the ability to specify a configuration

Describe the Feature

The raq aws_mq_broker terraform resource has a configuration block (see official terraform docs). However, this block cannot be specified in this module.

Expected Behavior

The user should be able to specify a aws_mq_configuration terraform resource to the module.

Use Case

The user wants to provide aws_mq_configuration terraform resource to the module.

Describe Ideal Solution

The user wants to provide aws_mq_configuration terraform resource to the module.

Alternatives Considered

N/A

Additional Context

No response

Getting "Audit logging is not supported for RabbitMQ brokers." error when audit logging set to false or not defined

I'm trying to deploy RabbitMQ. It's a test, so the set up is basic and variables are hardcoded.
I'm on Terraform v0.13.0, runnning on macOS.

module "aws_mq_broker"{
    source = "git::https://github.com/cloudposse/terraform-aws-mq-broker.git?ref=0.13.0"
    stage                        = "test"
    name                         = "rabbitmq"
    apply_immediately            = true
    auto_minor_version_upgrade   = false
    deployment_mode              = "CLUSTER_MULTI_AZ"
    engine_type                  = "RabbitMQ"
    engine_version               = "3.9.13"
    host_instance_type           = "mq.m5.large"
    general_log_enabled          = true
    audit_log_enabled            = false
    encryption_enabled           = true
    use_aws_owned_key            = true
    vpc_id                       = "vpc-xxxxx"
    subnet_ids                   = [ "subnet-xxxx", "subnet-xxxx" ]
    security_group_rules        = []
}

terraform plan succeeds, but terraform apply errors out with:

Error: BadRequestException: Audit logging is not supported for RabbitMQ brokers.
{
  RespMetadata: {
    StatusCode: 400,
    RequestID: "5ee2ba47-6465-4acb-9ebd-e3839e8adbe9"
  },
  ErrorAttribute: "logs.audit",
  Message_: "Audit logging is not supported for RabbitMQ brokers."
}

I have tried 1) setting both general and audit logs to false; 2) removing these lines completely. In all scenarios I get the same error. I've seen similar issues discussed on Github and Stackoverflow when using the resource "rabbitmq", but in their case, if I understood correctly, the issue was that they didn't define these variables, so terraform resorted to default, which was set to true.

RabbitMQ_Cluster_Mode Unable to create

Unable to Create Cluster mode broker for the rabbitmq engine using this terraform module, seeing SINGLE_INSTANCE and ACTIVE_STANDBY_MULTI_AZ are expected.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Base branch does not exist - skipping

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

Branch main
terraform
sg.tf
  • cloudposse/security-group/aws 2.2.0
versions.tf
  • aws >= 3.0
  • random >= 3.0
  • hashicorp/terraform >= 1.0.0
Branch release/v0
terraform
sg.tf
  • cloudposse/security-group/aws 0.3.1
versions.tf
  • aws >= 2.0
  • null >= 2.0
  • random >= 2.2.0
  • template >= 2.0
  • hashicorp/terraform >= 0.13.0
Branch release/v1
terraform
versions.tf
  • aws >= 2.0
  • null >= 2.0
  • random >= 2.2.0
  • template >= 2.0
  • hashicorp/terraform >= 0.13.0
Branch release/v2
terraform
sg.tf
  • cloudposse/security-group/aws 1.0.1
versions.tf
  • aws >= 3.0
  • random >= 3.0
  • hashicorp/terraform >= 0.14.0

  • Check this box to trigger a request for Renovate to run again on this repository

Error building RabbitMQ : Audit logging is not supported for RabbitMQ brokers

Describe the Bug

When trying to create a RabbitMQ broker using this module, I get an error: Audit logging is not supported for RabbitMQ brokers.

Expected Behavior

Rabbit MQ broker should be created when I set required values.

Example Code

I'm trying to provide most relevant code here. Lots of dependencies I'm leaving off for VPC, but that's all pretty standard.

rabbitmq.tf file

resource "aws_security_group" "rmq_cluster" {
  name        = "${var.appname}-rmq-sg"
  description = "for Rabbit MQ Broker"

  vpc_id = module.vpc.vpc_id

  ingress {
    protocol    = -1
    from_port   = 0
    to_port     = 0
    cidr_blocks = [var.vpccidr]
    description = "Allow all resources in VPC resources to communicate with Rabbit MQ"
  }

  egress {
    protocol    = -1
    from_port   = 0
    to_port     = 0
    cidr_blocks = [var.vpccidr]
    description = "Allow all outbound access from Rabbit MQ"
  }

  tags = local.tags
}

module "mq_broker" {
  source = "cloudposse/mq-broker/aws"
  version = "0.9.0"

  name                         = local.broker_name
  engine_type                  = "RabbitMQ"
  engine_version               = var.rmq_engine_version
  host_instance_type           = var.rmq_host_instance_type
  deployment_mode              = var.rmq_deployment_mode
  vpc_id                       = module.vpc.vpc_id
  subnet_ids                   = local.rmq_subnet_list
  use_existing_security_groups = true
  audit_log_enabled            = false
  existing_security_groups     = [aws_security_group.rmq_cluster.id]
  mq_application_user          = superuser
  mq_application_password      = unbreakablepassword
  tags                         = local.tags
}

vars.tfvars file

rmq_host_instance_type    = "mq.t3.micro"
rmq_engine_version        = "3.8.6"
rmq_deployment_mode       = "SINGLE_INSTANCE"

locals.tf file

broker_name      = "${var.appname}-${var.env}-rmq-${random_string.suffix.result}"
rmq_subnet_list = var.rmq_deployment_mode == "SINGLE_INSTANCE" ? [module.vpc.private_subnets.0] : module.vpc.private_subnets

Error Output

Error: BadRequestException: Audit logging is not supported for RabbitMQ brokers.
{
  RespMetadata: {
    StatusCode: 400,
    RequestID: "2564760b-18ab-4e41-9179-8f6e437e0dbe"
  },
  ErrorAttribute: "logs.audit",
  Message_: "Audit logging is not supported for RabbitMQ brokers."
}

  on .terraform/modules/mq_broker/main.tf line 73, in resource "aws_mq_broker" "default":
  73: resource "aws_mq_broker" "default" {

SSM parameters should be optional

Describe the Feature

Hello!

Thank you for this (and other) modules! They are a breeze to use and help us a lot during development.

I would like to propose that SSM parameter creation should be optional. The reason is twofold:

  1. always-created SSM parameters is unexpected behavior when compared with rest of your modules (namely: rds, redis)
  2. We'd like to manage all SSM parameters in one place (with your ssm module btw), but this module forces us to either duplicate the parameters or split the configuration.

I'm happy to implement this feature if you agree to it and comment with a suggestion for the switch name.

Expected Behavior

SSM parameter creation should be hidden behind an optional flag. Probably set as a default to false?

Use Case

We would like to keep all parameters in one place and set them according to our needs, with values sourced from this module's outputs. That's technically still possible, but the module creates its own parameters, causing a bit of confusion and duplication.

Describe Ideal Solution

SSM parameter creation is hidden behind a flag.
If flag is set to false => no SSM parameter will be created automatically by the module.
If set to true => module works as it does now.

Alternatives Considered

No response

Additional Context

No response

Provide capability to create configurations for brokers

Describe the Feature

As a user of this module, I need to create configurations with custom values and attach them to the brokers created with this module

Expected Behavior

As a user of this module, I need to create configurations with custom values and attach them to the brokers created with this module

Use Case

We need to update consumer_timeout of our broker

Describe Ideal Solution

provide way to input configuration data

Alternatives Considered

No response

Additional Context

No response

Use of deprecated argument `overwrite` on `aws_ssm_parameter`

Describe the Bug

The overwrite argument on aws_ssm_parameter has been deprecated:

โ”‚ Warning: Argument is deprecated
โ”‚ 
โ”‚   with module.mq.module.mq_broker.aws_ssm_parameter.mq_application_username[0],
โ”‚   on .terraform/modules/mq.mq_broker/main.tf line 74, in resource "aws_ssm_parameter" "mq_application_username":
โ”‚   74:   overwrite   = var.overwrite_ssm_parameter
โ”‚ 
โ”‚ this attribute has been deprecated

See docs for reference: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter#overwrite

Expected Behavior

No deprecation warnings are printed.

Steps to Reproduce

Use terraform-aws-mq-broker 3.1.0 with the aws provider 5.x.

Screenshots

No response

Environment

No response

Additional Context

No response

BadRequestException: Specify exactly one user for engine type [RABBITMQ]

When we use this module for creating Rabbitmq, we get an unexpected error in our terraform application:

Error: BadRequestException: Specify exactly one user for engine type [RABBITMQ].
{
RespMetadata: {
StatusCode: 400,
RequestID: "128ea9ae-c2b6-4a3e-a644-2cc3470a2b1a"
},
ErrorAttribute: "users",
Message_: "Specify exactly one user for engine type [RABBITMQ]."
}

Expected Behavior

No bugs, should work fine.

Steps to Reproduce

Run the terraform using this module for RabbitMQ

Invalid count argument mq_application_password

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

โ”‚ Error: Invalid count argument
โ”‚ 
โ”‚   on .terraform/modules/main.mq_broker/main.tf line 42, in resource "random_password" "mq_application_password":
โ”‚   42:   count   = local.enabled && ! local.mq_application_password_is_set ? 1 : 0
โ”‚ 
โ”‚ The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created.
โ”‚ To work around this, use the -target argument to first apply only the resources that the count depends on.

Expected Behavior

im using the following for random password gen:

resource "random_password" "password" {
  length           = 32
  special          = true
  override_special = "-._~"
}

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • OS: OSX, Debian buster
  • Version Terraform v1.0.1

Add support for RabbitMQ

When trying the RabbitMQ option the code fails,

โ”‚ Error: expected engine_type to be one of [ACTIVEMQ], got RabbitMQ
โ”‚
โ”‚ with module.mq_broker.aws_mq_broker.default[0],
โ”‚ on .terraform/modules/mq_broker/main.tf line 91, in resource "aws_mq_broker" "default":
โ”‚ 91: engine_type = var.engine_type
โ”‚
โ•ต

using engine_type=RabbitMQ

engine_type seems to support only ActiveMQ

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

Documentation states that engine_type can be ActiveMQ or RabbitMQ. Despite that, creation of the resource with engine_type = "RabbitMQ" fails. I can see that at the time of writing (2021-03-08), this module uses aws_mq_broker under the hood, which does not support RabbitMQ yet (see hashicorp/terraform-provider-aws#16108). Probably this is just documentation issue, but if there is a way to spin up aws RabbitMQ broker, please advise. Thanks in advance!

Expected Behavior

Successful creation of the resource

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create resource using module:
module "mq_broker" {
  source = "cloudposse/mq-broker/aws"
  namespace                    = "ns"
  stage                        = "test"
  name                         = "rabbit"
  apply_immediately            = true
  auto_minor_version_upgrade   = true
  deployment_mode              = "SINGLE_INSTANCE"
  engine_type                  = "RabbitMQ"
  engine_version               = "3.8.6"
  host_instance_type           = "mq.t3.micro"
  publicly_accessible          = true
  general_log_enabled          = true
  audit_log_enabled            = true
  use_existing_security_groups = true
  existing_security_groups     = [aws_security_group.my.id]
  encryption_enabled           = false
  use_aws_owned_key            = false
  vpc_id                       = data.aws_vpc.my_vpc.id
  subnet_ids                   = data.aws_subnet_ids.my_vpc.ids
  mq_application_user          = data.aws_ssm_parameter.app_login.value
  mq_application_password      = data.aws_ssm_parameter.app_password.value
  mq_admin_user                = data.aws_ssm_parameter.admin_login.value
  mq_admin_password            = data.aws_ssm_parameter.admin_password.value
}

  1. Run terraform apply
  2. Enter yes
  3. See error
Error: expected engine_type to be one of [ACTIVEMQ], got RabbitMQ

  on .terraform/modules/mq_broker/main.tf line 71, in resource "aws_mq_broker" "default":
  71:   engine_type                = var.engine_type

Screenshots

If applicable, add screenshots or logs to help explain your problem.

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • OSX 11.2.1
  • terraform --version
terraform --version
Terraform v0.14.7
+ provider registry.terraform.io/hashicorp/aws v3.31.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/template v2.2.0

Additional Context

module.this.id Error

Describe the Bug

I'm calling terraform-aws-mq-broker v3.1.0 from terragrunt and get the following error on a plan. It looks like the module.this.id has no value and fails the two tests. I read that these modules should be compatible with the terragrunt.

The main.tf line 91 seems to be the issue.
broker_name = module.this.id

I'm not sure why the error is being thrown and assume it's related to the fact that the id is only available after the module is applied? What's the fix or what am I doing wrong in trying to use cp modules with terragrunt?

โ”‚ Error: expected length of broker_name to be in the range (1 - 50), got
โ”‚
โ”‚ with module.mq_broker.aws_mq_broker.default[0],
โ”‚ on .terraform/modules/mq_broker/main.tf line 91, in resource "aws_mq_broker" "default":
โ”‚ 91: broker_name = module.this.id
โ”‚
โ•ต
โ•ท
โ”‚ Error: expected value of broker_name to match regular expression "^[0-9A-Za-z_-]+$", got
โ”‚
โ”‚ with module.mq_broker.aws_mq_broker.default[0],
โ”‚ on .terraform/modules/mq_broker/main.tf line 91, in resource "aws_mq_broker" "default":
โ”‚ 91: broker_name = module.this.id
โ”‚
โ•ต
Releasing state lock. This may take a few moments...
ERRO[0055] Terraform invocation failed in /app/infrastructure-live/dev/ca-central-1/dev/messaging/rabbitmq/.terragrunt-cache/DzpSoeycWeukzz45-SRvPTXf7Qw/aYg6jvKMeoPdWBiN8E8O6YgHPKw prefix=[dev/ca-central-1/dev/messaging/rabbitmq]
ERRO[0055] 1 error occurred:
* [/app/infrastructure-live/dev/ca-central-1/dev/messaging/rabbitmq/.terragrunt-cache/DzpSoeycWeukzz45-SRvPTXf7Qw/aYg6jvKMeoPdWBiN8E8O6YgHPKw] exit status 1

Expected Behavior

Module applies without error

Steps to Reproduce

Use the module with terragrunt version v0.48.3 based on the examples/complete.

Screenshots

No response

Environment

terragrunt version v0.48.3
Terraform v1.5.4
on linux_amd64

Additional Context

No response

Incorrect protocol for ingress security groups

Describe the Bug

When using the allowed_security_groups or allowed_cidr_blocks inputs they are setting port 0 traffic as allowed. This doesn't work since any broker queue (ActiveMQ or RabbitMQ) isn't on this port. The rule descriptions indicate it should be allowing all traffic so this points to not using the "tcp" protocol.

Expected Behavior

I think the ingress security group rules need to change from protocol = "tcp" to protocol = "-1" like the egress rule does. Even this is a bit wide open IMO when it should be restricting traffic to only the ports needed but at least this will fix it.

Additional Context

Excerpt:

Setting protocol = "all" or protocol = -1 with from_port and to_port will result in the EC2 API creating a security group rule with all ports open.

Cannot specify multiple security rules of the same type for different porst

Describe the Bug

The cloudposse/mq-broker/aws module is using the cloudposse/mq-broker/aws with version 0.3.1 internally, which fails with below error when passing multiple ports for the same type

# Error
โ”‚ Error: [WARN] A duplicate Security Group rule was found on (sg-0d867c5b26555c769). This may be
โ”‚ a side effect of a now-fixed Terraform issue causing two security groups with
โ”‚ identical attributes but different source_security_group_ids to overwrite each
โ”‚ other in the state. See https://github.com/hashicorp/terraform/pull/2376 for more
โ”‚ information and instructions for recovery. Error: InvalidPermission.Duplicate: the specified rule "peer: 0.0.0.0/0, ALL, ALLOW" already exists
โ”‚       status code: 400, request id: 9573b001-d97f-490d-a18c-0f00c7d8e198
โ”‚
โ”‚   with module.mq_test.module.security_group.aws_security_group_rule.default["ingress--1-5671-5671-9c87e5e1ed040a443ce1ac8e6d6cf159"],
โ”‚   on .terraform/modules/mq_test.security_group/main.tf line 41, in resource "aws_security_group_rule" "default":
โ”‚   41: resource "aws_security_group_rule" "default" {

Expected Behavior

Security group should be created with the specified rules

## Steps to Reproduce
Use below root module to deploy the resource passin `security_group_rules` argument
# root module call
module "mq_test" {
  source = "cloudposse/mq-broker/aws"
  version     = "0.15.0"
  [...]
  security_group_rules = [
    {
      type        = "ingress"
      from_port   = 5671
      to_port     = 5671
      protocol    = "-1"
      cidr_blocks = ["0.0.0.0/0"]
      description = "Allow all outbound traffic"
    },
    {
      type        = "ingress"
      from_port   = 8883
      to_port     = 8883
      protocol    = "-1"
      cidr_blocks = ["0.0.0.0/0"]
      description = "Allow all outbound traffic"
    },
    {
      type        = "egress"
      from_port   = 5671
      to_port     = 5671
      protocol    = "-1"
      cidr_blocks = ["0.0.0.0/0"]
      description = "Allow all inbound traffic"
    }
  ]
}

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • OS: WSL
  • Version: Terraform v1.0.11
  • provider registry.terraform.io/hashicorp/aws v3.66.0

Issues with mq broker

aws_mq_broker.default.*.instances.0.endpoints.2 this does not works.

I see errors

  • module.amq.output.secondary_stomp_ssl_endpoint: Resource 'aws_mq_broker.default' does not have attribute 'instances.1.endpoints.2' for variable 'aws_mq_broker.default.*.instances.1.endpoints.2'
  • module.amq.output.primary_ip_address: Resource 'aws_mq_broker.default' does not have attribute 'instances.0.ip_address' for variable 'aws_mq_broker.default.*.instances.0.ip_address'
  • module.amq.output.secondary_ampq_ssl_endpoint: Resource 'aws_mq_broker.default' does not have attribute 'instances.1.endpoints.1' for variable 'aws_mq_broker.default.*.instances.1.endpoints.1'
  • module.amq.output.secondary_console_url: Resource 'aws_mq_broker.default' does not have attribute 'instances.1.console_url' for variable 'aws_mq_broker.default.*.instances.1.console_url'
  • module.amq.output.primary_mqtt_ssl_endpoint: Resource 'aws_mq_broker.default' does not have attribute 'instances.0.endpoints.3' for variable 'aws_mq_broker.default.*.instances.0.endpoints.3'
  • module.amq.output.primary_ssl_endpoint: Resource 'aws_mq_broker.default' does not have attribute 'instances.0.endpoints.0' for variable 'aws_mq_broker.default.*.instances.0.endpoints.0'
  • module.amq.output.primary_console_url: Resource 'aws_mq_broker.default' does not have attribute 'instances.0.console_url' for variable 'aws_mq_broker.default.*.instances.0.console_url'
  • module.amq.output.secondary_ip_address: Resource 'aws_mq_broker.default' does not have attribute 'instances.1.ip_address' for variable 'aws_mq_broker.default.*.instances.1.ip_address'
  • module.amq.output.primary_ampq_ssl_endpoint: Resource 'aws_mq_broker.default' does not have attribute 'instances.0.endpoints.1' for variable 'aws_mq_broker.default.*.instances.0.endpoints.1'
  • module.amq.output.primary_wss_endpoint: Resource 'aws_mq_broker.default' does not have attribute 'instances.0.endpoints.4' for variable 'aws_mq_broker.default.*.instances.0.endpoints.4'
  • module.amq.output.primary_stomp_ssl_endpoint: Resource 'aws_mq_broker.default' does not have attribute 'instances.0.endpoints.2' for variable 'aws_mq_broker.default.*.instances.0.endpoints.2'
  • module.amq.output.secondary_mqtt_ssl_endpoint: Resource 'aws_mq_broker.default' does not have attribute 'instances.1.endpoints.3' for variable 'aws_mq_broker.default.*.instances.1.endpoints.3'
  • module.amq.output.secondary_wss_endpoint: Resource 'aws_mq_broker.default' does not have attribute 'instances.1.endpoints.4' for variable 'aws_mq_broker.default.*.instances.1.endpoints.4'
  • module.amq.output.secondary_ssl_endpoint: Resource 'aws_mq_broker.default' does not have attribute 'instances.1.endpoints.0' for variable 'aws_mq_broker.default.*.instances.1.endpoints.0'

MQ Broker should be recreate when id for SG changed

Describe the Bug

โ•ท
โ”‚ Error: updating MQ Broker (b-f9764a70-79ab-41de-ba60-2f722296ba50) security groups: BadRequestException: Changing security groups is not supported for RabbitMQ brokers.
โ”‚ {
โ”‚   RespMetadata: {
โ”‚     StatusCode: 400,
โ”‚     RequestID: "52d88252-71f0-4800-9c41-aa8455b174bf"
โ”‚   },
โ”‚   ErrorAttribute: "securityGroups",
โ”‚   Message_: "Changing security groups is not supported for RabbitMQ brokers."
โ”‚ }
โ”‚ 
โ”‚   with module.rabbitmq.aws_mq_broker.default[0],
โ”‚   on ../../modules/mq/main.tf line 89, in resource "aws_mq_broker" "default":
โ”‚   89: resource "aws_mq_broker" "default" {
โ”‚ 
โ•ต

Expected Behavior

id for security group don't change, or recreate rabbitMQ broker whe security_id was change

Steps to Reproduce

  1. Create rabbitmq
  2. Create sq
  3. add new SQ to rabbitmq by variable allowed_security_group_ids
  4. apply changes

Screenshots

No response

Environment

  • LINUX
  • Terraform v1.3.6
  • Module: 3.1.0

Additional Context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.