apex / up

Deploy infinitely scalable serverless apps, apis, and sites in seconds to AWS.
https://up.docs.apex.sh
MIT License
8.78k stars 374 forks source link

lambda.role without colons throws error #781

Open ivarprudnikov opened 4 years ago

ivarprudnikov commented 4 years ago

Prerequisites

Description

First ever deploy ends in panic and all hell breaks loose. In short I used the AWS execution role name (foobar) instead of its ARN (arn:aws:iam::990099999999:role/foobar).

Error message panic: runtime error: index out of range was not helpful, had to fish out source code and realize that it expects semicolon in role, which lead me to the usage of actual ARN.

Failing line in your codebase: https://github.com/apex/up/blob/master/platform/lambda/lambda.go#L945

Steps to Reproduce

Then run $ up -v

Stacktrace

$ up -v
     5ms     DEBU up version 1.3.0 (os: darwin, arch: amd64)
     0s      DEBU inferred runtime type=node
   ⠋ 0s      DEBU 1 regions from config
     29ms    DEBU 1 regions from config
     0s      DEBU event deploy map[commit:f2607e7 stage:staging]
     0s      DEBU event platform.build map[]
     0s      DEBU hook prebuild is not defined
     0s      DEBU event hook map[hook:[] name:build]
     3ms     DEBU hook "build" command ""
     0s      DEBU event hook.complete map[duration:3.470089ms hook:[] name:build]
     124ms   DEBU injecting proxy
     0s      DEBU open
     1ms     DEBU add _proxy.js: size=1955 mode=-rwxr-xr-x
     0s      DEBU add app.js: size=169 mode=-rwxr-xr-x
     0s      DEBU add byline.js: size=4710 mode=-rwxr-xr-x
     215ms   DEBU add main: size=14197271 mode=-rwxr-xr-x
     0s      DEBU add up.json: size=118 mode=-rwxr-xr-x
     0s      DEBU stats dirs_filtered=0 files_added=5 files_filtered=0 size_uncompressed=14 MB
     3ms     DEBU close
     0s      DEBU event platform.build.zip map[duration:343.736943ms files:5 size_compressed:6848636 size_uncompressed:14204223]
     1ms     DEBU removing proxy
     0s      DEBU hook postbuild is not defined
     0s      DEBU event platform.build.complete map[duration:348.694094ms]
     0s      DEBU hook predeploy is not defined
     0s      DEBU hook deploy is not defined
     0s      DEBU using role from config foobar
     0s      DEBU event platform.deploy map[commit:f2607e7 region:eu-west-1 stage:staging]
     285ms   DEBU fetching function config region=eu-west-1
     0s      DEBU event platform.function.create map[commit:f2607e7 region:eu-west-1 stage:staging]
   ⠦ 0s     panic: runtime error: index out of range

goroutine 9 [running]:
github.com/apex/up/platform/lambda.(*Platform).getAccountID(...)
    /Users/tj/dev/src/github.com/apex/up/platform/lambda/lambda.go:945
github.com/apex/up/platform/lambda.(*Platform).getS3BucketName(0xc00006a180, 0x1d88c3d, 0x9, 0x0, 0x0)
    /Users/tj/dev/src/github.com/apex/up/platform/lambda/lambda.go:939 +0x150
github.com/apex/up/platform/lambda.(*Platform).createBucket(0xc00006a180, 0x1d88c3d, 0x9, 0xc0002b8900, 0xc00035fcc0)
    /Users/tj/dev/src/github.com/apex/up/platform/lambda/lambda.go:841 +0x125
github.com/apex/up/platform/lambda.(*Platform).createFunction(0xc00006a180, 0xc0001260c8, 0xc0001260b8, 0xc0000d4230, 0x1d88c3d, 0x9, 0x1d8715c, 0x7, 0xc00028dba0, 0x7, ...)
    /Users/tj/dev/src/github.com/apex/up/platform/lambda/lambda.go:533 +0x5d
github.com/apex/up/platform/lambda.(*Platform).deploy(0xc00006a180, 0x1d88c3d, 0x9, 0x1d8715c, 0x7, 0xc00028dba0, 0x7, 0xc00028dbc0, 0xd, 0x1, ...)
    /Users/tj/dev/src/github.com/apex/up/platform/lambda/lambda.go:519 +0x81d
github.com/apex/up/platform/lambda.(*Platform).Deploy.func1(0x8, 0x1dc79e8)
    /Users/tj/dev/src/github.com/apex/up/platform/lambda/lambda.go:162 +0xd5
github.com/golang/sync/errgroup.(*Group).Go.func1(0xc000094120, 0xc0001280c0)
    /Users/tj/dev/pkg/mod/github.com/golang/sync@v0.0.0-20170927054112-8e0aa688b654/errgroup/errgroup.go:58 +0x57
created by github.com/golang/sync/errgroup.(*Group).Go
    /Users/tj/dev/pkg/mod/github.com/golang/sync@v0.0.0-20170927054112-8e0aa688b654/errgroup/errgroup.go:55 +0x66
tj commented 4 years ago

thanks! definitely need some validation there

ivarprudnikov commented 4 years ago

Is there any validation happening at the moment, at the time up.json is parsed maybe? I might chip in and do some minor pull request if necessary.