@@ -43,17 +43,29 @@ private static function loadServerlessConfig(string $fileName, ?string $override
43
43
if (empty ($ serverlessConfig ['service ' ]) || ! is_string ($ serverlessConfig ['service ' ]) || str_contains ($ serverlessConfig ['service ' ], '$ ' )) {
44
44
throw new Exception ('The "service" name in "serverless.yml" cannot contain variables, it is not supported by Bref Cloud ' );
45
45
}
46
+
46
47
$ team = (string ) ($ serverlessConfig ['bref ' ]['team ' ] ?? $ serverlessConfig ['custom ' ]['bref ' ]['team ' ] ?? '' );
47
48
if (empty ($ team )) {
48
49
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" ' );
49
50
}
50
51
if (str_contains ($ team , '$ ' )) {
51
52
throw new Exception ('The "service" name in "serverless.yml" cannot contain variables, it is not supported by Bref Cloud ' );
52
53
}
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
+
53
64
return [
54
65
'name ' => $ serverlessConfig ['service ' ],
55
66
'team ' => $ overrideTeam ?: $ team ,
56
67
'type ' => 'serverless-framework ' ,
68
+ 'region ' => $ region ,
57
69
// Health checks are automatically enabled if the package is installed
58
70
'healthChecks ' => file_exists ('vendor/bref/laravel-health-check/composer.json ' ),
59
71
];
0 commit comments