aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.61k stars 3.91k forks source link

+x executable bit not being set on uploaded AssetCode for golang lambdas #3498

Closed wizardishungry closed 5 years ago

wizardishungry commented 5 years ago

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

class Sibyl(core.Stack):

def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
    super().__init__(scope, id, *kwargs)

    web = lambda_.Function(
        self, "web",
        code=lambda_.AssetCode.asset("bin"),
        handler="httpd",
        runtime=lambda_.Runtime.GO_1_X
    )

    api = apigw.RestApi(self, "api",
        rest_api_name="Quotes",
        description="This does stuff"
    )

    integration = apigw.LambdaIntegration(web)
    api.root.add_proxy(
        default_integration=integration,
    )

app = core.App() Sibyl(app, "sibyl") app.synth()

Deploy and try to hit a url. CloudWatch logs:

fork/exec /var/task/httpd: permission denied: PathError null

If I mess around with the handler path:

fork/exec /var/task/./bin/httpd: no such file or directory: PathError null

Comparing `zipinfo` with serverless's output:

$ zipinfo .serverless/httpd.zip Archive: .serverless/httpd.zip Zip file size: 4309367 bytes, number of entries: 1 -rwxr-xr-x 4.5 unx 10067040 bl defN 80-Jan-01 00:00 bin/httpd 1 file, 10067040 bytes uncompressed, 4309235 bytes compressed: 57.2%

With the CDK asset zip I downloaded from S3:

$ zipinfo /Users/jonwilliams/Downloads/6d27f27d59cc0ed270439e7bca00df1033689146b3389c1e02b7ad3b93ce9518.zip Archive: /Users/jonwilliams/Downloads/6d27f27d59cc0ed270439e7bca00df1033689146b3389c1e02b7ad3b93ce9518.zip Zip file size: 9286087 bytes, number of entries: 2 -rw-r--r-- 4.5 unx 10071136 bl defN 80-Jan-01 00:00 httpd -rw-r--r-- 4.5 unx 12544352 bl defN 80-Jan-01 00:00 polld


No executable bit.

* **What is the expected behavior (or behavior of feature suggested)?**
The lambda executes.

* **What is the motivation / use case for changing the behavior or adding this feature?**
Suppporting golang lambdas.

* **Please tell us about your environment:**

  - CDK CLI Version: 1.2.0 (build 6b763b7)
  - Module Version: 1.2.0
  - OS: OSX Mojave
  - Language: Python

* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
jogold commented 5 years ago

Should be fixed with https://github.com/aws/aws-cdk/pull/3428, can you test once this is released with the next version?

jogold commented 5 years ago

https://github.com/aws/aws-cdk/releases/tag/v1.3.0