DEV Community

Maureen Chebet
Maureen Chebet

Posted on

Port Forwarding to Amazon MQ

Image description
Overview
RabbitMQ is a powerful message broker widely used in modern applications for handling message queues. However, ensuring the security of your RabbitMQ instance is crucial, especially in a production environment. One way to enhance security is by deploying RabbitMQ in a private subnet. In this article, we'll explore how to set up a private RabbitMQ instance on AWS and enable access to it securely using port forwarding through AWS Systems Manager (SSM) Agent.

Prerequisites

  • An AWS account
  • Amazon MQ.

Install and Configure SSM Agent

Depending on your OS, download ssm agent here

Configure awscli using either of the following:
a) aws configure
Image description

b) export sso credentials
Image description

Start port forwarding session:
Linux & MacOS

aws ssm start-session \
    --target instance-id \
    --document-name AWS-StartPortForwardingSessionToRemoteHost \
    --parameters '{"host":["my.example.mq.eu-west-1.amazonaws.com"],"portNumber":["443"], "localPortNumber":["4000"]}'
Enter fullscreen mode Exit fullscreen mode

Windows

aws ssm start-session ^
    --target instance-id ^
    --document-name AWS-StartPortForwardingSessionToRemoteHost ^
    --parameters host="my.example.us-east-2.rds.amazonaws.com",portNumber="443",localPortNumber="4000"
Enter fullscreen mode Exit fullscreen mode

You can use a different port other than 4000

In a separate tab open /etc/hosts with vim or nano and the following line.

127.0.0.1          my.example.mq.eu-west-1.amazonaws.com
Enter fullscreen mode Exit fullscreen mode

Note: Please change my.example.mq.eu-west-1.amazonaws.com. You can get it as shown:
Image description

Navigate to your browser:
Image description

Conclusion
You are now able to access your broker outside the VPC from your local browser.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up