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

no way how to use proxy with SDK v1 #1066

Closed
lcmgh opened this issue Feb 15, 2024 · 2 comments
Closed

no way how to use proxy with SDK v1 #1066

lcmgh opened this issue Feb 15, 2024 · 2 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@lcmgh
Copy link

lcmgh commented Feb 15, 2024

Describe the bug

I am opening this issue because I think it is quite crucial even there is a related issue #169 (that focused mostly and had solutions for SDK < v1) .

In corporate environments that require a proxy for internet access one cannot use the AWS SDK locally as such a configuration is not documented and it is unclear whether it is technically supported. For versions < 1 we had working solutions #169

Expected Behavior

  • Technical feature that allows to configure proxies
  • Doc that outlines how to configure such a http proxy

Current Behavior

  • Unclear whether this is supported
  • Unclear how proxy can be configured

Reproduction Steps

Possible Solution

No response

Additional Information/Context

No response

Version

v1

Environment details (OS name and version, etc.)

not relevant

Logs

No response

@lcmgh lcmgh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 15, 2024
@lcmgh lcmgh changed the title no way how to use proxy with v1 no way how to use proxy with SDK v1 Feb 15, 2024
@lcmgh
Copy link
Author

lcmgh commented Feb 20, 2024

I stand corrected. Using hyper v0.14 with hyper-proxy works perfectly fine.

use hyper_proxy::{Intercept, Proxy, ProxyConnector};
use url::Url;
use headers::Authorization;
use hyper::Uri;
use hyper::client::HttpConnector;


/// Returns `ProxyConnector<HttpConnector>` if env. variable 'https_proxy' is set
pub fn determine_proxy() -> Option<ProxyConnector<HttpConnector>> {
    let proxy_url: Url = std::env::var("https_proxy").ok()?.parse().ok()?;
    let proxy_uri: Uri = std::env::var("https_proxy").ok()?.parse().ok()?;
    let mut proxy = Proxy::new(Intercept::All, proxy_uri);

    if let Some(password) = proxy_url.password() {
        proxy.set_authorization(Authorization::basic(proxy_url.username(), password));
    }

    let connector = HttpConnector::new();
    Some(ProxyConnector::from_proxy(connector, proxy).unwrap())
}

Cargo.toml

[dependencies]
hyper = { version = "0.14", features = ["client"] }
hyper-proxy = "0.9.1"
headers = "0.3.0"
url = "2.5.0"

// Usage

  let proxy = determine_proxy().unwrap();
  let client = aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder::new().build(proxy);

  let aws_config = aws_config::load_from_env()
      .await
      .into_builder()
      .http_client(client.clone())
      .region(Region::new("eu-central-1"))
      .build();

  let sts = aws_sdk_sts::config::Builder::from(&aws_config)
      .build();

@lcmgh lcmgh closed this as completed Feb 20, 2024
Copy link

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant