-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to deploy a function to multiple regions ? #40
Comments
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 |
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. |
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). |
@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 ? |
@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? |
@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 deploy: clean build
sls deploy --region=us-east-1 --verbose
sls deploy --region=us-west-1 --verbose |
I have made a working version of this, deploys/updates and runs on all regions. Happy to put together a PR if others would be interested. Defaults to the region in the sidecar conf file
|
Is it possible to deploy a function to multiple regions ? And call that function with a region as argument ? Thanks.
The text was updated successfully, but these errors were encountered: