lambda-s3-logging-go

command module
v0.0.0-...-9d3994b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 13 Imported by: 0

README

AWS Lambda - S3 Logger (Go)

This is a simple AWS Lambda function written in Go that logs the S3 event to CloudWatch Logs.

Build

$ GOOS=linux go build -o main
$ zip deployment.zip main

Usage and Configuration

  1. Create a new Lambda function
    • Open the AWS Management Console and navigate to the Lambda service.
    • Click "Create function".
    • Choose "Author from scratch".
    • Enter a function name, for example, "s3-data-transfer-logger".
    • Choose "Go 1.x" as the runtime.
    • Under "Function code", click "Upload from" and select ".zip file". Upload the deployment.zip file created earlier.
    • In the "Execution role" section, choose "Create a new role with basic Lambda permissions". This creates an IAM role with basic permissions for your Lambda function.
  2. Configure an S3 trigger for your Lambda function:
    • In the "Function overview" section, click "Add trigger".
    • Choose "S3" as the trigger type.
    • Select the S3 bucket for which you want to track file downloads.
    • Set the "Event type" to "ObjectCreated (All)".
    • Optionally, set a prefix or suffix to filter events based on the object key (file path).
    • Click "Add" to create the trigger.
  3. Configure permissions for your Lambda function:
    • Make sure that the IAM role associated with your Lambda function has the necessary permissions to access S3 and interact with CloudWatch Logs. To do this, open the IAM service in the AWS Management Console, find the role you just created, and add the following managed policies:
      • AmazonS3ReadOnlyAccess
      • AWSLambdaBasicExecutionRole
    • Customize the role as needed, based on your specific requirements.

License

This project is licensed under the MIT License - see the MIT license for details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL