lambda-SQS-clouwatch-S3 events upload or delete or any Updates

Venkateswara Reddy - Dec 9 '23 - - Dev Community

Image description

1.create an SES:

1.In the console Search for SES and click on Email addresses and then click on verify a new Email.
2.Enter email address and click on verify this email address.
3.Open the gmail and then accept the request. Then our SES willverify.

SNS notification from s3.

Youtube reference: https://youtu.be/6mYLqTZ5FHg

1.Create a SNS by searching SNS in the console and subscribe any email or anything like HTTP or ….then under policy we will get by default script like below.


{
    "Version": "2008-10-17",
    "Id": "__default_policy_ID",
    "Statement": [
      {
        "Sid": "__default_statement_ID",
        "Effect": "Allow",
        "Principal": {
          "AWS": "*"
        },
        "Action": [
          "SNS:GetTopicAttributes",
          "SNS:SetTopicAttributes",
          "SNS:AddPermission",
          "SNS:RemovePermission",
          "SNS:DeleteTopic",
          "SNS:Subscribe",
          "SNS:ListSubscriptionsByTopic",
          "SNS:Publish"
        ],
        "Resource": "arn:aws:sns:ap-northeast-1:084251039480:ee",
        "Condition": {
          "StringEquals": {
            "AWS:SourceOwner": "084251039480"
          }
        }
      }
    ]
  }

Enter fullscreen mode Exit fullscreen mode

2.Here we have to edit 3 places out of those one is 7th line from bottom “StringEquals” to “ArnLike” and one more is “AWS:SourceOwner” to “AWS:SourceArn” and one more is value of source owner from default value like “54322423456” to S3 bucket ARN that is like “ARN:AWS:S3:::venkybucket”.
3.Then under s3 bucket goto properties and then under event notification we can add this sns and it will work otherwise it will throw error.


{
  "Version": "2008-10-17",
  "Id": "__default_policy_ID",
  "Statement": [
    {
      "Sid": "__default_statement_ID",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": [
        "SNS:GetTopicAttributes",
        "SNS:SetTopicAttributes",
        "SNS:AddPermission",
        "SNS:RemovePermission",
        "SNS:DeleteTopic",
        "SNS:Subscribe",
        "SNS:ListSubscriptionsByTopic",
        "SNS:Publish"
      ],
      "Resource": "arn:aws:sns:ap-northeast-1:084251039480:aaa",
      "Condition": {
        "ArnLike": {
          "AWS:SourceArn": "arn:aws:s3:::venkyoiuyi"
        }
      }
    }
  ]
}

Enter fullscreen mode Exit fullscreen mode

IAM:

1.In aws console search for iam then click on role then select lamda instead of default ec2 and the inder policies search for cloudwatch and select cloudwatch full access and again search for SES and select amazonSESFullAccess then click on okk
2.

Lamda:

1.In console search for lambda then click on create a function then give name and choose runtime as python and under roles section we have to select the existing role what ever we created.

Cloudwatch:

1.Click on cloudwatch and left side we can see rule click on that and click on create a rule and here we have to select theshedule then under this schedule we can add any time we can use cron job also.
2.Then create a target then select lambda and select the lambda what ever we created. Then finally enter the name of the rule and then create.
3.

. . . . . . . . . . . . .