serverless-operations / serverless-apigateway-service-proxy

This Serverless Framewrok plugin supports the AWS service proxy integration feature of API Gateway.
260 stars 77 forks source link

Integration with already existing S3 bucket #103

Open svoychik opened 4 years ago

svoychik commented 4 years ago

I'm trying to make API Gateway integration with already existing S3 Bucket Is there a way to reference the bucket by just a bucket name (or arn) without describing it as a part of the resources? like this:

- s3:
      path: "{userid}/{filename}"
      method: put
      action: PutObject
      bucket:
        bucketname: my-bucket
      cors: true
      requestParameters:
        integration.request.header.Content-Type: method.request.header.Content-Type
        integration.request.path.folder: method.request.path.userid
        integration.request.path.key: method.request.path.filename

It would be nice to have because if the resource already exists as a part of another CF it's quite a complex task to reference it

mfogel commented 3 years ago

I think what you're asking for is totally possible. In the example you have above instead of this:

bucket:
  bucketname: my-bucket

This should work:

bucket: my-bucket

This should work because this is the syntax I see in the README documentation:

bucket:
  Ref: S3Bucket

The Ref: S3Bucket part is dynamically pulling the bucket name as described in the cloudformation docs. Instead of dynamically pulling the bucket name you should be able to supply a static string if you already know the name of the bucket.