Repository: brefphp/bref (language: php)

Issue:
Enabling variablesResolutionMode: 20210326
Adding the advised deprecation flag `variablesResolutionMode: 20210326` (NEW_VARIABLES_RESOLVER) results in the bref layer variable failing:

```yml
variablesResolutionMode: 20210326

functions:
  web:
    layers:
      - ${bref:layer.php-80-fpm}

plugins:
  - ./vendor/bref/bref
```

Output

```
Serverless Error ----------------------------------------
 
  Approached unrecognized configuration variable sources: "bref"

Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.16.0
     Framework Version:         2.33.1
     Plugin Version:            4.5.3
     SDK Version:               4.2.2
     Components Version:        3.8.1
```




Discussion / hints:
Thank you for the report, it seems related to https://github.com/serverless/serverless/pull/9200

We will need to refactor the Bref plugin to support the new "variable resolver" API for serverless v3.

Fix patch:
diff --git a/index.js b/index.js
index b052ca7ce..4585658c6 100644
--- a/index.js
+++ b/index.js
@@ -19,6 +19,38 @@ class ServerlessPlugin {
 
         this.checkCompatibleRuntime();
 
+        // Declare `${bref:xxx}` variables
+        // See https://www.serverless.com/framework/docs/providers/aws/guide/plugins#custom-variable-types
+        this.configurationVariablesSources = {
+            bref: {
+                async resolve({address, params, resolveConfigurationProperty, options}) {
+                    // `address` and `params` reflect values configured with a variable: ${bref(param1, param2):address}
+
+                    // `options` is CLI options
+                    // `resolveConfigurationProperty` allows to access other configuration properties,
+                    // and guarantees to return a fully resolved form (even if property is configured with variables)
+                    const region = options.region || await resolveConfigurationProperty(['provider', 'region']);
+
+                    if (!address.startsWith('layer.')) {
+                        throw new Error(`Unknown Bref variable \${bref:${address}}, the only supported syntax right now is \${bref:layer.XXX}`);
+                    }
+
+                    const layerName = address.substr('layer.'.length);
+                    if (! (layerName in layers)) {
+                        throw new Error(`Unknown Bref layer named "${layerName}"`);
+                    }
+                    if (! (region in layers[layerName])) {
+                        throw new Error(`There is no Bref layer named "${layerName}" in region "${region}"`);
+                    }
+                    const version = layers[layerName][region];
+                    return {
+                        value: `arn:aws:lambda:${region}:209497400698:layer:${layerName}:${version}`,
+                    }
+                }
+            }
+        };
+
+        // This is the legacy way of declaring `${bref:xxx}` variables. This has been deprecated in 20210326.
         // Override the variable resolver to declare our own variables
         const delegate = this.serverless.variables
             .getValueFromSource.bind(this.serverless.variables);
@@ -111,7 +143,7 @@ class ServerlessPlugin {
         this.newVendorZipName = vendorZipHash + '.zip';
 
         this.consoleLog('Setting environment variables.');
-        
+
         if (! this.serverless.service.provider.environment) {
             this.serverless.service.provider.environment = [];
         }


Test patch: