Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
formated with terraform fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
tfhartmann committed Oct 12, 2017
1 parent f22223b commit d487819
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
39 changes: 20 additions & 19 deletions consulRdsCreateService.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,60 +30,61 @@ resource "aws_iam_role" "consul_rds" {
EOF
}


resource "aws_iam_role_policy_attachment" "xray_wo" {
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess"
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess"
}

resource "aws_iam_role_policy_attachment" "vpc_exec" {
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
}

resource "aws_iam_role_policy_attachment" "ec2_ro" {
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess"
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess"
}

resource "aws_iam_role_policy_attachment" "rds_ro" {
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/AmazonRDSReadOnlyAccess"
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/AmazonRDSReadOnlyAccess"
}

resource "aws_iam_role_policy_attachment" "lambda_ro" {
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/AWSLambdaReadOnlyAccess"
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/AWSLambdaReadOnlyAccess"
}

resource "aws_iam_role_policy_attachment" "lambda_basic_exec" {
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
role = "${aws_iam_role.consul_rds.name}"
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}

resource "aws_lambda_function" "consulRdsCreateService" {
filename = "${path.module}/files/rds/consulRdsCreateService.zip"
function_name = "consulRdsCreateService-${var.env}" # env var
function_name = "consulRdsCreateService-${var.env}" # env var
role = "${aws_iam_role.consul_rds.arn}"
handler = "consulRdsCreateService.lambda_handler"
source_code_hash = "${base64sha256(file("${path.module}/files/rds/consulRdsCreateService.zip"))}"
runtime = "python2.7"
timeout = "60"

vpc_config {
subnet_ids = ["${var.subnets}"]
security_group_ids = ["${var.rds_sg}"]
}

tracing_config {
mode = "Active"
}
}

resource "aws_lambda_permission" "rds_allow_cloudwatch" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.consulRdsCreateService.function_name}"
principal = "events.amazonaws.com"
source_arn = "${aws_cloudwatch_event_rule.consul_rds.arn}"
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.consulRdsCreateService.function_name}"
principal = "events.amazonaws.com"
source_arn = "${aws_cloudwatch_event_rule.consul_rds.arn}"
}

resource "aws_cloudwatch_event_rule" "consul_rds" {
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 3 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
variable "env" {}

variable "subnets" {
type = "list"
description = "List of VPC Subnets IDs used to do lambdas"
Expand All @@ -10,8 +11,8 @@ variable "rds_sg" {
}

variable "rds_vpc_ids" {
type = "list"
default = []
type = "list"
default = []
description = "List of VPC ID's the consulRdsCreateService lambda will attempt to discover RDS instances in. Defaults empty array"
}

Expand Down

0 comments on commit d487819

Please sign in to comment.