grunt-aws-lambda icon indicating copy to clipboard operation
grunt-aws-lambda copied to clipboard

Issue with deployment

Open kittrCZ opened this issue 9 years ago • 8 comments
trafficstars

Hi,

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

Running "lambda_package:default" (lambda_package) task
[email protected] 
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.

kittrCZ avatar Mar 22 '16 06:03 kittrCZ

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'
        }
    }
}

sonya avatar Mar 22 '16 15:03 sonya

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

kittrCZ avatar Mar 22 '16 20:03 kittrCZ

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

kittrCZ avatar Mar 23 '16 05:03 kittrCZ

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.

toshke avatar Oct 27 '16 08:10 toshke

@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'
            }
        }
    },

webdevotion avatar Nov 15 '16 23:11 webdevotion

@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.

toshke avatar Nov 16 '16 07:11 toshke

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

Muenze avatar Feb 09 '17 09:02 Muenze

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.

pmvilaca avatar Apr 14 '17 10:04 pmvilaca