Created
February 21, 2022 21:35
-
-
Save ystoneman/27aea8c6396ecd3d1dcc5fc7dc2ef0be to your computer and use it in GitHub Desktop.
Lambda function that puts a hello-world log message into CloudWatch Logs, just to test connectivity and permissions.
This file contains hidden or 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
import json | |
import boto3 | |
import time | |
def lambda_handler(event, context): | |
LOG_GROUP='awesome-logs' | |
LOG_STREAM='test' | |
logs = boto3.client('logs') | |
logs.create_log_stream(logGroupName=LOG_GROUP, logStreamName=LOG_STREAM) | |
timestamp = int(round(time.time() * 1000)) | |
response = logs.put_log_events( | |
logGroupName=LOG_GROUP, | |
logStreamName=LOG_STREAM, | |
logEvents=[ | |
{ | |
'timestamp': timestamp, | |
'message': 'Hello world, here is our first log message!' | |
} | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment