sidecar
sidecar copied to clipboard
Is it possible to deploy a function to multiple regions ?
Is it possible to deploy a function to multiple regions ? And call that function with a region as argument ? Thanks.
In theory, yes. I'm not sure the follow-on effects throughout the rest of the library though. For example, when you execute a method you'd then need to pass through the region as well.
What is the larger goal you're trying to accomplish? You could always swap out the config stuff at runtime and call the standard commands / methods.
This would be really useful, I have a use case where I wanna do an uptime check (API call) from multiple locations.
I'm not sure what resources are region specific vs universal. I know for sure we'd need buckets in each region, which is doable but maybe a pain? I'm not too sure about the IAM stuff though.
I'd could imagine an interface that looks something like:
Sidecar::setRegion('us-east-1')
// Do stuff
Sidecar::setRegion('us-west-1')
// Do stuff
Any thoughts on that?
It looks like IAM can be restricted to a region so I assume its not restricted by default.
I think an API on the function itself could be better, perhaps similar to how you do the package config.
e.g.
class FooFunction extends LambdaFunction {
public function region() {
// could still return a string here for a single region deployment
return Region::multi(['eu-west-1', 'us-east-1']) // loop over these when deploying functions
->default('eu-west-1');
}
}
FooFunction::execute(); // defaults to eu-west-1
FooFunction::executeInRegion('us-east-1'); // runs on us-east-1
I dont know the internals of sidecar so what I am suggesting may not be reasonable, its just what I had in mind.
This would be really useful, I have a use case where I wanna do an uptime check (API call) from multiple locations.
That sounds like a good use case.
@zenati Mind sharing your use case?
@clarkeash I like that better, that's very clever.
@fgilio Yes, it's uptime check from multiple locations as well.
FYI, S3 buckets are not region-bound, they are global in AWS.
With docker images, you could deploy to all of them and then use an ENV value (or even a HTTP region query parameter) to point to the docker ImageUri to be used in Sidecar (which has a region embedded in it).
@fgilio Yes, it's uptime check from multiple locations as well.
@zenati I landed here looking up the same requirement. Curious if you found a working solution?
@aarondfrancis, if this package is still being actively maintained, and if you are open to the idea of multi-region deployment, I don't mind putting together a pull request to address this. Let me know.
I had a quick look at implementing this but I think it will be a fairly big change
@hughsaffar did you ever look at this or were you waiting on @aarondfrancis ? It should be possible but I dont think I understand the codebase/aws enough to make the change
@clarkeash I was waiting for @aarondfrancis since it will be a big change as you pointed out above. I eventually moved on to a different solution.
@hughsaffar what solution did you come up with?
@hughsaffar what solution did you come up with?
@clarkeash I used Serverless Framework for AWS infra setup and deploying the functions and created my own abstraction over AWS PHP SDK in PHP to invoke the functions. It might sound like an overengineered solution, but it worked fine for me. It allowed me to have a repo for each function and let me to define a Makefile that allows me to deploy to different regions like
deploy: clean build
sls deploy --region=us-east-1 --verbose
sls deploy --region=us-west-1 --verbose