accessing s3 from lambda within VPC in aws-go-sdk

最后都变了- 提交于 2020-02-06 04:33:28

问题


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!


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/49809623/accessing-s3-from-lambda-within-vpc-in-aws-go-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!