grunt-aws-lambda
Advanced tools
Comparing version 0.10.0 to 0.11.0
105
package.json
{ | ||
"name": "grunt-aws-lambda", | ||
"description": "A grunt plugin to help develop AWS Lambda functions.", | ||
"version": "0.10.0", | ||
"homepage": "https://github.com/Tim-B/grunt-aws-lambda", | ||
"author": { | ||
"name": "Tim-B", | ||
"email": "tim@galacticcode.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/Tim-B/grunt-aws-lambda.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Tim-B/grunt-aws-lambda/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/Tim-B/grunt-aws-lambda/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
}, | ||
"scripts": { | ||
"test": "grunt test" | ||
}, | ||
"dependencies": { | ||
"temporary": "~0.0.8", | ||
"archiver": "~0.14.4", | ||
"mkdirp": "~0.5.0", | ||
"rimraf": "~2.2.8", | ||
"glob": "~4.3.0", | ||
"aws-sdk": "~2.1.30", | ||
"npm": "^2.10.0" | ||
}, | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "^0.9.2", | ||
"grunt-contrib-clean": "^0.5.0", | ||
"grunt-contrib-nodeunit": "^0.3.3", | ||
"grunt": "~0.4.5", | ||
"adm-zip": "~0.4.4" | ||
}, | ||
"peerDependencies": { | ||
"grunt": "~0.4.5" | ||
}, | ||
"keywords": [ | ||
"gruntplugin" | ||
] | ||
"name": "grunt-aws-lambda", | ||
"description": "A grunt plugin to help develop AWS Lambda functions.", | ||
"version": "0.11.0", | ||
"homepage": "https://github.com/Tim-B/grunt-aws-lambda", | ||
"author": { | ||
"name": "Tim-B", | ||
"email": "tim@galacticcode.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/Tim-B/grunt-aws-lambda.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Tim-B/grunt-aws-lambda/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/Tim-B/grunt-aws-lambda/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
}, | ||
"scripts": { | ||
"test": "grunt test" | ||
}, | ||
"dependencies": { | ||
"temporary": "~0.0.8", | ||
"archiver": "~0.14.4", | ||
"mkdirp": "~0.5.0", | ||
"rimraf": "~2.2.8", | ||
"glob": "~4.3.0", | ||
"aws-sdk": "~2.1.30", | ||
"npm": "^2.10.0" | ||
}, | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "^0.9.2", | ||
"grunt-contrib-clean": "^0.5.0", | ||
"grunt-contrib-nodeunit": "^0.3.3", | ||
"grunt": "~0.4.5", | ||
"adm-zip": "~0.4.4" | ||
}, | ||
"peerDependencies": { | ||
"grunt": "~0.4.5" | ||
}, | ||
"keywords": [ | ||
"gruntplugin" | ||
], | ||
"readme": "# grunt-aws-lambda\n\n> A grunt plugin to assist in developing functions for [AWS Lambda](http://aws.amazon.com/lambda/).\n\n[![Build Status](https://travis-ci.org/Tim-B/grunt-aws-lambda.svg)](https://travis-ci.org/Tim-B/grunt-aws-lambda)\n\nThis plugin provides helpers for:\n* Running Lambda functions locally\n* Managing npm dependencies which are required by your function\n* Packaging required dependencies with your function in a Lambda compatible zip\n* Uploading package to Lambda\n\n## Getting Started\nThis plugin requires Grunt `~0.4.5`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-aws-lambda --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-aws-lambda');\n```\n\n## Gotchas\n\n### Add dist to your .npmignore\n\nThis will save you from packaging previous packages in future ones.\n\nFor example your `.npmignore` might look something like this:\n```\nevent.json\nGruntfile.js\ndist\n*.iml\n```\n\n[Read More](#default-options-1)\n\n### Include your dependencies in bundledDependencies\n\nnpm packages which should be bundled with your lambda function must be included in the `bundledDependencies` of your\n `package.json`, for example:\n\n```json\n...\n\"dependencies\": {\n \"jquery\": \"2.1.1\"\n},\n...\n\"bundledDependencies\": [\n \"jquery\"\n]\n...\n```\n\n[Read More](#default-options-1)\n\n\n## Authenticating to AWS\n\nThis library supports providing credentials for AWS via an IAM Role, an AWS CLI profile, environment variables, a JSON file on disk, or passed in credentials.\nTo learn more, please see the [below section](#aws-credentials)\n\n## grunt-aws-lambda tasks\n\n### Overview\n\nThis plugin contains 3 tasks:\n* lambda_invoke - Wrapper to run and test lambda functions locally and view output.\n* lambda_package - Packages function along with any npm dependencies in a zip format suitable for lambda.\n* lambda_deploy - Uploads the zip package to lambda.\n\nlambda_invoke and lambda_package can be used independently, lambda_deploy will invoke lambda_package before uploading\nthe produced zip file.\n\n### lambda_invoke\n\nIn your project's Gruntfile, add a section named `lambda_invoke` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n lambda_invoke: {\n default: {\n options: {\n // Task-specific options go here.\n }\n }\n },\n});\n```\n\n#### Options\n\n##### options.handler\nType: `String`\nDefault value: `handler`\n\nName of the handler function to invoke.\n\n##### options.file_name\nType: `String`\nDefault value: `index.js`\n\nName of your script file which contains your handler function.\n\n##### options.event\nType: `String`\nDefault value: `event.json`\n\nName of the .json file containing your test event relative to your Gruntfile.\n\n#### Usage Examples\n\n##### Default Options\nIn this example, the default options are used therefore if we have the following in our `Gruntfile.js`:\n\n```js\ngrunt.initConfig({\n lambda_invoke: {\n default: {\n options: {\n // Task-specific options go here.\n }\n }\n },\n});\n```\nAnd the following in `index.js`\n\n```js\nexports.handler = function (event, context) {\n console.log('value1 = ' + event.key1);\n console.log('value2 = ' + event.key2);\n console.log('value3 = ' + event.key3);\n\n context.done(null, 'Hello World'); // SUCCESS with message\n};\n```\n\nAnd the following in `event.json`\n```json\n{\n \"key1\": \"value1\",\n \"key2\": \"value2\",\n \"key3\": \"value3\"\n}\n```\n\nThen we run `grunt lambda_invoke`, we should get the following output:\n\n```\nRunning \"lambda_invoke\" task\n\nvalue1 = value1\nvalue2 = value2\nvalue3 = value3\n\nMessage\n-------\nHello World\n\nDone, without errors.\n```\n\n\n### lambda_package\n\nThis task generates a lambda package including npm dependencies using the default npm install functionality, therefore\n your dependencies must be included in the **bundledDependencies** section of your package.json to be included in the\n produced package.\n\nIn your project's Gruntfile, add a section named `lambda_package` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n lambda_package: {\n default: {\n options: {\n // Task-specific options go here.\n }\n }\n },\n});\n```\n\n#### Options\n\n##### options.include_files\nType: `Array`\nDefault value: `[]`\n\nList of files to explicitly include in the package, even if they would be ignored by NPM\n\n##### options.include_time\nType: `Boolean`\nDefault value: `true`\n\nWhether or not to timestamp the packages, if set to true the current date/time will be included in the zip name, if false\n then the package name will be constant and consist of just the package name and version.\n\n##### options.package_folder\nType: `String`\nDefault value: `./`\n\nThe path to your npm package, must contain the package.json file.\n\n##### options.dist_folder\nType: `String`\nDefault value: `dist`\n\nThe folder where the complete zip files should be saved relative to the Gruntfile.\n\n#### Usage Examples\n\n##### Default Options\nIn this example, the default options are used therefore if we have the following in our `Gruntfile.js`:\n\n```js\ngrunt.initConfig({\n lambda_package: {\n default: {\n options: {\n // Task-specific options go here.\n }\n }\n },\n});\n```\nAnd the following in `package.json`\n\n```json\n{\n \"name\": \"my-lambda-function\",\n \"description\": \"An Example Lamda Function\",\n \"version\": \"0.0.1\",\n \"private\": \"true\",\n \"dependencies\": {\n \"jquery\": \"2.1.1\"\n },\n \"devDependencies\": {\n \"grunt\": \"0.4.*\",\n \"grunt-pack\": \"0.1.*\",\n \"grunt-aws-lambda\": \"0.1.*\"\n },\n \"bundledDependencies\": [\n \"jquery\"\n ]\n}\n```\n\nThen we run `grunt lambda_package`, we should see a new zip file in a new folder called `dist` called something like:\n\n`my-lambda-function_0-0-1_2014-10-30-18-29-4.zip`\n\nIf you unzip that and look inside you should see something like:\n```\nindex.js\npackage.json\nnode_modules/\nnode_modules/jquery\nnode_modules/jquery/... etc\n```\n\nGiven that by default the dist folder is inside your function folder you can easily end up bundling previous packages\n inside subsequent packages therefore it is **strongly advised that you add dist to your .npmignore**.\n\nFor example your `.npmignore` might look something like this:\n```\nevent.json\nGruntfile.js\ndist\n*.iml\n```\n\n### lambda_deploy\n\nIn your project's Gruntfile, add a section named `lambda_deploy` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n lambda_deploy: {\n default: {\n options: {\n // Task-specific options go here.\n arn: 'arn:aws:lambda:us-east-1:123456781234:function:my-function'\n }\n }\n },\n});\n```\n\n#### Options\n\n\n##### arn\nType: `String`\nDefault value: None - Required\n\nThe ARN of your target Lambda function.\n\n##### function\nType: `String`\nDefault value: None - Required (if you havn't specified an ARN)\n\n*This option is deprecated, use arn instead*. The name of your target Lambda function, ie. the name of the function in the AWS console.\n\n##### package\nType: `String`\nDefault value: Package name set by package task of same target - see below.\n\nThe name of the package to be uploaded.\n\nWhen the lambda_package task runs it sets the package value for the lambda_deploy target with the same name.\n\nTherefore if lambda_package and lambda_deploy have a target (eg. default) with the same name you will not\n need to provide this value - it will be passed automatically.\n\nFor example, your Gruntfile.js might contain the following:\n\n\n```js\ngrunt.initConfig({\n lambda_deploy: {\n default: {\n arn: 'arn:aws:lambda:us-east-1:123456781234:function:my-function'\n }\n },\n lambda_package: {\n default: {\n }\n }\n});\n```\n\nYou could then run `grunt lambda_package lambda_deploy` and it'll automatically create the package and deploy it without\n having to specify a package name.\n\n##### options.profile\nType: `String`\nDefault value: `null`\n\nIf you wish to use a specific AWS credentials profile you can specify it here, otherwise it will use the environment default.\nYou can also specify it with the environment variable `AWS_PROFILE`\n\n##### options.RoleArn\nType: `String`\nDefault value: `null`\n\nIf you wish to assume a specific role from an EC2 instance you can specify it here, otherwise it will use the environment default.\n\n##### options.accessKeyId\nType: `String`\nDefault value: `null`\n\nIf you wish to use hardcoded AWS credentials you should specify the Access Key ID here\n\n##### options.secretAccessKey\nType: `String`\nDefault value: `null`\n\nIf you wish to use hardcoded AWS credentials you should specify the Secret Access Key here\n\n##### options.credentialsJSON\nType: `String`\nDefault value: `null`\n\nIf you wish to use hardcoded AWS credentials saved in a JSON file, put the path to the JSON here. The JSON must conform to the [AWS format](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Credentials_from_Disk).\n\n##### options.region\nType: `String`\nDefault value: `us-east-1`\n\nSpecify the AWS region your functions will be uploaded to. Note that if an ARN is supplied this option is not required.\n\n##### options.timeout\nType: `Integer`\nDefault value: `null`\nDepending on your Lambda function, you might need to increase the timeout value. The default timeout assigned by AWS is currently 3 seconds.\nIf you wish to increase this timeout set the value here.\n\n##### options.memory\n Type: `Integer`\n Default value: `null`\n Sets the memory assigned to the function. If null then the current setting for the function will be used. Value is in\n MB and must be a multiple of 64.\n\n#### Usage Examples\n\n##### Default Options\nIn this example, the default options are used therefore if we have the following in our `Gruntfile.js`:\n\n```js\ngrunt.initConfig({\n lambda_deploy: {\n default: {\n arn: 'arn:aws:lambda:us-east-1:123456781234:function:my-function'\n }\n }\n});\n```\nAnd now if you run `grunt lambda_deploy` your package should be created and uploaded to the specified function.\n\n\n##### Increasing the Timeout Options to 10 seconds\nIn this example, the timeout value is increased to 10 seconds and set memory to 256mb.\n\n```js\ngrunt.initConfig({\n lambda_deploy: {\n default: {\n arn: 'arn:aws:lambda:us-east-1:123456781234:function:my-function',\n options: {\n timeout : 10,\n memory: 256\n }\n }\n }\n});\n```\n\n## Misc info\n\n### Streamlining deploy\n\nYou can combine the lambda_package and lambda_deploy into a single deploy task by adding the following to your\n Gruntfile.js:\n\n```js\ngrunt.registerTask('deploy', ['lambda_package', 'lambda_deploy']);\n```\n\nYou can then run `grunt deploy` to perform both these functions in one step.\n\n### AWS credentials\n\nThe AWS SDK is configured to look for credentials in the following order:\n\n1. an IAM Role (if running on EC2)\n2. an AWS CLI profile (from `~/.aws/credentials`)\n3. environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`)\n4. a JSON file on disk\n5. Hardcoded credentials passed into grunt-aws\n\nThe preferred method of authenticating during local development is by providing credentials in `~/.aws/credentials`,\nit should look something like this:\n\n```\n[default]\naws_access_key_id = <YOUR_ACCESS_KEY_ID>\naws_secret_access_key = <YOUR_SECRET_ACCESS_KEY>\n```\n\nFor more information [read this documentation](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html).\n\n### AWS permissions\n\nTo run the deploy command the AWS credentials require permissions to access lambda including `lambda:GetFunction`,\n`lambda:UploadFunction`, `lambda:UpdateFunctionCode`, `lambda:UpdateFunctionConfiguration` and\n`iam:PassRole` for the role which is assigned to the function.\n\nIt is recommended that the following policy be applied to the user:\n\n```json\n{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"Stmt1442787227063\",\n \"Action\": [\n \"lambda:GetFunction\",\n \"lambda:UploadFunction\",\n \"lambda:UpdateFunctionCode\",\n \"lambda:UpdateFunctionConfiguration\"\n ],\n \"Effect\": \"Allow\",\n \"Resource\": \"arn:aws:lambda:*\"\n },\n {\n \"Sid\": \"Stmt1442787265773\",\n \"Action\": [\n \"iam:PassRole\"\n ],\n \"Effect\": \"Allow\",\n \"Resource\": \"arn:aws:iam::<my_account_id>:role/<my_role_name>\"\n }\n ]\n}\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n### 0.1.0\nInitial release\n\n### 0.2.0\nAdding some unit tests, refactoring deploy task into single task and converting tasks to multitasks\n\n### 0.3.0\nAdding more warnings for various failure cases\n\n### 0.4.0\n\n* Added support for succeed and fail functions - [pull request by jonyo](https://github.com/Tim-B/grunt-aws-lambda/pull/11)\n* Added NPM to package.json - [pull request by jonyo](https://github.com/Tim-B/grunt-aws-lambda/pull/13), should address [issue 2](https://github.com/Tim-B/grunt-aws-lambda/issues/2#issuecomment-104805707)\n* Added timeout and memory options - [timeout pull request by aidancasey](https://github.com/Tim-B/grunt-aws-lambda/pull/3)\n* Bumped aws-sdk version\n* Bumped adm-zip version, will hopefully address [issue 4](https://github.com/Tim-B/grunt-aws-lambda/issues/4)\n\n### 0.5.0\n* Fixed issue where dotfiles weren't packaged - [see issue 17](https://github.com/Tim-B/grunt-aws-lambda/issues/17)\n* Fixed issue where task could be done before zip writing is finished - [pull request by qen](https://github.com/Tim-B/grunt-aws-lambda/pull/16)\n* Monkey patched node-archiver to force permissions to be 777 for all files in package - [see issue 6](https://github.com/Tim-B/grunt-aws-lambda/issues/6)\n\n### 0.6.0\n* Fixing a minor issue caused by some code that shouldn't have been commented out.\n\n### 0.7.0\n* Removing some unneeded files from the NPM package.\n\n### 0.8.0\n* Adding `include_files` option to package - [pull request by dhleong](https://github.com/Tim-B/grunt-aws-lambda/pull/19)\n\n### 0.9.0\n* Parsing region automatically from ARN - [pull request by jvwing](https://github.com/Tim-B/grunt-aws-lambda/pull/25)\n\n### 0.10.0\n* Making NPM a regular dependency to resolve [#20](https://github.com/Tim-B/grunt-aws-lambda/issues/20) - [pull request by timdp](https://github.com/Tim-B/grunt-aws-lambda/pull/27)\n\n### 0.11.0\n* Including AWS API error message in deployment failure - [pull request by CaseyBurns](https://github.com/Tim-B/grunt-aws-lambda/pull/40)\n* Providing a method to pass AWS credentials in either the Gruntfile or credentials file - [pull request by robbiet480](https://github.com/Tim-B/grunt-aws-lambda/pull/34)\n* Adding support for AWS temporary credentials - [pull request by olih](https://github.com/Tim-B/grunt-aws-lambda/pull/46)", | ||
"readmeFilename": "README.md", | ||
"gitHead": "68a32c8cf1c6b11c82e27263c70e4e7a7c60d27c", | ||
"_id": "grunt-aws-lambda@0.11.0", | ||
"_shasum": "dbd59a2e5da4913fccba55295eb73f31572d64f1", | ||
"_from": "../grunt-aws-lambda", | ||
"_resolved": "file:../grunt-aws-lambda" | ||
} |
103
README.md
@@ -64,8 +64,7 @@ # grunt-aws-lambda | ||
## Specify AWS credentials in ~/.aws/credentials | ||
## Authenticating to AWS | ||
This will save you from accidentally committing AWS credentials. | ||
This library supports providing credentials for AWS via an IAM Role, an AWS CLI profile, environment variables, a JSON file on disk, or passed in credentials. | ||
To learn more, please see the [below section](#aws-credentials) | ||
[Read More](#aws-credentials) | ||
## grunt-aws-lambda tasks | ||
@@ -292,4 +291,4 @@ | ||
// Task-specific options go here. | ||
}, | ||
arn: 'arn:aws:lambda:us-east-1:123456781234:function:my-function' | ||
arn: 'arn:aws:lambda:us-east-1:123456781234:function:my-function' | ||
} | ||
} | ||
@@ -351,3 +350,28 @@ }, | ||
If you wish to use a specific AWS credentials profile you can specify it here, otherwise it will use the environment default. | ||
You can also specify it with the environment variable `AWS_PROFILE` | ||
##### options.RoleArn | ||
Type: `String` | ||
Default value: `null` | ||
If you wish to assume a specific role from an EC2 instance you can specify it here, otherwise it will use the environment default. | ||
##### options.accessKeyId | ||
Type: `String` | ||
Default value: `null` | ||
If you wish to use hardcoded AWS credentials you should specify the Access Key ID here | ||
##### options.secretAccessKey | ||
Type: `String` | ||
Default value: `null` | ||
If you wish to use hardcoded AWS credentials you should specify the Secret Access Key here | ||
##### options.credentialsJSON | ||
Type: `String` | ||
Default value: `null` | ||
If you wish to use hardcoded AWS credentials saved in a JSON file, put the path to the JSON here. The JSON must conform to the [AWS format](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Credentials_from_Disk). | ||
##### options.region | ||
@@ -363,4 +387,4 @@ Type: `String` | ||
Depending on your Lambda function, you might need to increase the timeout value. The default timeout assigned by AWS is currently 3 seconds. | ||
If you wish to increase this timeout set the value here. | ||
If you wish to increase this timeout set the value here. | ||
##### options.memory | ||
@@ -399,3 +423,3 @@ Type: `Integer` | ||
timeout : 10, | ||
memory: 256 | ||
memory: 256 | ||
} | ||
@@ -422,5 +446,13 @@ } | ||
The AWS SDK is configured to look for credentials in the environment, that is it will look in `~/.aws/credentials`. | ||
The AWS SDK is configured to look for credentials in the following order: | ||
This file should look something like: | ||
1. an IAM Role (if running on EC2) | ||
2. an AWS CLI profile (from `~/.aws/credentials`) | ||
3. environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`) | ||
4. a JSON file on disk | ||
5. Hardcoded credentials passed into grunt-aws | ||
The preferred method of authenticating during local development is by providing credentials in `~/.aws/credentials`, | ||
it should look something like this: | ||
``` | ||
@@ -436,6 +468,7 @@ [default] | ||
To run the deploy command the AWS credentials require permissions to access lambda including `lambda:UploadFunction` and | ||
`iam:PassRole` for the role which is assigned to the function. | ||
To run the deploy command the AWS credentials require permissions to access lambda including `lambda:GetFunction`, | ||
`lambda:UploadFunction`, `lambda:UpdateFunctionCode`, `lambda:UpdateFunctionConfiguration` and | ||
`iam:PassRole` for the role which is assigned to the function. | ||
It is recommended that the following two policies be applied to the user: | ||
It is recommended that the following policy be applied to the user: | ||
@@ -447,28 +480,19 @@ ```json | ||
{ | ||
"Sid": "Stmt1404366560000", | ||
"Effect": "Allow", | ||
"Sid": "Stmt1442787227063", | ||
"Action": [ | ||
"lambda:*" | ||
"lambda:GetFunction", | ||
"lambda:UploadFunction", | ||
"lambda:UpdateFunctionCode", | ||
"lambda:UpdateFunctionConfiguration" | ||
], | ||
"Resource": [ | ||
"*" | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
```json | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
"Effect": "Allow", | ||
"Resource": "arn:aws:lambda:*" | ||
}, | ||
{ | ||
"Sid": "Stmt1404366560000", | ||
"Effect": "Allow", | ||
"Sid": "Stmt1442787265773", | ||
"Action": [ | ||
"iam:PassRole" | ||
], | ||
"Resource": [ | ||
"arn:aws:iam::<my_account_id>:role/<my_role_name>" | ||
] | ||
"Effect": "Allow", | ||
"Resource": "arn:aws:iam::<my_account_id>:role/<my_role_name>" | ||
} | ||
@@ -494,3 +518,3 @@ ] | ||
* Added support for succeed and fail functions - [pull request by jonyo](https://github.com/Tim-B/grunt-aws-lambda/pull/11) | ||
* Added support for succeed and fail functions - [pull request by jonyo](https://github.com/Tim-B/grunt-aws-lambda/pull/11) | ||
* Added NPM to package.json - [pull request by jonyo](https://github.com/Tim-B/grunt-aws-lambda/pull/13), should address [issue 2](https://github.com/Tim-B/grunt-aws-lambda/issues/2#issuecomment-104805707) | ||
@@ -502,4 +526,4 @@ * Added timeout and memory options - [timeout pull request by aidancasey](https://github.com/Tim-B/grunt-aws-lambda/pull/3) | ||
### 0.5.0 | ||
* Fixed issue where dotfiles weren't packaged - [see issue 17](https://github.com/Tim-B/grunt-aws-lambda/issues/17) | ||
* Fixed issue where task could be done before zip writing is finished - [pull request by qen](https://github.com/Tim-B/grunt-aws-lambda/pull/16) | ||
* Fixed issue where dotfiles weren't packaged - [see issue 17](https://github.com/Tim-B/grunt-aws-lambda/issues/17) | ||
* Fixed issue where task could be done before zip writing is finished - [pull request by qen](https://github.com/Tim-B/grunt-aws-lambda/pull/16) | ||
* Monkey patched node-archiver to force permissions to be 777 for all files in package - [see issue 6](https://github.com/Tim-B/grunt-aws-lambda/issues/6) | ||
@@ -522,2 +546,5 @@ | ||
### 0.11.0 | ||
* Including AWS API error message in deployment failure - [pull request by CaseyBurns](https://github.com/Tim-B/grunt-aws-lambda/pull/40) | ||
* Providing a method to pass AWS credentials in either the Gruntfile or credentials file - [pull request by robbiet480](https://github.com/Tim-B/grunt-aws-lambda/pull/34) | ||
* Adding support for AWS temporary credentials - [pull request by olih](https://github.com/Tim-B/grunt-aws-lambda/pull/46) |
@@ -27,2 +27,6 @@ /* | ||
profile: null, | ||
RoleArn: null, | ||
accessKeyId: null, | ||
secretAccessKey: null, | ||
credentialsJSON: null, | ||
region: 'us-east-1', | ||
@@ -38,2 +42,21 @@ timeout: null, | ||
if (options.RoleArn !== null) { | ||
AWS.config.credentials = new AWS.EC2MetadataCredentials({ | ||
httpOptions: { timeout: 5000 } // 5 second timeout | ||
}); | ||
AWS.config.credentials = new AWS.TemporaryCredentials({ | ||
RoleArn: options.RoleArn | ||
}); | ||
} | ||
if (options.accessKeyId !== null && options.secretAccessKey !== null) { | ||
AWS.config.update({accessKeyId: options.accessKeyId, secretAccessKey: options.secretAccessKey}); | ||
} | ||
if (options.credentialsJSON !== null) { | ||
AWS.config.loadFromPath(options.credentialsJSON); | ||
} | ||
AWS.config.update({region: options.region}); | ||
var deploy_function = grunt.config.get('lambda_deploy.' + this.target + '.function'); | ||
@@ -68,3 +91,4 @@ var deploy_arn = grunt.config.get('lambda_deploy.' + this.target + '.arn'); | ||
} else { | ||
grunt.fail.warn('AWS API request failed, check your AWS credentials, region and permissions are correct.'); | ||
grunt.log.error('AWS API request failed with ' + err.statusCode + ' - ' + err); | ||
grunt.fail.warn('Check your AWS credentials, region and permissions are correct.'); | ||
} | ||
@@ -71,0 +95,0 @@ } |
Sorry, the diff of this file is not supported yet
58079
602
539