chalice icon indicating copy to clipboard operation
chalice copied to clipboard

lambda layers per stage in config not working

Open ssoonan opened this issue 7 years ago • 11 comments

Hi, I'm Ssoonan.

"stages": {
    "dev": {
      "api_gateway_stage": "api" ,
      "lambda_timeout": 300,
      "lambda_memory_size": 512,
      "layers": [
        "arn:aws:lambda:~",
        "arn:aws:lambda:~"
      ]
    }
  }

I put Lambda layers in ./chalice/config.json When I deployed my project, everything works fine and no errors occured.
But layers config doesn't working, So I had to do it on the console manually.

Thanks for your project and help. Thank you

ssoonan avatar Mar 25 '19 08:03 ssoonan

Hi, I am having the same problem here.

LucioSt avatar Apr 02 '19 15:04 LucioSt

I was not able to reproduce. Using this app.py with an empty requirements.txt:

from chalice import Chalice
import PIL
import aiohttp

app = Chalice(app_name='layers')


@app.lambda_function()
def version(event, context):
    return {
        'Pilow': PIL.__version__,
        'aiohttp': aiohttp.__version__
    }

and these public layers in my .chalice/config.json:

{
  "stages": {
    "dev": {
      "api_gateway_stage": "api",
      "layers": [
        "arn:aws:lambda:us-west-2:113088814899:layer:Klayers-python37-Pillow:1",
        "arn:aws:lambda:us-west-2:113088814899:layer:Klayers-python37-aiohttp:5"
      ]
    }
  },
  "version": "2.0",
  "app_name": "layers"
}

I was able to chalice deploy and then invoke it fine:

$ chalice invoke -n version
{"Pilow": "5.4.1", "aiohttp": "3.5.4"}

What version of chalice are you using? In order to use layers, you need to be using version 1.7.0.

kyleknap avatar Apr 02 '19 17:04 kyleknap

@kyleknap I have the same issue. Can it be because I didn't recreate my already deployed Chalice app but just run chalice deploy?

danil-smirnov avatar Apr 03 '19 15:04 danil-smirnov

@kyleknap I've done chalice delete and chalice deploy - no luck still. I have the following part in config and I can confirm that lambda_timeout parameter works just perfect, while layers param does not.

      "lambda_functions": {
        "api_handler": {
          "lambda_timeout": 300,
          "layers": [
            "arn:aws:lambda:us-east-1:12345678:layer:pycryptodome:1",
            "arn:aws:lambda:us-east-1:12345678:layer:paypal-checkout-serversdk:1"
          ]
	}
      },

danil-smirnov avatar Apr 03 '19 16:04 danil-smirnov

@danil-smirnov What version of chalice are you using? You can get the version by running chalice --version.

kyleknap avatar Apr 03 '19 16:04 kyleknap

@kyleknap

chalice --version
chalice 1.7.0, python 3.6.8, linux 4.14.88-72.73.amzn1.x86_64

danil-smirnov avatar Apr 03 '19 16:04 danil-smirnov

So looking over the tags, it looks like layers has not actually been included in a official chalice release. It is currently on the master branch though, which is why it is showing up in the documentation (we always build the docs from the head of the master branch). It was working for me because I have chalice installed from the head of master as well. I will look into cutting a release for chalice so it is available on PyPI. Otherwise, you should be able to install it from the master branch in the meantime to try it out by running:

pip install -e git://github.com/aws/chalice.git@master#egg=chalice

kyleknap avatar Apr 03 '19 16:04 kyleknap

We just released chalice 1.8.0 to PyPI. You should be able to install it now and use layers with chalice. Let us know if you run into any issues.

kyleknap avatar Apr 03 '19 19:04 kyleknap

Everything works like a charm now @kyleknap Many thanks

danil-smirnov avatar Apr 04 '19 09:04 danil-smirnov

Everything works fine now. Thanks guys

LucioSt avatar Apr 04 '19 13:04 LucioSt

Awesome. Great to hear! Closing.

kyleknap avatar Apr 04 '19 16:04 kyleknap