Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worked #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added aws-event-triggering/s3-lambda-function.zip
Binary file not shown.
80 changes: 79 additions & 1 deletion aws-event-triggering/s3-lambda-function/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,79 @@
boto3==1.17.95
attrs==21.2.0
Automat==20.2.0
awscli==1.22.34
Babel==2.8.0
bcrypt==3.2.0
blinker==1.4
botocore==1.23.34
certifi==2020.6.20
chardet==4.0.0
click==8.0.3
cloud-init==23.1.1
colorama==0.4.4
command-not-found==0.3
configobj==5.0.6
constantly==15.1.0
cryptography==3.4.8
dbus-python==1.2.18
distro==1.7.0
distro-info===1.1build1
docutils==0.17.1
ec2-hibinit-agent==1.0.0
hibagent==1.0.1
httplib2==0.20.2
hyperlink==21.0.0
idna==3.3
importlib-metadata==4.6.4
incremental==21.3.0
jeepney==0.7.1
Jinja2==3.0.3
jmespath==0.10.0
jsonpatch==1.32
jsonpointer==2.0
jsonschema==3.2.0
keyring==23.5.0
launchpadlib==1.10.16
lazr.restfulclient==0.14.4
lazr.uri==1.0.6
MarkupSafe==2.0.1
more-itertools==8.10.0
netifaces==0.11.0
oauthlib==3.2.0
olefile==0.46
pexpect==4.8.0
Pillow==9.0.1
ptyprocess==0.7.0
pyasn1==0.4.8
pyasn1-modules==0.2.1
Pygments==2.11.2
PyGObject==3.42.1
PyHamcrest==2.0.2
PyJWT==2.3.0
pyOpenSSL==21.0.0
pyparsing==2.4.7
pyrsistent==0.18.1
pyserial==3.5
python-apt==2.4.0+ubuntu1
python-dateutil==2.8.1
python-debian===0.1.43ubuntu1
python-magic==0.4.24
pytz==2022.1
PyYAML==5.4.1
requests==2.25.1
roman==3.3
rsa==4.8
s3transfer==0.5.0
SecretStorage==3.3.1
service-identity==18.1.0
six==1.16.0
sos==4.4
ssh-import-id==5.11
systemd-python==234
Twisted==22.1.0
ubuntu-advantage-tools==8001
ufw==0.36.1
unattended-upgrades==0.1
urllib3==1.26.5
wadllib==1.3.6
zipp==1.0.0
zope.interface==5.4.0
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def lambda_handler(event, context):

# Example: Send a notification via SNS
sns_client = boto3.client('sns')
topic_arn = 'arn:aws:sns:us-east-1:<account-id>:s3-lambda-sns'
topic_arn = 'arn:aws:sns:ap-south-1:560905053644:s3-lambda-sns'
sns_client.publish(
TopicArn=topic_arn,
Subject='S3 Object Created',
Expand Down
10 changes: 5 additions & 5 deletions aws-event-triggering/s3-notification-triggers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ aws_account_id=$(aws sts get-caller-identity --query 'Account' --output text)
echo "AWS Account ID: $aws_account_id"

# Set AWS region and bucket name
aws_region="us-east-1"
bucket_name="abhishek-ultimate-bucket"
aws_region="ap-south-1"
bucket_name="khakendra707-ultimate-bucket"
lambda_func_name="s3-lambda-function"
role_name="s3-lambda-sns"
email_address="zyz@gmail.com"
email_address="sasiram124@gmail.com"

# Create IAM Role for the project
role_response=$(aws iam create-role --role-name s3-lambda-sns --assume-role-policy-document '{
Expand Down Expand Up @@ -42,7 +42,7 @@ aws iam attach-role-policy --role-name $role_name --policy-arn arn:aws:iam::aws:
aws iam attach-role-policy --role-name $role_name --policy-arn arn:aws:iam::aws:policy/AmazonSNSFullAccess

# Create the S3 bucket and capture the output in a variable
bucket_output=$(aws s3api create-bucket --bucket "$bucket_name" --region "$aws_region")
bucket_output=$(aws s3api create-bucket --bucket "$bucket_name" --region "$aws_region" --create-bucket-configuration LocationConstraint=ap-south-1)

# Print the output from the variable
echo "Bucket creation output: $bucket_output"
Expand Down Expand Up @@ -74,7 +74,7 @@ aws lambda add-permission \
--source-arn "arn:aws:s3:::$bucket_name"

# Create an S3 event trigger for the Lambda function
LambdaFunctionArn="arn:aws:lambda:us-east-1:$aws_account_id:function:s3-lambda-function"
LambdaFunctionArn="arn:aws:lambda:ap-south-1:$aws_account_id:function:s3-lambda-function"
aws s3api put-bucket-notification-configuration \
--region "$aws_region" \
--bucket "$bucket_name" \
Expand Down