From dc201a2beafc5a7742c72fc01cef2f6d668d1147 Mon Sep 17 00:00:00 2001 From: nitro Date: Thu, 13 Feb 2020 18:36:43 -0500 Subject: [PATCH] Update iam.tf --- iam.tf | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/iam.tf b/iam.tf index ec9d74d..938f62a 100644 --- a/iam.tf +++ b/iam.tf @@ -60,11 +60,10 @@ resource "aws_iam_policy" "logs" { policy = data.aws_iam_policy_document.logs[0].json } -resource "aws_iam_policy_attachment" "logs" { +resource "aws_iam_role_policy_attachment" "logs" { count = var.cloudwatch_logs ? 1 : 0 - name = "${var.function_name}-logs" - roles = [aws_iam_role.lambda.name] + role = aws_iam_role.lambda.name policy_arn = aws_iam_policy.logs[0].arn } @@ -94,11 +93,10 @@ resource "aws_iam_policy" "dead_letter" { policy = data.aws_iam_policy_document.dead_letter[0].json } -resource "aws_iam_policy_attachment" "dead_letter" { +resource "aws_iam_role_policy_attachment" "dead_letter" { count = var.dead_letter_config == null ? 0 : 1 - name = "${var.function_name}-dl" - roles = [aws_iam_role.lambda.name] + role = aws_iam_role.lambda.name policy_arn = aws_iam_policy.dead_letter[0].arn } @@ -129,11 +127,10 @@ resource "aws_iam_policy" "network" { policy = data.aws_iam_policy_document.network[0].json } -resource "aws_iam_policy_attachment" "network" { +resource "aws_iam_role_policy_attachment" "network" { count = var.vpc_config == null ? 0 : 1 - name = "${var.function_name}-network" - roles = [aws_iam_role.lambda.name] + role = aws_iam_role.lambda.name policy_arn = aws_iam_policy.network[0].arn } @@ -146,10 +143,9 @@ resource "aws_iam_policy" "additional" { policy = var.policy.json } -resource "aws_iam_policy_attachment" "additional" { +resource "aws_iam_role_policy_attachment" "additional" { count = var.policy == null ? 0 : 1 - name = var.function_name - roles = [aws_iam_role.lambda.name] + role = aws_iam_role.lambda.name policy_arn = aws_iam_policy.additional[0].arn }