Commit 02398750 authored by Nicky White's avatar Nicky White

Terraform upgrade 0.12

parent de9f3ac3
Pipeline #8345 failed with stage
in 15 seconds
......@@ -93,13 +93,13 @@ data "aws_iam_policy_document" "trust" {
resource "aws_iam_role_policy" "main" {
name = "lambda_ebs_snapshots"
role = "${aws_iam_role.main.id}"
policy = "${data.aws_iam_policy_document.policy.json}"
role = aws_iam_role.main.id
policy = data.aws_iam_policy_document.policy.json
}
resource "aws_iam_role" "main" {
name = "lambda_ebs_snapshots"
assume_role_policy = "${data.aws_iam_policy_document.trust.json}"
assume_role_policy = data.aws_iam_policy_document.trust.json
}
#############################################################################################################
......@@ -108,19 +108,19 @@ resource "aws_iam_role" "main" {
resource "aws_lambda_function" "main" {
filename = "${path.module}/lambda_ebs_snapshots.zip"
function_name = "lambda_ebs_snapshots"
role = "${aws_iam_role.main.arn}"
role = aws_iam_role.main.arn
handler = "lambda_ebs_snapshots.lambda_handler"
timeout = "300"
runtime = "python2.7"
source_code_hash = "${base64sha256(file("${path.module}/lambda_ebs_snapshots.zip"))}"
source_code_hash = filebase64sha256("${path.module}/lambda_ebs_snapshots.zip")
environment {
variables = {
MIN_RETENTION_COUNT = "${var.min_retention_count}"
DEFAULT_RETENTION_DAYS = "${var.default_retention_days}"
SNAPSHOT_TAG = "${var.snapshot_tag}"
RETENTION_TAG = "${var.retention_tag}"
DELETE_TAG = "${var.delete_tag}"
MIN_RETENTION_COUNT = var.min_retention_count
DEFAULT_RETENTION_DAYS = var.default_retention_days
SNAPSHOT_TAG = var.snapshot_tag
RETENTION_TAG = var.retention_tag
DELETE_TAG = var.delete_tag
}
}
}
......@@ -128,9 +128,9 @@ resource "aws_lambda_function" "main" {
resource "aws_lambda_permission" "main" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.main.arn}"
function_name = aws_lambda_function.main.arn
principal = "events.amazonaws.com"
source_arn = "${aws_cloudwatch_event_rule.main.arn}"
source_arn = aws_cloudwatch_event_rule.main.arn
}
#############################################################################################################
......@@ -139,11 +139,12 @@ resource "aws_lambda_permission" "main" {
resource "aws_cloudwatch_event_rule" "main" {
name = "lambda_ebs_snapshots_nightly"
description = "Run EBS snapshot function each morning"
schedule_expression = "${var.cloudwatch_schedule}"
schedule_expression = var.cloudwatch_schedule
}
resource "aws_cloudwatch_event_target" "main" {
rule = "${aws_cloudwatch_event_rule.main.name}"
arn = "${aws_lambda_function.main.arn}"
target_id = "${aws_lambda_function.main.function_name}"
rule = aws_cloudwatch_event_rule.main.name
arn = aws_lambda_function.main.arn
target_id = aws_lambda_function.main.function_name
}
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