Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: support AWS WebIdentityProvider credentials configuration #2168

Closed
serejke opened this issue May 4, 2023 · 3 comments
Closed

Feature: support AWS WebIdentityProvider credentials configuration #2168

serejke opened this issue May 4, 2023 · 3 comments

Comments

@serejke
Copy link
Contributor

serejke commented May 4, 2023

Objective

Currently, the only way to configure AWS credentials for agents to access S3 and KMS is by passing env variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. This is not the best security practice as the specified credentials never expire.

The recommended approach for integrating AWS roles for EKS pods is to use IAM roles for ServiceAccount (IRSA). The IRSA webhook automatically sets up AWS_WEB_IDENTITY_TOKEN_FILE and AWS_ROLE_ARN env variables on the pod, and mounts the web identity token file.

What needs to be changed in code

Hyperlane uses rusoto SDK for AWS services, which, by the way, is in maintenance mode (consider migrating to the official AWS SDK for Rust ?).

Rusoto has a ProvideAwsCredentials trait, which has several implementations. Currently, the EnvironmentProvider is used:

EnvironmentProvider::default(),

EnvironmentProvider::default(),

we can provide a configuration flag to use WebIdentityProvider instead.

Suggestion:

SignerConf.Aws

can be extended with a new credentials_type: AwsCredentialsType enum AwsCredentialsType = EnvironmentVariables | WebIdentityFile with the default value of EnvironmentVariables, and depending on the enum value, the EnvironmentProvider or WebIdentityProvider is created.

Related discussion

This issue was first discovered by @kuzirashi and mentioned in Discord.

@nambrot
Copy link
Contributor

nambrot commented May 4, 2023

Thanks for filing this. Agree that we should probably move off and support the recommended configuration path. Is that something you think the Khalani team could take on?

@tkporter
Copy link
Collaborator

tkporter commented May 4, 2023

related re: rusoto - probably makes sense to switch when ethers-rs does gakonst/ethers-rs#2312

serejke added a commit to tvl-labs/hyperlane-monorepo that referenced this issue May 4, 2023
serejke added a commit to tvl-labs/hyperlane-monorepo that referenced this issue May 4, 2023
serejke added a commit to tvl-labs/hyperlane-monorepo that referenced this issue May 10, 2023
serejke added a commit to tvl-labs/hyperlane-monorepo that referenced this issue May 15, 2023
serejke added a commit to tvl-labs/hyperlane-monorepo that referenced this issue May 15, 2023
serejke added a commit to tvl-labs/hyperlane-monorepo that referenced this issue May 18, 2023
serejke added a commit to tvl-labs/hyperlane-monorepo that referenced this issue May 19, 2023
asaj pushed a commit that referenced this issue May 19, 2023
### Description

Support of web identity AWS credentials:
#2168

### Drive-by changes

`WebIdentityProvider` resides in `rusoto_sts`, I had to add a dependency
on `rusoto_sts = "*"`.

### Backward compatibility

_Are these changes backward compatible?_

Yes. The newly added `AwsChainCredentialsProvider` preserves 100%
compatibility with clients using `EnvironmentProvider`. We tested the
following scenarios:
1) Run agent with `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` /
`AWS_SESSION_TOKEN` credentials — the current default behavior — works
as before.
2) Without envs from p.1 but with `AWS_WEB_IDENTITY_TOKEN_FILE` /
`AWS_ROLE_ARN` / `AWS_ROLE_SESSION_NAME` injected by AWS EKS pod
identity
[webhook](https://github.com/aws/amazon-eks-pod-identity-webhook) —
works well. We ran the agents for 24+ hours to make sure the JWT gets
refreshed automatically.
3) Without any envs — the app expectedly fails with "environment
variable not found" error.

_Are there any infrastructure implications, e.g. changes that would
prohibit deploying older commits using this infra tooling?_

None

### Testing

Manual: we deployed a Hyperlane agent Docker image built from our
[fork](https://github.com/tvl-labs/hyperlane-monorepo/pkgs/container/hyperlane-monorepo).
@yorhodes
Copy link
Member

yorhodes commented Jun 2, 2023

closed by #2188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants