- Write a Terraform template to create the InsertMovie Lambda function resources.
Answer: Setup execution role for the Lambda function:
resource "aws_iam_role" "role" { name = "InsertMovieRole" assume_role_policy = "${file("assume-role-policy.json")}"}resource "aws_iam_policy" "cloudwatch_policy" { name = "PushCloudWatchLogsPolicy" policy = "${file("cloudwatch-policy.json")}"}resource "aws_iam_policy" "dynamodb_policy" { name = "ScanDynamoDBPolicy" policy = "${file("dynamodb-policy.json")}"}resource "aws_iam_policy_attachment" "cloudwatch-attachment" { name = "cloudwatch-lambda-attchment" roles = ["${aws_iam_role.role.name}"] policy_arn = "${aws_iam_policy.cloudwatch_policy.arn}"}resource "aws_iam_policy_attachment" "dynamodb-attachment" ...