Tim-B / grunt-aws-lambda

A grunt plugin to assist in developing functions for AWS Lambda.
MIT License
247 stars 100 forks source link

Issue with deployment #73

Open kittrCZ opened 8 years ago

kittrCZ commented 8 years ago

Hi,

I have problems with deployment. The grunt deploy task is keep getting 404 and shows:

Running "lambda_package:default" (lambda_package) task
css-processor@1.0.0 
Created package at ./dist/css-processor_1-0-0_2016-2-21-22-58-51.zip

Running "lambda_deploy:default" (lambda_deploy) task
Warning: Unable to find lambda function arn:aws:lambda:us-west-2:XXX:function:XX-css-processor, verify the lambda function name and AWS region are correct. Use --force to continue.

Aborted due to warnings.

I'm able to invoke the same function with aws-cli:

aws lambda invoke --function-name XXX-css-processor test
{
    "StatusCode": 200
}

I'm running

$ aws --version
aws-cli/1.10.14 Python/2.7.10 Darwin/14.5.0 botocore/1.4.5

Package.json

"devDependencies": {
    "grunt": "^0.4.5",
    "grunt-aws-lambda": "^0.12.0"
  }

Gruntfile.js

var grunt = require('grunt');
grunt.loadNpmTasks('grunt-aws-lambda');

grunt.initConfig({
    lambda_invoke: {
        default: {
        }
    },
    lambda_deploy: {
        options: {
            enableVersioning: true
        },
        default: {
            arn: 'arn:aws:lambda:us-west-2:XXX:function:XXX-css-processor'
        }
    },
    lambda_package: {
        default: {
        }
    },
});

grunt.registerTask('deploy', ['lambda_package:default', 'lambda_deploy:default']);

Am I doing something wrong? I have used this library before and never head problems with this. Do you see there something wrong? I'm sure that the Lambda function is working and I'm able to test it.

sonya commented 8 years ago

Could you see what happens if you change the lambda_deploy section to the following? (I was seeing this as well and just just opened a PR about it)

lambda_deploy: {
    default: {
        arn: 'arn:aws:lambda:us-west-2:XXX:function:XXX-css-processor',
        options: {
            enableVersioning: true,
            region: 'us-west-2'
        }
    }
}
kittrCZ commented 8 years ago

@sonya I will check in couple of hours, I'm OOF now. Thanks for the reply!

kittrCZ commented 8 years ago

OK @sonya, so this is working. I'm kind of baffled by that, I guess I need to review the code. But this is resolved. Anyway, it should be mentioned that the order of options matters. I'm considering review the code in order to fix that

toshke commented 7 years ago

This maybe old thread, but It seems to me that default region is hardcoded to 'us-east-1'. What would be neet if region is picked up from used AWS profile, if not explicitly set in configuration.

webdevotion commented 7 years ago

@toshke specify the region in the task:

lambda_deploy: {
        default: {
            arn: 'arn:aws:lambda:eu-west-1:my-account-number:function:my-function',
            options: {
                region: 'eu-west-1'
            }
        }
    },
toshke commented 7 years ago

@webdevotion this works for me, but I believe if I add

options: {
    profile : 'my-profile-name'
}

in Grunt configuration and I have

[profile my-profile-name]
region=ap-southeast-2

in ~/.aws/config - I'll still get 'us-east-1' as deployment region. Doing some work on my fork anyway, so will double check and fix if this is the case.

Muenze commented 7 years ago

It is a problem in 0.13.0, don't know why this is not being fixed... You have to set the region to your region in the options. My Problem was that there is misleading Information in the readme:

options.region

Type: String Default value: us-east-1

Specify the AWS region your functions will be uploaded to. Note that if an ARN is supplied this option is not required.

Please tag als bug and fix it

pmvilaca commented 7 years ago

I just had the same problem. I assume that there is a bug in the code and not a documentation issue, because it make sense to extract the region from the arn if it's available.