As described in my post, this is a simple project that illustrates how to get Credentials
from a session.Session
so you can can create a v4.Signer
and then sign a request all from within an AWS Lambda function.
This assumes that you AWS credentials configured locally and those credentials permit access to list S3 buckets.
go run cmd/signed/main.go
You should see an XML listing of all your S3 buckets.
Create a zipped binary using the following command from the top of the project directory.
go build ./...
zip signed.zip signed
These are the basic steps to create the function using the console. If you're here, you probably already know how to do this, there's nothing special about this project.
- Choose Create Function
- Select Author from scratch
- Function name:
bucketlist
- Runtime
Go 1.x
- Function name:
- Select Create Function
- Select your
signed.zip
file after selecting the Upload button. - In the Handler field enter
signed
- Select the Save button in the top right.
The function doesn't expect any input so you can configure a simple test event (e.g. {}
) and run the function by clicking the Test button. The function will succeed but the output will show that access was denied. You need to add the s3:ListAllMyBuckets
policy action to your newly created role. Run the test again and you'll see the bucket list.