Skip to content

Instantly share code, notes, and snippets.

@djg07
Created November 11, 2019 23:34
Show Gist options
  • Save djg07/1dc4196116e9eb55c40766d4fdc76c3b to your computer and use it in GitHub Desktop.
Save djg07/1dc4196116e9eb55c40766d4fdc76c3b to your computer and use it in GitHub Desktop.
Resources
S3 PutObject Role
---
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "*"
}
]
}
AWSLambdaBasicExecution Role
---
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
Python Code
---
#Talk python to me
import json
import boto3
s3 = boto3.client('s3')
def lambda_handler(event, context):
bucket ='aws-simplified-transactions'
transactionToUpload = {}
transactionToUpload['transactionId'] = '12345'
transactionToUpload['type'] = 'PURCHASE'
transactionToUpload['amount'] = 20
transactionToUpload['customerId'] = 'CID-11111'
fileName = 'CID-11111' + '.json'
uploadByteStream = bytes(json.dumps(transactionToUpload).encode('UTF-8'))
s3.put_object(Bucket=bucket, Key=fileName, Body=uploadByteStream)
print('Put Complete')
@Anon-Exploiter
Copy link

Thanks.

@AyushSinghdeo
Copy link

thanx

@sgrsaga
Copy link

sgrsaga commented Oct 16, 2021

Thanks

Copy link

ghost commented Jul 13, 2022

Thanks

@SARDENDU1010
Copy link

Thanks

@clement2019
Copy link

thanks

@shivaram235vemula
Copy link

Thanks, bow for your efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment