0

I'm working my way through the aws + grunt-aws-lambda + jenkins tutorial at:

https://aws.amazon.com/blogs/compute/continuous-integration-deployment-for-aws-lambda-functions-with-jenkins-and-grunt-part-1/

I am able to successfully complete the tasks through the grunt lambda_invoke step. However, when I try grunt deploy, the task fails. Here is the excerpt where I receive warning and failure messages:

Running "lambda_package:default" (lambda_package) task
Verifying property lambda_package.default exists in config...OK
**File: [no files]**
Options: dist_folder="dist", include_time, package_folder="./", include_files=[]
Reading /Users/user/Documents/create-thumbs-lambda/package.json...OK
Parsing /Users/user/Documents/create-thumbs-lambda/package.json...OK
create-thumbs-lambda@1.0.0 ../../../../var/folders/01/xxx/T/xxx.1516/node_modules/create-thumbs-lambda
├── async@0.9.2
└── gm@1.23.0 (array-series@0.1.5, array-parallel@0.1.3, debug@2.2.0, cross-spawn@4.0.2)
Created package at ./dist/create-thumbs-lambda_1-0-0_2016-10-12-17-17-50.zip

Running "lambda_deploy" task

Running "lambda_deploy:default" (lambda_deploy) task
Verifying property lambda_deploy.default exists in config...OK
**File: [no files]**
Verifying property lambda_deploy.default.package exists in config...OK
Options: profile="lambdanodetestuser", region="us-west-2", timeout=null, memory=null
**Warning: AWS API request failed, check your AWS credentials, region and permissions are correct. Use --force to continue.**

I see that there is No File warning, and that my credentials may be an issue. But I'm not sure what file the Warning references, where to config the credentials in question, or if those are really even the the source of the problem.

Any advice is most appreciated!

ouonomos
  • 700
  • 1
  • 9
  • 25
  • Do you have credentials configured in `~/.aws/config`? Have you run [`configure`](http://docs.aws.amazon.com/cli/latest/reference/configure/)? – cartant Nov 13 '16 at 02:17
  • Thanks for that advice. I check my config file as you say and it looks correct. – ouonomos Nov 13 '16 at 04:45
  • Have you verified the credentials? [This answer](http://stackoverflow.com/a/31837458/6680611) mentions a few verification approaches. – cartant Nov 13 '16 at 04:49
  • Hmm. Well using the aws aws iam get-user command, I see that the iam user is as I expect. But now that I consider it: do I need to be specifying the iam user arn some where in the grunt setup? I don't see anything about that in the tutorial. – ouonomos Nov 13 '16 at 05:11
  • There's a default user that should be being used. I'm not familiar with the tools you are using, but I've used the AWS CLI a fair bit. You might want to check that the user you are using has the required permissions; if your user has limited permissions it's pretty easy to miss one that's actually required. – cartant Nov 13 '16 at 05:20
  • I'm pretty sure the permissions are correct, because I can succesfully run grunt lambda_invoke and also they look right in the IAM user console given what I want to do. Thanks though. – ouonomos Nov 13 '16 at 05:38

1 Answers1

1

There are many issues with that tutorial. It's very hard to make a perfect tutorial, so many variances.

But... I did debug the symptom you describe above. Unfortunately, the error message you receive is misleading.

The problem is in the implementation of lambda_deploy.js That function overwrites the 'function:' key-value you specified in your Gruntfile.js with a null string from an 'arn:' key-value.

The FIX: You can manually create the lambda function. Copy its arn. And, modify your lambda_deploy target to specify options and arn. it may look something like this...

   lambda_invoke: {
      default: {
         options: {
            file_name: 'CreateThumbnail.js'
         }
      }
   },
   lambda_deploy: {
      default: {
         options: {
            profile: "tah",
            region: "us-east-2",
            timeout: 10,
            memory: 1024,
         },
         function: 'CreateThumbnail',
         arn: 'arn:aws:lambda:us-east-2:REPLACEME:function:CreateThumbnail'
      }
   },
   lambda_package: {
      default: {
      }
   }
Tommy Hunt
  • 26
  • 2