-
Notifications
You must be signed in to change notification settings - Fork 503
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
Use AWS ECS credentials #1283
Comments
@johnjelinek |
Yes, I bootstrap it out of process and have no way to send updates although
that URL is available during the lifetime of the container and is always
available to get new values. The AWS SDK should have support to make
fetching these credentials seamless if you wanted to provide another way
for Athens to learn about its IAM task role.
…On Wed, Jun 12, 2019, 2:02 PM marpio ***@***.***> wrote:
@johnjelinek <https://github.com/johnjelinek>
Just for my understanding - the problem is that currently Athens fetches
the credentials only once (either from the config file or environment
variables) while starting and there is no way to provide new credentials?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1283?email_source=notifications&email_token=AAGVJCX3RC6KOZHQOW2BXSTP2FB3DA5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXRPGOI#issuecomment-501412665>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGVJCUJOKCJC2VZGERT2E3P2FB3DANCNFSM4HXM6B5Q>
.
|
Athens s3 config file contains the
Would that be of any help to you? |
No, I first tried setting that to true and it didn't find the credentials.
That's why I made that bootstrapping process to inject values into the
config file.
…On Wed, Jun 12, 2019, 2:58 PM marpio ***@***.***> wrote:
Athens s3 config file contains the UseDefaultConfiguration option. If
it's set to true then, instead of using credentials.NewStaticCredentials
the defaults are being used.
Fom docs:
// The credentials object to use when signing requests. Defaults to a
// chain of credential providers to search for credentials in environment
// variables, shared credential file, and EC2 Instance Roles.
Would that be of any help to you?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1283?email_source=notifications&email_token=AAGVJCTIMOA6S7PKOQ7N2ELP2FIMRA5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXRUAXQ#issuecomment-501432414>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGVJCVYIWATK3PC7CU46VLP2FIMRANCNFSM4HXM6B5Q>
.
|
Hi,
What happens when you do not add credentials to the config file? If Athens
does not start, I think we should fix this as we can get credentials from
A) Profile (default / otherwise)
B) Config
C) Env (for security token)
Cheers,
Manu Gupta
On Wed, Jun 12, 2019 at 2:09 PM John Jelinek IV <[email protected]>
wrote:
… No, I first tried setting that to true and it didn't find the credentials.
That's why I made that bootstrapping process to inject values into the
config file.
On Wed, Jun 12, 2019, 2:58 PM marpio ***@***.***> wrote:
> Athens s3 config file contains the UseDefaultConfiguration option. If
> it's set to true then, instead of using credentials.NewStaticCredentials
> the defaults are being used.
> Fom docs:
>
> // The credentials object to use when signing requests. Defaults to a
> // chain of credential providers to search for credentials in environment
> // variables, shared credential file, and EC2 Instance Roles.
>
> Would that be of any help to you?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <
#1283?email_source=notifications&email_token=AAGVJCTIMOA6S7PKOQ7N2ELP2FIMRA5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXRUAXQ#issuecomment-501432414
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/AAGVJCVYIWATK3PC7CU46VLP2FIMRANCNFSM4HXM6B5Q
>
> .
>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1283?email_source=notifications&email_token=AADAXDYECMP6YO2ILGF7AXDP2FQY3A5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXRZ4OA#issuecomment-501456440>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADAXD6WYFE7UMH645NX37TP2FQY3ANCNFSM4HXM6B5Q>
.
|
If I do not add credentials, athens starts and I can get the metrics
endpoint, but all artifact requests respond with 500 because it can't get
the credentials of the ECS task.
…On Wed, Jun 12, 2019, 4:29 PM Manu Gupta ***@***.***> wrote:
Hi,
What happens when you do not add credentials to the config file? If Athens
does not start, I think we should fix this as we can get credentials from
A) Profile (default / otherwise)
B) Config
C) Env (for security token)
Cheers,
Manu Gupta
On Wed, Jun 12, 2019 at 2:09 PM John Jelinek IV ***@***.***>
wrote:
> No, I first tried setting that to true and it didn't find the
credentials.
> That's why I made that bootstrapping process to inject values into the
> config file.
>
> On Wed, Jun 12, 2019, 2:58 PM marpio ***@***.***> wrote:
>
> > Athens s3 config file contains the UseDefaultConfiguration option. If
> > it's set to true then, instead of using
credentials.NewStaticCredentials
> > the defaults are being used.
> > Fom docs:
> >
> > // The credentials object to use when signing requests. Defaults to a
> > // chain of credential providers to search for credentials in
environment
> > // variables, shared credential file, and EC2 Instance Roles.
> >
> > Would that be of any help to you?
> >
> > —
> > You are receiving this because you were mentioned.
> > Reply to this email directly, view it on GitHub
> > <
>
#1283?email_source=notifications&email_token=AAGVJCTIMOA6S7PKOQ7N2ELP2FIMRA5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXRUAXQ#issuecomment-501432414
> >,
> > or mute the thread
> > <
>
https://github.com/notifications/unsubscribe-auth/AAGVJCVYIWATK3PC7CU46VLP2FIMRANCNFSM4HXM6B5Q
> >
> > .
> >
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <
#1283?email_source=notifications&email_token=AADAXDYECMP6YO2ILGF7AXDP2FQY3A5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXRZ4OA#issuecomment-501456440
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/AADAXD6WYFE7UMH645NX37TP2FQY3ANCNFSM4HXM6B5Q
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1283?email_source=notifications&email_token=AAGVJCSVUQZQWJS45O4W6Y3P2FTDPA5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXR3KCQ#issuecomment-501462282>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGVJCTEBUCXRVE3OGQBMTTP2FTDPANCNFSM4HXM6B5Q>
.
|
@johnjelinek since you're fetching the credentials from an endpoint currently - we could support https://docs.aws.amazon.com/sdk-for-go/api/aws/credentials/endpointcreds/ cc: @manugupt1 |
That should work. The endpoint will always be the same in AWS ECS (Fargate).
…On Thu, Jun 13, 2019, 6:24 AM marpio ***@***.***> wrote:
@johnjelinek <https://github.com/johnjelinek> since you're fetching the
credentials from an endpoint currently - we could support
https://docs.aws.amazon.com/sdk-for-go/api/aws/credentials/endpointcreds/
cc: @manugupt1 <https://github.com/manugupt1>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1283?email_source=notifications&email_token=AAGVJCU2VL5BXM3U7AAIDDTP2IU7BA5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXTMFSA#issuecomment-501662408>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGVJCVROOVNX4WINMUDEVDP2IU7BANCNFSM4HXM6B5Q>
.
|
Yep! that should work. I would like to work on it. I should have a PR next week. |
I just had to add this kind of support to another project. This works:
|
apparently |
@marpio: any updates? |
@manugupt1 are you still on it? |
yep! sorry did not notice it got assigned to me. I looked into it a bit now. It seems like we can end up using a combination of Static and Env credentials and if we get a 403, then we re-try by fetching new credentials rather than enforcing an HTTP handler. This will enable users to inject new credentials in whatever way they see fit (HTTP / otherwise) What do you think? Ref: https://github.com/aws/aws-sdk-go/blob/master/aws/credentials/env_provider.go#L36 |
@manugupt1 What is your opinion @johnjelinek ? |
Precisely. It knows when it's expired and when you call |
I am currently in the same situation as @johnjelinek. That feature would be highly appreciated. |
Yep! I have an idea on what to do. I am working on a PR soon and expect it in a couple of days. |
FYI: Ran into some issues. Here is a draft PR: #1291 Please start putting in comments so that I can address as I make changes to it. |
@manugupt1 What kind of issues? |
@marpio I have added a PR that is ready for review. https://github.com/gomods/athens/pull/1291/files Do you think we should also add a unit test that spins up a server and retrieves creds from that server and see if the test succeeds? |
any new updates on this @marpio? |
Hi I have a patch PR, I was travelling and am on-call, so I will try to get
to it asap.
Cheers,
Manu Gupta
…On Tue, Jul 16, 2019 at 11:38 AM John Jelinek IV ***@***.***> wrote:
any new updates on this @marpio <https://github.com/marpio>?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1283?email_source=notifications&email_token=AADAXD43ZRVMOJEDJPZGYX3P7YISJA5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2BYNHA#issuecomment-511936156>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADAXD7L2H5MK3VZWRUN6D3P7YISJANCNFSM4HXM6B5Q>
.
|
@marpio / @manugupt1: I'm having difficulty getting this to work. Here's my config change:
but I'm getting an exception:
|
One of the tricky things about running this in AWS ECS Fargate is that the URL changes every time. I have to do something like this in a sidecar |
@johnjelinek I have been able to get a 403 on this with endpoint creds. Can you verify if it works with real ones: #1325 |
Cool! I think that looks good. Can you push this to the canary container so I can pull it in Fargate? |
@johnjelinek canary should be pushed on every master build so you should be able to test it. |
@marpio: works great! The only other part that would make this nicer is if it could figure out the endpoint in process instead of me having to use a sidecar to generate the URL to pass into the config. |
@johnjelinek glad to hear that! Line 11 in a336c55
|
@marpio: no, the env var would have to be set a deploy-time, but AWS generates it dynamically, so I generate the URL at run-time in a sidecar, modifying the config file in a shared volume, and then I start the athens container -- however, the URL is always discoverable at: Do you think it makes sense to add support for resolving other env vars so I could set it like this:
Or do you think it makes more sense to embed this endpoint as a default URL, since it's always available here when running in AWS Fargate (and then I don't have to pass in an endpoint at all)? |
@johnjelinek Can you be a bit more clear? Is it a new URI that it generates or do the tokens expire after a while? |
A service, in Fargate, is an essential container and a collection of sidecars that run to provide functionality. Every time a service starts in Fargate, the environment variable To simplify, if |
@johnjelinek to keep track I am reopening the issue. Can you look at this PR and see if it makes sense: https://github.com/gomods/athens/pull/1337/files |
I'm not sure this makes sense. It doesn't look like it's linking to anything from the environment. I think what you're trying to implement is an environment variable alias. The |
We use envconfig that should help override env vars.
https://github.com/kelseyhightower/envconfig/blob/master/README.md
That should work! Is there an easy way for you to test this branch? If not, let’s figure something out
Cheers
Manu
…________________________________
From: John Jelinek IV <[email protected]>
Sent: Tuesday, August 13, 2019 5:53 AM
To: gomods/athens
Cc: Manu Gupta; State change
Subject: Re: [gomods/athens] Use AWS ECS credentials (#1283)
I'm not sure this makes sense. It doesn't look like it's linking to anything from the environment. I think what you're trying to implement is an environment variable alias. The $AWS_CONTAINER_CREDENTIALS_RELATIVE_URI is already an environment variable, it's not part of the URL. It might make more sense to see if AWS_CONTAINER_CREDENTIALS_RELATIVE_URI exists as an env var and if so, evaluate AWS_CREDENTIALS_ENDPOINT to whatever that evaluates to instead of requiring and config input.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub<#1283?email_source=notifications&email_token=AADAXD6S6RQQTOSX52GIV4TQEKVDPA5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4FRZYA#issuecomment-520821984>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AADAXD7FZDTSJLHO7HVT4PTQEKVDPANCNFSM4HXM6B5Q>.
|
@manugupt1: If you could push your latest changes to the canary container release, I can pull it in and try it out ... I suspect it won't work, but let's find out! |
@manugupt1: I left comments on your PR |
@johnjelinek It should work as I tested out printing out exported env vars. I will open the PR for review and see if everyone is okay to merge it in. |
cool, when it gets to the canary container, I'll try it out |
It should be on canary now can you test it John! Thanks
Cheers
Manu
…________________________________
From: John Jelinek IV <[email protected]>
Sent: Wednesday, August 14, 2019 9:51 AM
To: gomods/athens
Cc: Manu Gupta; Mention
Subject: Re: [gomods/athens] Use AWS ECS credentials (#1283)
cool, when it gets to the canary container, I'll try it out
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#1283?email_source=notifications&email_token=AADAXDZPYK3EDGY7DLGGYS3QEQZY5A5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4JNGSI#issuecomment-521327433>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AADAXD64J43K44CQMZBU4N3QEQZY5ANCNFSM4HXM6B5Q>.
|
Excellent, I should be able to test it tomorrow |
@manugupt1: canary works great. I removed all my sidecars and it still works with this env var:
I think can be closed now. It might be nice to document somewhere that |
Is it a global endpoint or is it region specific?
Cheers
Manu
…________________________________
From: John Jelinek IV <[email protected]>
Sent: Thursday, August 22, 2019 9:32 AM
To: gomods/athens
Cc: Manu Gupta; Mention
Subject: Re: [gomods/athens] Use AWS ECS credentials (#1283)
@manugupt1<https://github.com/manugupt1>: canary works great. I removed all my sidecars and it still works with this env var:
{
"name": "AWS_CREDENTIALS_ENDPOINT",
"value": "http://169.254.170.2"
}
I think can be closed now. It might be nice to document somewhere that http://169.254.170.2 is the default Fargate endpoint for everyone.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#1283?email_source=notifications&email_token=AADAXD2TMQOEZOCQNTCNWHTQF25SRA5CNFSM4HXM6B52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD45U46I#issuecomment-523980409>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AADAXD35QFHU6SWC4JR6TZTQF25SRANCNFSM4HXM6B5Q>.
|
global |
@johnjelinek : I want to use the aws credentials in AWS Fargate. I am using a golang docker container to read some AWS SSM Params and need credentials. Can you please help me with this snippet.. sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
svc := ssm.New(sess) I am unable to access any ssm secrets. |
Is your feature request related to a problem? Please describe.
When running athens in AWS ECS (Fargate), the environment is provided credentials through a different avenue than the usual environment variables (i.e.:
AWS_ACCESS_KEY_ID
). I have a sidecar process go fetch the credentials and inject them into the config file:The problem is that these credentials expire and I don't have a way to have athens fetch the updated credentials in the running instance.
Describe the solution you'd like
I'd like athens to be able to fetch these credentials from the environment automatically.
Describe alternatives you've considered
Right now, I have a health check on the athens instances that fetch a package that is stored on S3. When that fails, the health check fails and the instance is destroyed and a new one is provisioned in its place with valid credentials.
The text was updated successfully, but these errors were encountered: