Hi @apparentlymart !
Thanks so much for taking time below is the full error code I recieved.
Error: Invalid function argument
on ../my-module/lambda.tf line 37, in data "template_file" "iam_policy":
37: template = file("${path.module}/local/iam_policy.json")
|----------------
| path.module is "../my-module"
Invalid value for "path" parameter: no file exists at
../my-module/local/iam_policy.json; this function works only with files
that are distributed as part of the configuration source code, so if this file
will be created by a resource in this configuration you must instead obtain
this result from an attribute of that resource.`
I upgraded a mirrored enviornment with different permissions and was able to run my code with TF 0.14…
I am more curious on how or what this error means. My guess now for the community is it had to do with permissions? Here was my Lambda.tf portion of my IAM role and template I used that I think may have caused this strange error…
resource "aws_iam_role" "lambda_iam_role" {
name = var.lambda_role_name
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
tags = merge(local.common_tags, {})
}
resource "aws_iam_policy" "iam_policy" {
name = var.lambda_role_name
policy = data.template_file.iam_policy.rendered
}
resource "aws_iam_role_policy_attachment" "iam_policy_attachment" {
depends_on = [
aws_iam_role.lambda_iam_role,
aws_iam_policy.iam_policy
]
role = aws_iam_role.lambda_iam_role.name
policy_arn = aws_iam_policy.iam_policy.arn
}
data "template_file" "iam_policy" {
template = file("${path.module}/local/iam_policy.json")
vars = {
account_id = var.account_id
region = var.region
bucket_name = var.bucket_name
lambda_role_name = var.lambda_role_name
}
}