Last active
August 19, 2017 18:44
-
-
Save vovayartsev/d842a7dfcbb21c784bd637930e3b94c2 to your computer and use it in GitHub Desktop.
Terraform stack example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
coreos: | |
units: | |
- name: metabase.service | |
command: start | |
enable: true | |
content: | | |
[Unit] | |
Description=Metabase analytics dashboard | |
After=docker.service | |
[Service] | |
Slice=machine.slice | |
ExecStartPre=/usr/bin/mkdir -p /home/core/metabase-data | |
ExecStart=/usr/bin/rkt run \ | |
--insecure-options=image \ | |
--trust-keys-from-https \ | |
--port=3000-tcp:80 \ | |
docker://metabase/metabase | |
KillMode=mixed | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AWS-specific parameters | |
provider "aws" { | |
region = "us-east-1" | |
} | |
terraform { | |
backend "s3" { | |
bucket = "castle-terraform-infrastructure" | |
key = "metabase" | |
region = "us-east-1" | |
} | |
} | |
# Running EC2 instance | |
data "template_file" "cloudconfig" { | |
template = "${file("cloudconfig.tpl")}" | |
vars { ... } | |
} | |
resource "aws_instance" "metabase" { | |
ami = "ami-919e8987" | |
instance_type = "t2.small" | |
user_data = "${data.template_file.cloudconfig.rendered}" | |
key_name = "...." | |
} | |
# Service Discovery: adjusting metabase.castle.co record automatically | |
provider "cloudflare" { | |
email = "admin@example.com" | |
} | |
resource "cloudflare_record" "my_dns_record" { | |
domain = "example.com" | |
name = "metabase" | |
value = "${aws_instance.metabase.public_ip}" | |
type = "A" | |
proxied = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment