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

Broken PR build fix #10556

Open
wants to merge 2 commits into
base: master
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
58 changes: 29 additions & 29 deletions scripts/aws s3 event triggering/s3-lambda/s3-lambda.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
import boto3
import json

def lambda_handler(event, context):

# i want to know that event thing
print(event)
def lambda_handler(event, context):
# i want to know that event thing
print(event)

# extract relevant information from the s3 event trigger
bucket_name=event['Records'][0]['s3']['bucket']['name']
object_key=event['Records'][0]['s3']['object']['key']
# extract relevant information from the s3 event trigger
bucket_name = event['Records'][0]['s3']['bucket']['name']
object_key = event['Records'][0]['s3']['object']['key']

# perform desired operations with the upload file
print(f"File '{object_key}' was uploaded to bucket '{bucket_name}'")
# perform desired operations with the uploaded file
print(f"File '{object_key}' was uploaded to bucket '{bucket_name}'")

# example: send a notification via sns
sns_client=boto3.client('sns')
topic_arn='arn:aws:sns:us-east-1:<account-id>:s3-lambda-sns'
sns_client.publish(
TopicArn=topic_arn,
Subject='s3 object created !!',
Message=f"File '{object_key}' was uploaded to bucket '{bucket_name}"
)
# example: send a notification via SNS
sns_client = boto3.client('sns')
topic_arn = 'arn:aws:sns:us-east-1:<account-id>:s3-lambda-sns'
sns_client.publish(
TopicArn=topic_arn,
Subject='s3 object created !!',
Message=f"File '{object_key}' was uploaded to bucket '{bucket_name}'"
)

# Example: Trigger another Lambda function
# lambda_client = boto3.client('lambda')
# target_function_name = 'my-another-lambda-function'
# lambda_client.invoke(
# FunctionName=target_function_name,
# InvocationType='Event',
# Payload=json.dumps({'bucket_name': bucket_name, 'object_key': object_key})
# )
# in case of queuing and other objective similar to the netflix flow of triggering
# Example: Trigger another Lambda function
# lambda_client = boto3.client('lambda')
# target_function_name = 'my-another-lambda-function'
# lambda_client.invoke(
# FunctionName=target_function_name,
# InvocationType='Event',
# Payload=json.dumps({'bucket_name': bucket_name, 'object_key': object_key})
# )
# in case of queuing and other objectives similar to the Netflix flow of triggering

return {
'statusCode': 200,
'body': json.dumps("Lambda function executed successfully !!")
}
return {
'statusCode': 200,
'body': json.dumps("Lambda function executed successfully !!")
}
16 changes: 10 additions & 6 deletions scripts/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

set -euo pipefail

PROJECT_DIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/.."
PROJECT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/.."

MD_FILES=$(find ${PROJECT_DIR} -name "*.md" -not -path "${PROJECT_DIR}/tests/*")

for file in ${MD_FILES[@]}; do
python ${PROJECT_DIR}/tests/syntax_lint.py ${file} > /dev/null
# Use the `-print0` option to handle spaces safely, and while-read loop:
find "${PROJECT_DIR}" \
-name "*.md" \
-not -path "${PROJECT_DIR}/tests/*" \
-print0 |
while IFS= read -r -d '' file
do
python "${PROJECT_DIR}/tests/syntax_lint.py" "${file}" > /dev/null
done

echo "- Syntax lint tests on MD files passed successfully"

flake8 --max-line-length=100 . && echo "- PEP8 Passed"
flake8 --max-line-length=100 . && echo "- PEP8 Passed"
Loading