Commit 78e9af25 by Edward Zarecor

simple example to introduce terraform

parent 67137e97
This probably makes the most sense in a private repository, but I'm adding it here toyp kick-off the Jenkins site-speed integration. We can move it later.
Note that I've included the tfvars file intentionally as an example, but this would typically be git ignored.
Start by downloading and installing the terraform go binaries. Run
> terraform plan
from the sitespeed directory to see what would happen if this was run against and AWS account.
resource "aws_iam_policy" "topic_policy" {
name = "${var.environment}-${var.deployment}-${var.service}-sender"
path = "/"
description = "Sender policy"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"sns:Publish"
],
"Effect": "Allow",
"Resource": "${aws_sns_topic.build_requests.arn}"
}
]
}
EOF
}
resource "aws_sqs_queue" "build_requests" {
name = "${var.queue_name}"
delay_seconds = "${var.queue_delay_seconds}"
max_message_size = "${var.queue_max_message_size}"
message_retention_seconds = "${var.queue_message_retention_seconds}"
receive_wait_time_seconds = "${var.queue_receive_wait_time_seconds}"
}
resource "aws_sns_topic" "build_requests" {
name = "user-updates-topic"
}
resource "aws_sns_topic_subscription" "build_requests_sqs_target" {
topic_arn = "${aws_sns_topic.build_requests.arn}"
protocol = "sqs"
endpoint = "${aws_sqs_queue.build_requests.arn}"
}
environment = "prod"
deployment = "edx"
service = "jenkins"
# SQS variables
queue_name = "my-queue"
queue_delay_seconds = 90
queue_max_message_size = 2048
queue_message_retention_seconds = 86400
queue_receive_wait_time_seconds = 10
variable "environment" {}
variable "deployment" {}
variable "service" {}
variable "queue_name" {
default = "default-queue"
}
variable "queue_delay_seconds" {}
variable "queue_max_message_size" {}
variable "queue_message_retention_seconds" {}
variable "queue_receive_wait_time_seconds" {}
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