serverless / compose

Orchestrate Serverless Framework in monorepos
https://serverless.com/framework/docs/guides/compose
MIT License
111 stars 15 forks source link

[RFC] Automatically share deployment buckets? #18

Open mnapoli opened 2 years ago

mnapoli commented 2 years ago

Feature idea: a way to automatically share the deployment bucket across all Serverless Framework services.

For example:

name: my-app

shareDeploymentBucket: true

and automatically all services share the same deployment bucket (no extra config needed).

It needs to be opt-in of course (to preserve backward compatibility).

Thoughts?

pgrzesik commented 2 years ago

As discussed in our call, one of the potential options here would be to use a "hidden" internal component that will handle the management of the bucket used for deployments.

m-radzikowski commented 2 years ago

I think this should even be the default behavior, but putting this single line in serverless-compose.yml is not bad.

For now, I tried to pass ServerlessDeploymentBucketName as a param (since sls creates such output), but serverless-compose did not see it and thrown an error:

name: myapp

services:

  common:
    path: services/common

  api:
    path: services/api
    params:
      deploymentBucket: ${common.ServerlessDeploymentBucketName}
mnapoli commented 2 years ago

@m-radzikowski thanks for the feedback!

And regarding your error, oh it seems to be related to this:

https://github.com/serverless/compose/blob/fc980341ea53221fa0a5fa455a948045768a4426/components/framework/serverless.js#L205

I explicitly removed that line from info (and outputs) to avoid having too much noise. I didn't think about this use case 🤔 I'm not sure if we should restore that output, wdyt @pgrzesik?

m-radzikowski commented 2 years ago

useless info

😄

This will not be needed if the deployment bucket is shared automatically thought.

pgrzesik commented 2 years ago

Thanks for the feedback @m-radzikowski 🙇

@mnapoli I think it's good to keep it in outputs for the exact use case that @m-radzikowski has here - we can remove it afterwards if needed

mnapoli commented 2 years ago

👍 sounds good to me!

mnapoli commented 2 years ago

Note: this may be related as well to state storage (on S3) and/or CDK deployments with the bootstrap stack.

There may be an opportunity here to have 1 bucket per app, and use it to store state + as deployment bucket for services.