@@ -43,17 +43,29 @@ private static function loadServerlessConfig(string $fileName, ?string $override
4343 if (empty ($ serverlessConfig ['service ' ]) || ! is_string ($ serverlessConfig ['service ' ]) || str_contains ($ serverlessConfig ['service ' ], '$ ' )) {
4444 throw new Exception ('The "service" name in "serverless.yml" cannot contain variables, it is not supported by Bref Cloud ' );
4545 }
46+
4647 $ team = (string ) ($ serverlessConfig ['bref ' ]['team ' ] ?? $ serverlessConfig ['custom ' ]['bref ' ]['team ' ] ?? '' );
4748 if (empty ($ team )) {
4849 throw new Exception ('To deploy a Serverless Framework project with Bref Cloud you must set the team name in the "bref.team" field in "serverless.yml" ' );
4950 }
5051 if (str_contains ($ team , '$ ' )) {
5152 throw new Exception ('The "service" name in "serverless.yml" cannot contain variables, it is not supported by Bref Cloud ' );
5253 }
54+
55+ // Retrieve the region if set in the provider block
56+ if (isset ($ serverlessConfig ['provider ' ]['region ' ]) && ! is_string ($ serverlessConfig ['provider ' ]['region ' ])) {
57+ throw new Exception ('The "provider.region" field in "serverless.yml" must be a string ' );
58+ }
59+ $ region = $ serverlessConfig ['provider ' ]['region ' ] ?? null ;
60+ if ($ region && str_contains ($ region , '$ ' )) {
61+ throw new Exception ('The "provider.region" field in "serverless.yml" cannot contain variables, it is not supported by Bref Cloud ' );
62+ }
63+
5364 return [
5465 'name ' => $ serverlessConfig ['service ' ],
5566 'team ' => $ overrideTeam ?: $ team ,
5667 'type ' => 'serverless-framework ' ,
68+ 'region ' => $ region ,
5769 // Health checks are automatically enabled if the package is installed
5870 'healthChecks ' => file_exists ('vendor/bref/laravel-health-check/composer.json ' ),
5971 ];
0 commit comments