github.com/y2k2mt/aws-credentials.cr

Get AWS credentials in various ways.

6 stars
0 dependents
License: MIT

Nothing has been indexed for 0.3.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  aws-credentials:
    github: y2k2mt/aws-credentials.cr
    version: ~> 0.3.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.3.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

# aws-credentials

[![Crystal CI](https://github.com/y2k2mt/aws-credentials.cr/workflows/Crystal%20CI/badge.svg)](https://github.com/y2k2mt/aws-credentials.cr/actions)
[![Releases](https://img.shields.io/github/release/y2k2mt/aws-credentials.cr.svg?maxAge=360)](https://github.com/y2k2mt/aws-credentials.cr/releases)
 
Get AWS credentials in various ways.

## Installation

1. Add the dependency to your `shard.yml`:

```yaml
dependencies:
  aws-credentials:
    github: y2k2mt/aws-credentials.cr
```

2. Run `shards install`

## Usage

`Providers` resolves credentials in order from given` Provider`.

In the example below, at first ,`Providers` resolves credentials from EnvProvider ('AWS_ACCESS_KEY_ID' and 'AWS_SECRET_ACCESS_KEY' in env) and then resolves credentials from SharedCredentialFileProvider ('~/.aws/credentials').

```crystal
require "aws-credentials"

include Aws::Credentials

provider = Providers.new ([
  EnvProvider.new,
  SharedCredentialFileProvider.new
] of Provider)

credentials = provider.credentials
# Aws::Credentials::Credentials(@access_key_id="AKIA...",@expiration=nil,@secret_access_key="mVlf...",@session_token=nil)
```

Current `Provider` implementation is as follows:
- [EnvProvider](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html)
- [SharedCredentialFileProvider](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)
- [InstanceMetadataProvider](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html)
- [ContainerCredentialProvider](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html)
- [AssumeRoleProvider](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html)
  - Usage: Please watch `spec/it/assume_role_with_sts_spec.cr`
- [AssumeRoleWithWebIdentityProvider](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html)
  - Usage: Please watch `spec/it/assume_role_with_sts_spec.cr`
- SimpleCredentials (Simply holds given credentials)

## Contributing

1. Fork it (<https://github.com/y2k2mt/aws-credentials/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Contributors

- [y2k2mt](https://github.com/y2k2mt) - creator and maintainer