Commit ee9d55e8 authored by Cameron McFarland's avatar Cameron McFarland

Moving EOF piped content into seperate files for easy editing.

parent c3f970a1
......@@ -13,17 +13,41 @@ provider "aws" {
version = "~> 1.41"
}
// User Data Templates
// Data Templates
data "template_file" "user_data_collector" {
template = "${file("${path.module}/collector-user-data.sh")}"
template = "${file("${path.module}/templates/collector-user-data.sh")}"
}
data "template_file" "user_data_enricher" {
template = "${file("${path.module}/enricher-user-data.sh")}"
template = "${file("${path.module}/templates/enricher-user-data.sh")}"
}
data "template_file" "user_data_s3loader" {
template = "${file("${path.module}/s3loader-user-data.sh")}"
template = "${file("${path.module}/templates/s3loader-user-data.sh")}"
}
data "template_file" "iam_policy_collector" {
template = "${file("${path.module}/templates/iam_policy_collector.json")}"
}
data "template_file" "iam_policy_enricher" {
template = "${file("${path.module}/templates/iam_policy_enricher.json")}"
}
data "template_file" "iam_policy_s3loader" {
template = "${file("${path.module}/templates/iam_policy_s3loader.json")}"
}
data "template_file" "iam_role_collector" {
template = "${file("${path.module}/templates/iam_role_collector.json")}"
}
data "template_file" "iam_role_enricher" {
template = "${file("${path.module}/templates/iam_role_enricher.json")}"
}
data "template_file" "iam_role_s3loader" {
template = "${file("${path.module}/templates/iam_role_s3loader.json")}"
}
// Policies
......@@ -32,33 +56,7 @@ resource "aws_iam_policy" "snowplow_collector_policy" {
name = "snowplow-collector-policy"
path = "/"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"cloudwatch:PutMetricData"
],
"Resource": [
"*"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"kinesis:*"
],
"Resource": [
"*"
]
}
]
}
EOF
policy = "${data.template_file.iam_policy_collector.rendered}"
}
resource "aws_iam_policy" "snowplow_enricher_policy" {
......@@ -66,43 +64,7 @@ resource "aws_iam_policy" "snowplow_enricher_policy" {
name = "snowplow-enricher-policy"
path = "/"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"cloudwatch:PutMetricData"
],
"Resource": [
"*"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"dynamodb:*"
],
"Resource": [
"arn:aws:dynamodb:us-east-1:855262394183:table/SnowplowEnrich-gitlab-us-east-1"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"kinesis:*"
],
"Resource": [
"*"
]
}
]
}
EOF
policy = "${data.template_file.iam_policy_enricher.rendered}"
}
resource "aws_iam_policy" "snowplow_s3loader_policy" {
......@@ -110,87 +72,13 @@ resource "aws_iam_policy" "snowplow_s3loader_policy" {
name = "snowplow-s3loader-policy"
path = "/"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"cloudwatch:PutMetricData"
],
"Resource": [
"*"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::gitlab-com-snowplow-test-one/*"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"dynamodb:*"
],
"Resource": [
"arn:aws:dynamodb:us-east-1:855262394183:table/SnowplowS3Loader-gitlab-us-east-1"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"kinesis:*"
],
"Resource": [
"*"
]
}
]
}
EOF
policy = "${data.template_file.iam_policy_s3loader.rendered}"
}
// Roles
resource "aws_iam_role" "snowplow_collector_role" {
name = "snowplow-collector-role"
assume_role_policy = <<EOF
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":"ec2.amazonaws.com"
},
"Action":"sts:AssumeRole"
},
{
"Effect":"Allow",
"Principal":{
"Service":"ecs-tasks.amazonaws.com"
},
"Action":"sts:AssumeRole"
},
{
"Effect":"Allow",
"Principal":{
"Service":"ecs.amazonaws.com"
},
"Action":"sts:AssumeRole"
}
]
}
EOF
name = "snowplow-collector-role"
assume_role_policy = "${data.template_file.iam_role_collector.rendered}"
tags = {
environment = "SnowPlow"
......@@ -198,22 +86,8 @@ resource "aws_iam_role" "snowplow_collector_role" {
}
resource "aws_iam_role" "snowplow_enricher_role" {
name = "snowplow-enricher-role"
assume_role_policy = <<EOF
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":"ec2.amazonaws.com"
},
"Action":"sts:AssumeRole"
}
]
}
EOF
name = "snowplow-enricher-role"
assume_role_policy = "${data.template_file.iam_role_enricher.rendered}"
tags = {
environment = "SnowPlow"
......@@ -221,22 +95,8 @@ resource "aws_iam_role" "snowplow_enricher_role" {
}
resource "aws_iam_role" "snowplow_s3loader_role" {
name = "snowplow-s3loader-role"
assume_role_policy = <<EOF
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":"ec2.amazonaws.com"
},
"Action":"sts:AssumeRole"
}
]
}
EOF
name = "snowplow-s3loader-role"
assume_role_policy = "${data.template_file.iam_role_s3loader.rendered}"
tags = {
environment = "SnowPlow"
......@@ -651,6 +511,7 @@ resource "aws_lb" "snowplow_lb" {
}
}
// EC2 Load Balancer Listener
resource "aws_lb_listener" "snowplow_collector_lb_listener" {
load_balancer_arn = "${aws_lb.snowplow_lb.arn}"
port = "443"
......
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"cloudwatch:PutMetricData"
],
"Resource": [
"*"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"kinesis:*"
],
"Resource": [
"*"
]
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"cloudwatch:PutMetricData"
],
"Resource": [
"*"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"dynamodb:*"
],
"Resource": [
"arn:aws:dynamodb:us-east-1:855262394183:table/SnowplowEnrich-gitlab-us-east-1"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"kinesis:*"
],
"Resource": [
"*"
]
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"cloudwatch:PutMetricData"
],
"Resource": [
"*"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::gitlab-com-snowplow-test-one/*"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"dynamodb:*"
],
"Resource": [
"arn:aws:dynamodb:us-east-1:855262394183:table/SnowplowS3Loader-gitlab-us-east-1"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": [
"kinesis:*"
],
"Resource": [
"*"
]
}
]
}
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":"ec2.amazonaws.com"
},
"Action":"sts:AssumeRole"
},
{
"Effect":"Allow",
"Principal":{
"Service":"ecs-tasks.amazonaws.com"
},
"Action":"sts:AssumeRole"
},
{
"Effect":"Allow",
"Principal":{
"Service":"ecs.amazonaws.com"
},
"Action":"sts:AssumeRole"
}
]
}
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":"ec2.amazonaws.com"
},
"Action":"sts:AssumeRole"
}
]
}
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":"ec2.amazonaws.com"
},
"Action":"sts:AssumeRole"
}
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment