This repository have files to launch Redash and Redash slack bot on AWS ready for production.
Cloudformation templates which referred this repository
These cfn templates set up VPC, security groups, ALB and ECS cluster.
redash-app.yml defines necessary resources specific to Redash application, such as RDS(Postgres), ElastiCache(Redis), ECS service and ALB listener etc.
There are docker-compose.yml
and ecs-params.yml
each for Redash app and redash bot.
As described below, until you explicitly set a value true to launch a redash bot, no related resource will be created.
You should be charged according to the size of instances and duration you run the stack
- Redash App ECS: t3.medium
- Redash Bot ECS: t2.micro
- RDS: db.t2.micro
- Cache: cache.t2.small
- etc..
You are supposed to have domain managed by Route53 and ACM for it. And http request to the domain will be redirected to https by ALB.
- domain for redash in your mind managed on Route53 e.g. redash.example.com
- ACM SSL certification on certification for the Redash domain above
In order to debug deeply in case any issues happens and to operate adhoc commands directly (e.g. migration of database), EC2 instances of Redash app are supposed to be launched in public subnet.
Make sure you have a key file like example.pem to connect to the EC2 instances.
Please note you have to modify the security group's rule attached to the EC2 instances to allow ssh connection, which is disabled by default for security.
ssh -i /path/to/example.pem ec2-user@xxxx.xxxx.xxx.xxx
The steps assumes you are launching Redash for staging
environment. You can replace staging
into production
or whatever you like.
- Decide a name of this Cloudformation cluster and update
ecs-params-redash-app.yml
andecs-params-redash-bot.yml
with the name - Set up a string for Redash database with
RedashDbPassword
Name in AWS Systems Manager -> Parameter Store.- The Value you set there will be used as password of RDS Postgres instance.
- Update
.env.staging
$ cp .env.example .env.staging
and edit it.- Set your primary AWS region in
AWS_REGION
. - Create a CloudWatch log group in AWS CloudWatch Log console and fill
AWS_LOG_GROUP
with the name of the log group.- e.g. ecs-redash
- For email settings, if you use AWS SES to send email, this topic is good to read.
- You can get a SMTP credential by follwing this and fill
REDASH_MAIL_USERNAME
andREDASH_MAIL_PASSWORD
.
- You can get a SMTP credential by follwing this and fill
- If you want to set your own environment variables for Redash, see this doc and populate whatever values you want in
.env
.
- Install ecs-cli by following this and create a task definition of Redash app ECS service.
- Decide a name of cloudformation stack which you will create and keep it in your mind.
- Update ecs-params-redash-app.yml with the name of cloudformation stack.
- cp .env.staging .env && ecs-cli compose --project-name redash-app-staging --ecs-params ecs-params-redash-app.yml -f docker-compose-redash-app.yml create
- Create a Cloudformation from AWS Web console with the name you have decided
- Upload files under a S3 bucket. And put the URL of S3 bucket in
TemplateBaseURL
parameter of the stack. - Check the ARN of the task definition you created before in AWS ECS console and put it in
RedashAppTaskDefinitionArn
parameter of the stack.- e.g.
arn:aws:ecs:ap-northeast-1:0000000000:task-definition/redash-app-staging:1
- e.g.
- Supply other parameters with a proper format by checking the default value and the description of each
- Keep
ShouldRedashBotLaunched
false
still
- Access your <> to confirm redash is now running.
- If you don't need a Redash slack bot running, you have done! The below steps is only for those who want to run the bot.
- When the redash app get ready, set these variables in
.env
- REDASH_API_KEY
- Access https://{YOUR_REDASH_HOST}/users/me and retrive a API key.
- SLACK_BOT_TOKEN
- Token for the slack bot. e.g. xoxb-xxxxxxxxxxxxxxxxxxxxxxxxxxxx
- REDASH_API_KEY
- Create a task definition of Redash slack bot ECS service.
- ecs-cli compose --project-name redash-bot-staging --ecs-params ecs-params-redash-bot.yml -f docker-compose-redash-bot.yml create
- Update the Cloudformation stack's template.
ShouldRedashBotLaunched
is nowtrue
.- Fill
RedashBotTaskDefinitionArn
with the ARN of the newly created task definition for Redash slack bot in Step #8.
https://docs.aws.amazon.com/ja_jp/AmazonECS/developerguide/cmd-ecs-cli-compose-parameters.html https://docs.aws.amazon.com/ja_jp/AmazonECS/developerguide/cmd-ecs-cli-compose-ecsparams.html https://discuss.redash.io/t/redash-on-aws-ecs/1124/3 https://github.com/yamitzky/redashbot https://redash.io/help/open-source/admin-guide/env-vars-settings/