douyuan9512
2018-04-13 05:02
浏览 92
已采纳

在AWS Go-SDK中从VPC中的Lambda访问s3

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!

图片转代码服务由CSDN问答提供 功能建议

我刚开始使用aws-sdk-go,注意到s3请求使用的是http / https而不是 比s3协议。 如何使用aws-sdk-go从vpc中的lambda读取s3中的对象?

并且我不想使用NAT网关。 我可以在NodeJS中执行此操作,但是aws-go-sdk是否可以执行相同的操作?

谢谢!

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dourukeng5302 2018-04-14 08:55
    已采纳

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

    打赏 评论
  • drcrc28428 2018-04-13 21:20

    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

    打赏 评论

相关推荐 更多相似问题