Created
November 11, 2019 23:34
-
-
Save djg07/1dc4196116e9eb55c40766d4fdc76c3b to your computer and use it in GitHub Desktop.
Resources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
Thanks, bow for your efforts.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks