Brightspace / serverless-plugin-for-each

Serverless plugin that adds $forEach syntax to reduce code duplication and allow creating dynamic templates
Apache License 2.0
1 stars 5 forks source link

Not working with serverless-offline #91

Open throrin19 opened 10 months ago

throrin19 commented 10 months ago

Hello,

It seems that this plugin doesn't work with serverless-offline, regardless of the order in which the plugins are called.

For example, when I run the package command, I get the parsing warning but then the $forEach are replaced, whereas when I run sls offline, I only get the parsing warning, without the $forEach modifications:

I try to forEach on env variables on my lambdas but it's correctly available after package, but not in serverless-offline, only for $forEach part :

{
    functions : {
        companiesCreate : {
            handler              : 'src/handlers/companies-create-api.handler',
            maximumRetryAttempts : 0,
            events               : [
                {
                    http : {
                        method : 'post',
                        path   : '/companies',
                    },
                },
            ],
            environment : {
                $forEach : {
                    iterator : {
                        // simplify logic, only for debug purpose
                        ENV_ONE : process.env.ENV_ONE,
                        ENV_TWO : process.env.ENV_TWO,
                    }
                    template : {
                        '$forEach.key' : '$forEach.value',
                    },
                },
            },
        },
    },
    plugins : [
        'serverless-plugin-for-each',
        'serverless-esbuild',
        'serverless-prune-plugin',
        'serverless-analyze-bundle-plugin',
        // laisser en dernier
        'serverless-offline',
    ],
}

Is it possible to make it compatible with serverless-offline in order to keep the same logic between local development and deployment?