Cameron Ezell

Hosting Mattermost on AWS

I recently installed the open-source Slack alternative Mattermost on a personal t2.micro Ubuntu instance in AWS. So far, I love it and thought I would share my experiences in using EC2, RDS, and S3 to host the application.

Mattermost has their own install guide which is pretty thorough and very helpful. By using a db.t2.micro RDS instance (free tier!) as the database server, it actually simplifies many of the steps.

  1. Launch an Ubuntu instance in EC2. While it launches...

  2. Launch a PostgreSQL RDS instance. Make sure to take note of the master username and password you specify. In the database options, name the database "mattermost".

  3. Verify that you have the correct inbound/outbound settings for your EC2 and RDS instance security groups.

    Your EC2 instance will of course need to have inbound ports 80/443 open as well as 22 for SSH from your IP only. The outbound settings will look like this:

    Outbound EC2 ports
    80/443 are open to update the server. 485 is open so Mattermost can send emails over SMTP. 5432 is open only to the database's security group.

    Your RDS instance will only need inbound access on 5432 from the security group of the EC2 instance:

    Outbound EC2 ports

  4. In a terminal window or with Putty, SSH to your EC2 instance and create a new user such as 'mattermost' with limited privileges

Example:

sudo useradd mattermost -m

sudo passwd mattermost

  1. Referencing the Mattermost install guide, download the Mattermost server by typing
    wget https://releases.mattermost.com/X.X.X/mattermost-team-X.X.X-linux-amd64.tar.gz
    where X.X.X is the latest Mattermost release version.

  2. Unzip the Mattermost server by typing tar -xvzf mattermost-team-X.X.X-linux-amd64.tar.gz

  3. At this point in the install guide it mentions creating a location on the server for storing files. We're hosting this on AWS, so let's use S3 instead! Go ahead and create a new S3 bucket. S3 buckets need a globally unique name so do something like <your-domain-name>-mattermost-media. We will reference the bucket later in the configuration.

  4. You may want to create a user with its own access key in IAM at this point that only has access to the S3 bucket you've created. You'll need this access key in order for Mattermost to read and write to the bucket.

  5. Use your favorite text editor to open ~/mattermost/config/config.json and once again reference the install guide (Step 7) to make the necessary modifications.

Under the DataSource replace mmuser and mmuser_password with the credentials you specified during the creation of your PostgreSQL RDS instance.

Again, under the DataSource replace 10.10.10.1 from the install guide with the endpoint address for your RDS instance.

Save and close the file, we'll make some more changes later in the admin console.

  1. Follow steps 8 & 9 in the install guide to test and start the Mattermost server. Once you're up and running, login to the Mattermost server and navigate to the System Console.

  2. Under File Settings in the System Console, change Store Files In to Amazon S3. Add your Access Keys that have permissions to the bucket you created earlier. Add your bucket name and specify the region it sits in (e.g. us-west-1). Save your settings.

  3. Another AWS service we can utilize is SES in order to send emails to users. Under the SES service, click on Domains and walk through the steps in order to verify your domain name. This should involve configuring the DNS settings for your domain name and adding a TXT entry. I use Google Domains but you could also use Route 53 for yet another(!) AWS service in this guide.

  4. Once AWS has verified your domain, click on SMTP Settings and create your SMTP credentials. If you've already done this before, you can use your existing credentials.

  5. In the Mattermost system console, update your Email Settings to look like this:

    Outbound EC2 ports
    Note that your SMTP Server may be in a different region than mine.

  6. At this point you should have a Mattermost server running on an EC2 instance with a PostgreSQL RDS instance and an S3 bucket for file storage!

If you run into any roadblocks or if something seems unclear, please comment below.

Update 1/9/2017:

I'd like to thank reader Rob for providing me with the following insight: He was using a postgresql RDS instance like myself, but had issues starting Mattermost via systemctl until he removed all postgres dependencies mattermost.service from systemd. If anyone else runs into a similar issue, give this a shot!

tech aws mattermost