Skip to content

authentication at proxy is not supported #2526

New issue

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

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

Already on GitHub? # to your account

Closed
milesqi opened this issue Mar 13, 2021 · 5 comments
Closed

authentication at proxy is not supported #2526

milesqi opened this issue Mar 13, 2021 · 5 comments
Labels
closed-for-staleness guidance Question that needs advice or information. response-requested Waiting on additional info or feedback. Will move to "closing-soon" in 5 days.

Comments

@milesqi
Copy link

milesqi commented Mar 13, 2021

Hello, looks like java sdk doesn't support aws service authentication on a proxy. I have a proxy server with a iam role for s3 bucket access attached. When I use aws cli to access my s3 bucket via this proxy(HTTP_PROXY=http://proxy_host:proxy_port), it works. I don't have any credentials configured one the machine where I issue aws cli command. However, on same machine, using aws java sdk, I can't access s3 bucket via same proxy because aws java sdk requires a credentials. there doesn't seem to be any credential providers available for this scenario.

In a short:

  • aws cli (no credentials -> proxy server (iam role configured) -> s3 -> SUCCESS
  • aws java sdk (no credential) -> proxy server (iam role configured) -> s3 -> FAILURE (can't create client without credential)
@debora-ito
Copy link
Member

@milesqi what do you mean by "proxy server (iam role configured)"? How is the IAM role being configured?

Can you provide a sample code of how you are creating the client?
And what AWS SDK version are you using?

@debora-ito debora-ito added guidance Question that needs advice or information. response-requested Waiting on additional info or feedback. Will move to "closing-soon" in 5 days. labels Mar 15, 2021
@milesqi
Copy link
Author

milesqi commented Mar 15, 2021

Hi @debora-ito ,
I created a proxy server (running in ec2 instance) in aws vpc, it's assigned with a iam role for a s3 bucket access. I run aws cli from a vm in our on-premise data center (aws vpc is connected to on-premise data center through some secured tunnel). The idea is that any apps running in on-premise data center can access s3 bucket without local credential configuration if it's allowed to use this proxy server. It's like a remote InstanceProfileCredentialsProvider to me. AWS SDK that I use is 2.16.7. I tried a few different ways for client code. none of them works.

I have a feeling that aws java skd is always expecting to find credential locally. But it looks like aws cli can find credentials from remote. Here is logs from aws cli for your reference.
2021-03-15 11:27:49,807 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env
2021-03-15 11:27:49,807 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role
2021-03-15 11:27:49,808 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity
2021-03-15 11:27:49,808 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: sso
2021-03-15 11:27:49,808 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file
2021-03-15 11:27:49,808 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: custom-process
2021-03-15 11:27:49,808 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: config-file
2021-03-15 11:27:49,808 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: ec2-credentials-file
2021-03-15 11:27:49,809 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: boto-config
2021-03-15 11:27:49,809 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: container-role
2021-03-15 11:27:49,809 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: iam-role
2021-03-15 11:27:49,811 - MainThread - urllib3.connectionpool - DEBUG - Starting new HTTP connection (1): .elb.us-west-2.amazonaws.com:8888
2021-03-15 11:27:50,073 - MainThread - urllib3.connectionpool - DEBUG - http://
.elb.us-west-2.amazonaws.com:8888 "PUT http://169.254.169.254/latest/api/token HTTP/1.1" 200 56
2021-03-15 11:27:50,074 - MainThread - urllib3.connectionpool - DEBUG - Resetting dropped connection: ac94f7012ab5e4405a28a41f48a02c0d-317134de08b48933.elb.us-west-2.amazonaws.com
2021-03-15 11:27:50,343 - MainThread - urllib3.connectionpool - DEBUG - http://.elb.us-west-2.amazonaws.com:8888 "GET http://169.254.169.254/latest/meta-data/iam/security-credentials/ HTTP/1.1" 200 63
2021-03-15 11:27:50,344 - MainThread - urllib3.connectionpool - DEBUG - Resetting dropped connection: ac94f7012ab5e4405a28a41f48a02c0d-317134de08b48933.elb.us-west-2.amazonaws.com
2021-03-15 11:27:50,615 - MainThread - urllib3.connectionpool - DEBUG - http://
.elb.us-west-2.amazonaws.com:8888 "GET http://169.254.169.254/latest/meta-data/iam/security-credentials/arn:aws:iam::838711373148:role/etl-s3-dev-iam-role HTTP/1.1" 200 615

@github-actions github-actions bot removed the response-requested Waiting on additional info or feedback. Will move to "closing-soon" in 5 days. label Mar 15, 2021
@milesqi
Copy link
Author

milesqi commented Mar 15, 2021

Hi @debora-ito
It looks like it's caused by this line, didn't find similar thing in aws cli code. Instead, aws cli uses NO_PROXY env var to control that rather than hard code it. (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-proxy.html)

@debora-ito
Copy link
Member

@milesqi Apologies for the delayed reply, and thank you for the follow-up comments. I see the issue now, you are trying to use an InstanceProfile credential but not able to because of proxy configurations.

Have you tried to set the instance metadata endpoint to the http.nonProxyHosts system property? If you're using Apache HTTP Client the proxy configuration is also available in the ApacheHttpClient.Builder.

@debora-ito debora-ito added the response-requested Waiting on additional info or feedback. Will move to "closing-soon" in 5 days. label May 7, 2021
@github-actions
Copy link

It looks like this issue hasn’t been active in longer than a week. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please add a comment to prevent automatic closure, or if the issue is already closed please feel free to reopen it.

@github-actions github-actions bot added closing-soon This issue will close in 2 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will close in 2 days unless further comments are made. labels May 14, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
closed-for-staleness guidance Question that needs advice or information. response-requested Waiting on additional info or feedback. Will move to "closing-soon" in 5 days.
Projects
None yet
Development

No branches or pull requests

2 participants