Skip to content
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

Not working with serverless-offline #91

Open
throrin19 opened this issue Jan 4, 2024 · 0 comments
Open

Not working with serverless-offline #91

throrin19 opened this issue Jan 4, 2024 · 0 comments

Comments

@throrin19
Copy link
Contributor

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:

  • With sls package :
    > sls package
    Warning: Invalid configuration encountered
      at 'functions.companiesCreate.environment': unrecognized property '$forEach'
      at 'functions.companiesDelete.environment': unrecognized property '$forEach'
    
    Learn more about configuration validation here: http://slss.io/configuration-validation
    Packaging my-package for stage local (eu-west-1)
    ✔ Found and replaced 2 $forEach matches
    
  • With sls offline :
    > sls offline start --stage local --httpPort 8001 --lambdaPort 9001
    
    Warning: Invalid configuration encountered
      at 'functions.companiesCreate.environment': unrecognized property '$forEach'
      at 'functions.companiesDelete.environment': unrecognized property '$forEach'
    
    Learn more about configuration validation here: http://slss.io/configuration-validation
    Warning: No external modules needed
    
    Starting Offline at stage local (eu-west-1)
    
    Offline [http for lambda] listening on http://localhost:9001
    

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant