Skip to content

Instantly share code, notes, and snippets.

@lovemycodesnippets
Created February 13, 2025 19:27
Show Gist options
  • Save lovemycodesnippets/ac3776b9e2847cdd86288298087379f8 to your computer and use it in GitHub Desktop.
Save lovemycodesnippets/ac3776b9e2847cdd86288298087379f8 to your computer and use it in GitHub Desktop.
From the article "Can AI Generate Functional Terraform?"
resource "aws_s3_bucket" "example" {
bucket = "example-bucket"
}
resource "aws_lambda_function" "example" {
function_name = "example_lambda"
s3_bucket = aws_s3_bucket.example.bucket
s3_key = "lambda_function.zip"
handler = "index.handler"
runtime = "python3.8"
role = aws_iam_role.lambda_exec.arn
}
resource "aws_iam_role" "lambda_exec" {
name = "lambda_exec_role"
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [{
Effect = "Allow",
Principal = { Service = "lambda.amazonaws.com" },
Action = "sts:AssumeRole"
}]
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment