Skip to content

Commit be5bcfd

Browse files
jeskewsrchase
authored andcommitted
Add README files to credential provider packages (#52)
* Add README files to credential provider packages * Be stricter in documentation about which date strings are accepted
1 parent 843bb85 commit be5bcfd

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# AWS Credential Provider for Node.JS - Instance and Container Metadata
2+
3+
This module provides two `CredentialProvider` factory functions,
4+
`fromContainerMetadata` and `fromInstanceMetadata`, that will create
5+
`CredentialProvider` functions that read from the ECS container metadata service
6+
and the EC2 instance metadata service, respectively.
7+
8+
A `CredentialProvider` function created with `fromContainerMetadata` will return
9+
a promise that will resolve with credentials for the IAM role associated with
10+
containers in an Amazon ECS task. Please see [IAM Roles for Tasks](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html)
11+
for more information on using IAM roles with Amazon ECS.
12+
13+
A `CredentialProvider` function created with `fromInstanceMetadata` will return
14+
a promise that will resolve with credentials for the IAM role associated with
15+
an EC2 instance. Please see [IAM Roles for Amazon EC2](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html)
16+
for more information on using IAM roles with Amazon EC2.
17+
18+
## Supported configuration
19+
20+
You may customize how credentials are resolved by providing an options hash to
21+
the `fromContainerMetadata` and `fromInstanceMetadata` factory functions. The
22+
following options are supported:
23+
24+
* `timeout` - The connection timeout (in milliseconds) to apply to any remote
25+
requests. If not specified, a default value of `1000` (one second) is used.
26+
* `maxRetries` - The maximum number of times any HTTP connections should be
27+
retried. If not specified, a default value of `0` will be used.
28+
29+
Additionally, `fromInstanceMetadata` supports the following options:
30+
31+
* `profile` - The configuration profile to use. If not specified, the provider
32+
will use default profile name associated with the EC2 instance as reported by
33+
the Instance Metadata Service.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# AWS Shared Configuration File Loader
2+
3+
This module provides a function that reads from AWS SDK configuration files and
4+
returns a promise that will resolve with a hash of the parsed contents of the
5+
AWS credentials file and of the AWS config file. Given the [sample
6+
files](#sample-files) below, the promise returned by `loadSharedConfigFiles`
7+
would resolve with:
8+
9+
```javascript
10+
{
11+
configFile: {
12+
'default': {
13+
aws_access_key_id: 'foo',
14+
aws_secret_access_key: 'bar',
15+
},
16+
dev: {
17+
aws_access_key_id: 'foo1',
18+
aws_secret_access_key: 'bar1',
19+
},
20+
prod: {
21+
aws_access_key_id: 'foo2',
22+
aws_secret_access_key: 'bar2',
23+
},
24+
'testing host': {
25+
aws_access_key_id: 'foo4',
26+
aws_secret_access_key: 'bar4',
27+
}
28+
},
29+
credentialsFile: {
30+
'default': {
31+
aws_access_key_id: 'foo',
32+
aws_secret_access_key: 'bar',
33+
},
34+
dev: {
35+
aws_access_key_id: 'foo1',
36+
aws_secret_access_key: 'bar1',
37+
},
38+
prod: {
39+
aws_access_key_id: 'foo2',
40+
aws_secret_access_key: 'bar2',
41+
}
42+
},
43+
}
44+
```
45+
46+
If a file is not found, its key (`configFile` or `credentialsFile`) will instead
47+
have a value of an empty object.
48+
49+
## Supported configuration
50+
51+
You may customize how the files are loaded by providing an options hash to the
52+
`loadSharedConfigFiles` function. The following options are supported:
53+
54+
* `filepath` - The path to the shared credentials file. If not specified, the
55+
provider will use the value in the `AWS_SHARED_CREDENTIALS_FILE` environment
56+
variable or a default of `~/.aws/credentials`.
57+
* `configFilepath` - The path to the shared config file. If not specified, the
58+
provider will use the value in the `AWS_CONFIG_FILE` environment variable or a
59+
default of `~/.aws/config`.
60+
61+
## Sample files
62+
63+
### `~/.aws/credentials`
64+
```ini
65+
[default]
66+
aws_access_key_id=foo
67+
aws_secret_access_key=bar
68+
69+
[dev]
70+
aws_access_key_id=foo2
71+
aws_secret_access_key=bar2
72+
73+
[prod]
74+
aws_access_key_id=foo3
75+
aws_secret_access_key=bar3
76+
```
77+
78+
### `~/.aws/config`
79+
```ini
80+
[default]
81+
aws_access_key_id=foo
82+
aws_secret_access_key=bar
83+
84+
[profile dev]
85+
aws_access_key_id=foo2
86+
aws_secret_access_key=bar2
87+
88+
[profile prod]
89+
aws_access_key_id=foo3
90+
aws_secret_access_key=bar3
91+
92+
[profile "testing host"]
93+
aws_access_key_id=foo4
94+
aws_secret_access_key=bar4
95+
```

0 commit comments

Comments
 (0)