Skip to content

Commit

Permalink
docker usage examples. modified credential chain to actually include …
Browse files Browse the repository at this point in the history
…the provided profile
  • Loading branch information
joona committed May 30, 2017
1 parent 5e60adc commit 6095cbd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,29 @@ $ curl http://localhost:9200
}
```

## With Docker

```
docker build -t aws-es-proxy .
```

Run and specify credentials via ENV variables.

```
docker run -it --rm -p 9210:9200 \
-e AWS_ACCESS_KEY_ID=... \
-e AWS_SECRET_ACCESS_KEY=... \
aws-es-proxy -- <elasticsearch_url>
```

Utilise configuration and profiles from the host.

```
docker run -it -v $HOME/.aws:/root/.aws --rm -p 9210:9200 \
aws-es-proxy -- --profile <profile_name> <elasticsearch_url>
```


## Related
* [aws-es-curl](https://github.com/joona/aws-es-curl)

21 changes: 13 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
var AWS = require('aws-sdk');
var co = require('co');
var url = require('url');
var http = require('http');
var options = require('optimist')
const AWS = require('aws-sdk');
const co = require('co');
const url = require('url');
const http = require('http');
const options = require('optimist')
.argv;

var context = {};
const context = {};
const profile = process.env.AWS_PROFILE || options.profile || 'default';

var profile = process.env.AWS_PROFILE || options.profile || 'default';
var creds = {};
AWS.CredentialProviderChain.defaultProviders = [
() => { return new AWS.EnvironmentCredentials('AWS'); },
() => { return new AWS.EnvironmentCredentials('AMAZON'); },
() => { return new AWS.SharedIniFileCredentials({ profile: profile }); },
() => { return new AWS.EC2MetadataCredentials(); }
];

var execute = function(endpoint, region, path, method, body) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -135,7 +141,6 @@ var main = function() {
}

var chain = new AWS.CredentialProviderChain();
chain.providers.push(new AWS.SharedIniFileCredentials({ profile }));
yield chain.resolvePromise()
.then(function (credentials) {
creds = credentials;
Expand Down

0 comments on commit 6095cbd

Please sign in to comment.