Skip to content

Instantly share code, notes, and snippets.

@lovemycodesnippets
Created February 13, 2025 19:28
Show Gist options
  • Save lovemycodesnippets/bf0ae29d2618b5bbd8169f6dd56307bb to your computer and use it in GitHub Desktop.
Save lovemycodesnippets/bf0ae29d2618b5bbd8169f6dd56307bb to your computer and use it in GitHub Desktop.
From the article "Can AI Generate Functional Terraform?"
resource "aws_iam_policy" "lambda_s3" {
name = "lambda_s3_policy"
policy = jsonencode({
Version = "2012-10-17",
Statement = [{
Effect = "Allow",
Action = ["s3:GetObject", "s3:PutObject"],
Resource = "${aws_s3_bucket.example.arn}/*"
}]
})
}
resource "aws_iam_role_policy_attachment" "lambda_attach" {
role = aws_iam_role.lambda_exec.name
policy_arn = aws_iam_policy.lambda_s3.arn
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment