1

I'm just started on using aws-sdk-go and notice that the s3 requests are using http/https rather than s3 protocol. How can I read the object in s3 from my lambda within vpc using aws-sdk-go?

And I don't want to use NAT Gateway. I can do this in NodeJS but is there any way for aws-go-sdk to do the same?

Thanks!

3
  • 2
    There is no "S3 protocol." S3 uses HTTP. The s3://bucket/object notation (if this is what you are referring to) is simply a URI format, a notational style. It's not clear what you are saying you can do in Node that is different than Go... please clarify this, because there should be no difference. Commented Apr 13, 2018 at 11:17
  • ah.. I thought s3:// and https:// are different Commented Apr 15, 2018 at 1:02
  • yeah.. It turns out that I need the S3 Endpoint as mentioned by @Robo. Sorry for the confusion. The application in NodeJS belongs to a VPC that does have an s3 endpoint Commented Apr 15, 2018 at 1:06

2 Answers 2

3

This code snippet shows how to use aws-go-sdk to list S3 buckets for region us-east-1 within a Lambda function:

func listBuckets() {
    svc := s3.New(session.New(&aws.Config{Region: aws.String("us-east-1")}))
    buckets, err := svc.ListBuckets(nil)
    log.Printf("listBuckets: %q error=%v", buckets, err)
}

Find full source code here: https://github.com/udhos/hellolambda/blob/master/main.go

Sign up to request clarification or add additional context in comments.

Comments

2

To access S3 within a VPC without an internet gateway you need to use a S3 Endpoint

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.