@@ -2,11 +2,11 @@ terraform {
22 required_providers {
33 aws = {
44 source = " hashicorp/aws"
5- version = " ~> 5.57 .0"
5+ version = " ~> 6.19 .0"
66 }
77 }
88
9- required_version = " >= 0 .14.9 "
9+ required_version = " ~> 1 .14"
1010}
1111
1212data "aws_caller_identity" "current" {}
@@ -23,24 +23,24 @@ resource "aws_s3_bucket" "MySourceS3Bucket" {
2323
2424# Send notifications to SQS for all events in the bucket
2525resource "aws_s3_bucket_notification" "MySourceS3BucketNotification" {
26- bucket = aws_s3_bucket. MySourceS3Bucket . id
26+ bucket = aws_s3_bucket. MySourceS3Bucket . id
2727
2828 queue {
29- queue_arn = aws_sqs_queue. MyHandlerQueue . arn
30- events = [
29+ queue_arn = aws_sqs_queue. MyHandlerQueue . arn
30+ events = [
3131 " s3:ObjectCreated:*"
3232 ]
3333 filter_suffix = " .jpg"
3434 }
35-
35+
3636}
3737
3838# ################################################################
3939# SQS - Queue
4040# ################################################################
4141# Create SQS - Queue
4242resource "aws_sqs_queue" "MyHandlerQueue" {
43- name = " s3-sqs-lambda-tf-SQSResizerQueue"
43+ name = " s3-sqs-lambda-tf-SQSResizerQueue"
4444}
4545
4646# Create SQS - Policy
@@ -105,7 +105,7 @@ resource "aws_iam_role" "MyHandlerFunction-Role" {
105105 name = " s3-sqs-lambda-tf-MyHandlerFunction-Role"
106106
107107 assume_role_policy = jsonencode ({
108- Version = " 2012-10-17"
108+ Version = " 2012-10-17"
109109 Statement = [
110110 {
111111 Action = " sts:AssumeRole"
@@ -120,41 +120,41 @@ resource "aws_iam_role" "MyHandlerFunction-Role" {
120120
121121# Creating IAM Policies for Lambda
122122resource "aws_iam_role_policy" "MyHandlerFunction-Policy-source" {
123- name = " s3-sqs-lambda-tf-MyHandlerFunction-Role"
123+ name = " s3-sqs-lambda-tf-MyHandlerFunction-Role"
124124 policy = jsonencode (
125- {
126- " Statement" : [
125+ {
126+ " Statement" : [
127127 {
128- " Action" : [
129- " s3:GetObject" ,
130- " s3:ListBucket" ,
131- " s3:GetBucketLocation" ,
132- " s3:GetObjectVersion" ,
133- " s3:GetLifecycleConfiguration"
134- ],
135- " Resource" : [
136- " arn:aws:s3:::${ aws_s3_bucket . MySourceS3Bucket . id } " ,
137- " arn:aws:s3:::${ aws_s3_bucket . MySourceS3Bucket . id } /*"
138- ],
139- " Effect" : " Allow"
128+ " Action" : [
129+ " s3:GetObject" ,
130+ " s3:ListBucket" ,
131+ " s3:GetBucketLocation" ,
132+ " s3:GetObjectVersion" ,
133+ " s3:GetLifecycleConfiguration"
134+ ],
135+ " Resource" : [
136+ " arn:aws:s3:::${ aws_s3_bucket . MySourceS3Bucket . id } " ,
137+ " arn:aws:s3:::${ aws_s3_bucket . MySourceS3Bucket . id } /*"
138+ ],
139+ " Effect" : " Allow"
140140 }
141- ]
142- }
141+ ]
142+ }
143143 )
144144 role = aws_iam_role. MyHandlerFunction-Role . name
145145}
146146
147147resource "aws_iam_role_policy_attachment" "AWSLambdaBasicExecutionRole" {
148148 policy_arn = " arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
149- role = " ${ aws_iam_role . MyHandlerFunction-Role . name } "
149+ role = aws_iam_role. MyHandlerFunction-Role . name
150150}
151151
152152resource "aws_iam_role_policy_attachment" "AWSLambdaSQSQueueExecutionRole" {
153153 policy_arn = " arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole"
154- role = " ${ aws_iam_role . MyHandlerFunction-Role . name } "
154+ role = aws_iam_role. MyHandlerFunction-Role . name
155155}
156156
157-
157+
158158# ################################################################
159159# Outputs
160160# ################################################################
0 commit comments