tomdale / lambda-packager

Builds dependencies for Node.js Lambda functions
145 stars 14 forks source link

`lambda-packager deploy` fails with ENOENT #3

Open dcrockwell opened 8 years ago

dcrockwell commented 8 years ago
$ lambda-packager deploy
? Stack name lambda-packager
? Region us-east-1
Creating stack lambda-packager...
This may take a few minutes.
ENOENT: no such file or directory, open '/Users/dcrockwell/.nvm/versions/node/v4.2.1/lib/node_modules/lambda-packager/blueprints/cloudformation-template.json'

This is on Node v4 if it matters.

michaelwills commented 8 years ago

Using 0.2.1 from npm and adding there old template from here: https://github.com/tomdale/lambda-packager/blob/0564aacd837bb7ddfe7e310929c7961ba28c6e7a/blueprints/cloudformation.json

resolves the ENOENT but it still fails:

% DEBUG=lambda-packager:cloud-formation lambda-packager deploy
? Stack name lambda-packager
? Region us-east-1
Creating stack lambda-packager...
This may take a few minutes.
  lambda-packager:cloud-formation creating stack; name= +0ms lambda-packager ; template= {
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Provisions a Lambda function for compiling npm packages via the lambda-packager package.",
    "Resources": {
        "OutputBucket": {
            "Type": "AWS::S3::Bucket"
        },
        "ExecutionRole": {
            "Type": "AWS::IAM::Role",
            "Properties": {
                "AssumeRolePolicyDocument": {
                    "Version": "2012-10-17",
                    "Statement": [{
                        "Effect": "Allow",
                        "Principal": {
                            "Service": ["lambda.amazonaws.com"]
                        },
                        "Action": ["sts:AssumeRole"]
                    }]
                },
                "Policies": [{
                    "PolicyName": "LambdaPackager",
                    "PolicyDocument": {
                        "Version": "2012-10-17",
                        "Statement": [{
                            "Effect": "Allow",
                            "Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"],
                            "Resource": "arn:aws:logs:*:*:*"
                        }, {
                            "Effect": "Allow",
                            "Action": ["s3:GetObject", "s3:PutObject"],
                            "Resource": ["arn:aws:s3:::*"]
                        }]
                    }
                }]
            }
        },
        "LambdaFunction": {
            "Type": "AWS::Lambda::Function",
            "Properties": {
                "Handler": "handler.handler",
                "Role": {
                    "Fn::GetAtt": ["ExecutionRole", "Arn"]
                },
                "Runtime": "nodejs",
                "Timeout": "300",
                "Code": {
                    "S3Bucket": "lambda-packager",
                    "S3Key": "output.zip"
                }
            }
        }
    },
    "Outputs": {
        "Bucket": {
            "Value": {
                "Ref": "OutputBucket"
            }
        },
        "Function": {
            "Value": {
                "Ref": "LambdaFunction"
            }
        }
    }
}

  lambda-packager:cloud-formation cloudformation error; err= +567ms { [OptInRequired: The AWS Access Key Id needs a subscription for the service]
  message: 'The AWS Access Key Id needs a subscription for the service',
  code: 'OptInRequired',
  time: Thu Dec 24 2015 09:43:49 GMT-0800 (PST),
  requestId: 'e372fa01-aa65-11e5-ac9f-f513d706eb04',
  statusCode: 403,
  retryable: false,
  retryDelay: 30 }
davidsulpy commented 8 years ago

Also failing for me with ENOENT on lambda-packager/blueprints/cloudformation-template.json

davidsulpy commented 8 years ago

When I manually add the cloudformation template, the cloudformation stack fails to create because of a lack of permissions to get the resource at s3 bucket lambda-packager and key output.zip

gmaclennan commented 8 years ago

Same problems here.

jgreen01 commented 8 years ago

Same problem. lambda-packager/blueprints/cloudformation-template.json doesn't exist for some reason. @hmcfletch created a fork that fixes this issue. Of course, you still need the permissions to deploy cloudformation.

fix/add-cloudformation-blueprint

ariesshrimp commented 8 years ago

the fork mentioned by @jgreen82 produces just the same error.

magentanova commented 6 years ago

@joefraley the fork by @jgreen82 solves the original issue, but the fix branch isn't merged into master. so you need to pull that branch and work from there. it's at the bottom of that README.