Getting started
Last updated
Was this helpful?
Last updated
Was this helpful?
Follow this simple guide to deploy a MySQL and a Redis instance on your AWS account. By the end of this guide, you'll have a MySQL instance running on RDS and a Redis cluster on Elasticache.What you'll need:
An with the credentials stored in your local machine. You could create an AWS profile that uses those credentials and would make things easier. More details on the . If you already have an AWS account profile set up locally, you can skip this.
installed locally. You can follow the to do that, or if you already have Terraform installed, feel free to skip this part.
to help us install stackmate.
Your favorite text editor, terminal and a working internet connection.
Here's what you'll get after you've finished this guide:
A instance on RDS, within the AWS free tier to help run in sane costs
A on Elasticache, within the AWS free tier
A VPC and Internet Gateway to keep your database instances isolated and secure
Your credentials securely stored on AWS Secrets Manager
First, we need to create a configuration file for stackmate, under its default location which is .stackmate/config.yml
. You can start by copying the code specified in this on the . Our configuration file would then look something like this:
Let's now prefix the AWS profile to the stackmate deploy command and we're ready to go!
This will do the following:
Install stackmate cli locally (if it's not available already)
Load the AWS profile specified
Set up our infrastructure on the AWS account specified.
You'll be getting output on your terminal regarding the progress and once it's done, you'll get the endpoints you can connect to. For example:
Your infrastructure is now deployed and ready to be used!
To be able to use an S3 bucket in our stackmate configuration with locking, the following needs to exist in advance:
The directory we used and its contents should now be safe to delete
You can use the value in the "Outputs" sections above to configure stackmate:
Our next deployments will store the state in S3 and the state will be locked in DynamoDB
Next steps
You can add more services to your configuration
Quick note: By default your resources are deployed in a meaning that they're isolated from the outside world but all resources deployed by Stackmate, can connect with each other. If you need to allow connections from a resource that's not deployed by Stackmate, consider adding the externalLinks
attribute to the service as documented in the section for environments
.
Terraform requires a file to be present, so that it knows what the desired state of your infrastructure will be every time. For the sake of this guide, we will be storing our state files locally, but at the end of this guide, we'll see how we can use an AWS S3 bucket to securely store our states in.
Please note that as described in , we should NEVER commit our state to version control and this is why the directory is set outside our repository. Now let's go ahead and create the directory:
Use your favorite editor to view an existing, or add a new AWS profile on your AWS configuration. As an example, we'll be using an AWS profile named stackmate-user
. More details on the .
Deploying your state on an S3 bucket, allows your team to access it centrally, makes sure it's always available and handles versioning and locking. The benefits and the process Terraform uses is described in this .
An with versioning and no public access
A table to be used for locking
You can create these resources manually, as described in numerous tutorials (for example one) but if you're already familiar with Terraform, we have prepared a for you that you can use to create the resources described above. Here's how:
creates the state bucket and lock table for you and handles AWS profiles automatically, once it securely access your AWS account. We offer a trial of 7 days and no credit card is required.
You can check out the additional configuration in or and update the service section on .stackmate/config.yml
accordingly
You can add more to your project, for example a staging
environment
stackmate
globally to avoid using npx @stackmate/stackmate
Tweet about , raise an , or view our .