data "aws_iam_policy_document" "assume_role_policy" { statement { effect = "Allow" actions = ["sts:AssumeRole"] principals { type = "Service" identifiers = ["lambda.amazonaws.com"] } } } resource "aws_iam_role" "role_for_lambda" { name = var.role_name assume_role_policy = data.aws_iam_policy_document.assume_role_policy.json depends_on = [data.aws_iam_policy_document.assume_role_policy] } resource "aws_iam_role_policy" "lambda_policy" { name = "lambda_policy" role = aws_iam_role.role_for_lambda.id policy = <