Skip to content

Instantly share code, notes, and snippets.

@yogendratamang48
Created January 31, 2023 21:06
Show Gist options
  • Save yogendratamang48/19297e502799bcf6e83f11854c658bbb to your computer and use it in GitHub Desktop.
Save yogendratamang48/19297e502799bcf6e83f11854c658bbb to your computer and use it in GitHub Desktop.
aclouguru-statemachines
name provider skill-level
Introduction to Amazon Athena AWS Apprentice
Processing Serverless Data Using Lambda AWS Practitioner
import boto3
import awswrangler as wr
courses_bucket_name = 'datafeed-20230131'
s3_courses_csv_file_name = 'premium-courses.csv'
s3_client = boto3.client('s3')
def lambda_handler(event, context):
print('Received event from Step Functions')
print(event)
response = {}
response ['Message'] = 'Well done, this was a hard quiz and you nailed it! Here are your premium courses!'
response['Score'] = event["Score"]
csv_file = f's3://' + courses_bucket_name + '/' + s3_courses_csv_file_name
df = wr.s3.read_csv(csv_file)
response['Courses'] = df.to_dict()
return response
id name provider skill-level
2 Setting Up Lambda Functions with S3 Event Triggers AWS Practitioner
3 Automatically Processing Data in S3 Using Lambda AWS Practitioner
import boto3
import awswrangler as wr
lessons_bucket_name = 'datafeed-20230131'
s3_lessons_csv_file_name = 'premium-lessons.csv'
s3_client = boto3.client('s3')
def lambda_handler(event, context):
print('Received event from Step Functions')
print(event)
response = {}
response ['Message'] = "You didn't pass. Don't worry! Practice makes perfect. Here are premium lessons to keep you going!"
response['Score'] = event["Score"]
csv_file = f's3://' + lessons_bucket_name + '/' + s3_lessons_csv_file_name
df = wr.s3.read_csv(csv_file)
response['Lessons'] = df.to_dict()
return response
{
"Comment": "Rewards Processor State Machine",
"StartAt": "AssessStudent",
"States": {
"AssessStudent": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.Score",
"NumericGreaterThan": 74,
"Next": "UnlockPremiumCourses"
},
{
"Variable": "$.Score",
"NumericLessThan": 75,
"Next": "UnlockPremiumLessons"
}
]
},
"UnlockPremiumCourses": {
"Type": "Task",
"Resource": "",
"End": true
},
"UnlockPremiumLessons":
{
"Type": "Task",
"Resource": "",
"End": true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment