Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

using instance profile for AWS SDK authentication #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
```

If `instanceProfile` parameter is passed, the aws-sdk will be initialised using the instance's profile and use them for your invalidation job. You will need to ensure that the instance role has enough privileges(cloudfront access).

Then in the jobs options:
```javascript
grunt.initConfig({
cloudfront: {
options: {
region:'us-east-1', // your AWS region
distributionId:"YOUR_DISTRIBUTION_ID", // DistributionID where files are stored
instanceProfile: true,
listInvalidations:true,
listDistributions:false,
version:"1.0"
}
}
```

You can also store them in a git ignored credential file and pass them as options to the grunt job:

Expand Down
2 changes: 2 additions & 0 deletions tasks/grunt-cloudfront.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ module.exports = function(grunt) {

if (options.awsProfile){
creds = new AWS.SharedIniFileCredentials({profile: options.awsProfile});
}else if(options.instanceProfile) {
creds = new AWS.EC2MetadataCredentials();
}else {
creds = {
accessKeyId: (process.env.AWS_ACCESS_KEY_ID || options.credentials.accessKeyId),
Expand Down