Skip to content

Instantly share code, notes, and snippets.

View carlosescura's full-sized avatar

Carlos Escura carlosescura

  • RSS
  • Barcelona, Spain
View GitHub Profile
@carlosescura
carlosescura / packer_redash.json
Created June 3, 2019 13:37
redash-guide-packer.json
{
"variables": {
"name": "redash",
"ami_name": "redash",
"redash_version": "7.0.0",
"account_id": null
},
"builders": [
{
"type": "amazon-ebs",
version: '2'
x-redash-service: &redash-service
# Get the latest image available from https://hub.docker.com/r/redash/redash/tags
image: redash/redash:7.0.0.b18042
# Load ENV vars as file
env_file: /opt/redash/env
restart: always
services:
server:
<<: *redash-service
#!/bin/sh
set -eux
REDASH_BASE_PATH=/opt/redash
create_directories() {
if [[ ! -e $REDASH_BASE_PATH ]]; then
sudo mkdir -p $REDASH_BASE_PATH
fi
#!/bin/sh
set -e
echo 'Cleaning up after bootstrapping...'
rm -rf /tmp/*
cat /dev/null > ~/.bash_history
history -c
exit
|- packer/
| | - redash.json
| | /packer-redash/
| | | /files/
| | | | - docker-compose.yml
| | |
| | | /shell/
| | | | - bootstrap.sh
| | | | - cleanup.sh
/* subnet group used by rds */
resource "aws_db_subnet_group" "rds_subnet_group" {
name = "redash-rds-subnet-group"
description = "Redash RDS subnet group"
subnet_ids = ["${var.rds_subnet_ids}"]
tags {
Environment = "${var.environment}"
}
}
resource "aws_elasticache_subnet_group" "redis_subnet_group" {
name = "redash-redis-subnet-group"
description = "Redash Redis subnet group"
subnet_ids = ["${var.redis_subnet_ids}"]
}
resource "aws_elasticache_cluster" "redis" {
cluster_id = "redash-redis-cluster"
engine = "redis"
node_type = "${var.redis_instance_class}"
resource "aws_acm_certificate" "ssl_cert" {
domain_name = "redash.${var.main_domain}"
validation_method = "DNS"
}
resource "aws_route53_record" "cert_validation_dns_record" {
name = "${aws_acm_certificate.ssl_cert.domain_validation_options.0.resource_record_name}"
type = "CNAME"
zone_id = "${var.main_domain_zone_id}"
records = ["${aws_acm_certificate.ssl_cert.domain_validation_options.0.resource_record_value}"]
resource "aws_elb" "redash_service_elb" {
name = "redash-service-lb"
subnets = ["${var.loadbalancer_subnets}"]
security_groups = ["${aws_security_group.redash_service_loadbalancer_sg.id}"]
instances = ["${aws_instance.redash_service_ec2.id}"]
listener {
instance_port = 80
instance_protocol = "http"
lb_port = 443
# Security Group for EC2 resources allowing only traffic from ELB
resource "aws_security_group" "redash_service_instances_sg" {
name = "redash-service-instances-sg"
description = "Redash Serving instancs Security Group"
vpc_id = "${var.vpc_id}"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"