Forem Creators and Builders

Cover image for Forem AWS Setup on MacOS
Christina Gorton for Forem Core Team

Posted on • Updated on

Forem AWS Setup on MacOS

Introduction

In this guide you will learn how to set up your Forem self-host instance on AWS.
You will also set up DNS for your domain and restart Forem Traefik service to generate a TLS cert.

Prerequisites

Step 1- Installing Ansible Amazon AWS Collection

In this step you will install the necessary collection for AWS.
In your terminal make sure you are in the selfhost directory with:

cd selfhost
Enter fullscreen mode Exit fullscreen mode

Install the Ansible Amazon AWS collections with:

ansible-galaxy collection install amazon.aws community.aws
Enter fullscreen mode Exit fullscreen mode

Alternatively you can install all the cloud provider collections with:

ansible-galaxy collection install -r requirements.yml`
Enter fullscreen mode Exit fullscreen mode

This is useful if you want to try other cloud providers.

Step 2- Installing the AWS CLI version 2 Tool

In this step you will install the AWS CLI version 2 tool. You will use this tool to configure preset variables for the AWS provisioning target

First, download the latest version of the AWS CLI: https://awscli.amazonaws.com/AWSCLIV2.pkg

Click the downloaded file to launch the installer.

Follow the prompts in the installer to install the CLI to a recommended folder.

To see if the CLI installed properly, in your terminal type:

aws --version
Enter fullscreen mode Exit fullscreen mode

aws --version in MacOS terminal

You can see the full instructions for AWS CLI installation on a MacOS in the AWS docs.

Step 2- Installing Pip Modules

In this step you will install Boto modules. Boto is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python

In your terminal install Boto, Boto3, and Botocore pip modules with:

pip3 install boto boto3 botocore
Enter fullscreen mode Exit fullscreen mode

or you can run:

pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

Step 3- Creating an AWS IAM User

In this step you will create an AWS IAM user. You will also add permissions..

Navigate to your AWS Management Console

In the search bar type IAM and click the IAM option under "Services"
IAM option under "Services"

In the navigation pane, choose "Users"
navigate to Users in the menu

Click Add user to add a new user
Add new user

At minimum, add Admin permissions to your user.

Add Admin permissions

You do not need to set any tags at this time. Click Next: Review to review and then click Create user

Save your Access key ID and Secret Access Key to use in a later step.

Once your user is created, click on the user name to set up the necessary policies.

click user name to set up policies

Click Add permissions

Click Add permissions button

Click Attach existing policies directly.
Click Attach existing policies directly

Search for:

  • AmazonEC2FullAccess and check the box to add the policy
  • AmazonS3FullAccess and check the box to add the policy
  • AmazonVPCFullAccess and check the box to add the policy

Now that your IAM user is set up you can configure your profile with the AWS CLI

Step 4- Configuring forem-selfhost Profile

In this step you will configure your profile with the AWS CLI

In your terminal type:

aws configure --profile forem-selfhost
Enter fullscreen mode Exit fullscreen mode

When prompted add:

  • Your the access key you saved previously and hit enter
  • Your secret access key you saved and hit enter

Set the Default region name to: us-east-1

Set the Default output format to: json

Configure your forem-selfhost profile

Now you are ready to provision your AWS provider playbook.

Step 4- Provisioning the Playbook

In this step you will provision the AWS provider playbook to set up your Forem.

In your terminal type:

ansible-playbook -i inventory/forem/setup.yml playbooks/providers/aws.yml
Enter fullscreen mode Exit fullscreen mode

Note: If you run into the following error:
botocore error message
try using this command in your terminal instead:

``` bash ansible-playbook -i inventory/forem/setup.yml playbooks/providers/aws.yml -e ansible_python_interpreter=/usr/local/bin/python3



Once you run the command, you should see an output in your terminal similar to the code below with your community's domain name and IP address.



```bash
ok: [forem] => 
  msg:
  - The public IPv4 IP Address for www.creativecommunity.club is 54.221.141.133
  - Please add an A entry for www.creativecommunity.club that points to 54.221.141.133
  - 'Example:'
  - '    www.creativecommunity.club IN A 54.221.141.133'
  - 'Once you have DNS resolving to this EC2 instance please read the Forem Admin Docs: https://forem-admin.netlify.app/'
Enter fullscreen mode Exit fullscreen mode

Now you can set up an A record and point it to your public IPv4 IP Address

Step 5- Setting up DNS

In this step you will see an example of creating an A record in NameCheap and pointing it to the IP address that was outputted in the previous step. If you are not using NameCheap please refer to your own domain provider for how to set up DNS.

In the Advanced DNS section add an A record for your domain and subdomain.

Set the value to the IP address that was outputted after provisioning.

Set TTL to 1minute.
Advanced DNS in namecheap.com

Step 6- Restarting Forem Traefik Service

In this step you will reset Forem Traefik Service via SSH to generate a TLS cert.

In your terminal type:

ssh core@<SERVER IP ADDRESS>
Enter fullscreen mode Exit fullscreen mode

replacing with your community name.

Here is an example using a community name:
ssh core@ example

If prompted to continue, type yes into your terminal.

Once you have connected to your Forem server, type the following command:

sudo systemctl restart forem-traefik.service
Enter fullscreen mode Exit fullscreen mode

systemctl restart command in terminal

Now, you can navigate to your community domain. You should see a "Let's Start your Forem Journey" page.
You may need to wait a few minutes after running the Forem Traefik command.
Let's Start your Forem Journey page

Conclusion

Congratulations on setting up your first Forem!🎉

For next steps on how to configure your Forem please visit our Forem Admin Docs.

Discussion (0)