Skip to content

Conversation

@johannesfloriangeiger
Copy link
Contributor

@johannesfloriangeiger johannesfloriangeiger commented Jul 4, 2025

Summary

See title, enables AWS authentication for the http_client source.

Vector configuration

[sources.http_client]
type = "http_client"
endpoint = "<ENDPOINT>"
auth = {strategy = "aws", auth = {}, service = "aps"}
method = "POST"
headers.Content-Type = ["application/x-www-form-urlencoded"]
query.query = "up"

[sinks.blackhole]
type = "blackhole"
inputs = ["http_client"]

How did you test this PR?

Manually. Get yourself an AWS Account, create an Amazon Managed Service for Prometheus workspace, get the Endpoint - query URL and use it in the config above. Run Vector and see it working (and not failing with a 403 like the current version).

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • cargo fmt --all
      • cargo clippy --workspace --all-targets -- -D warnings
      • cargo nextest run --workspace (alternatively, you can run cargo test --all)
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run cargo vdev build licenses to regenerate the license inventory and commit the changes (if any). More details here.

@johannesfloriangeiger johannesfloriangeiger requested a review from a team as a code owner July 4, 2025 14:38
@github-actions github-actions bot added domain: sources Anything related to the Vector's sources domain: sinks Anything related to the Vector's sinks labels Jul 4, 2025
@johannesfloriangeiger johannesfloriangeiger changed the title feat(source: http_client): #23338 Enable AWS authentication for the http_client source. feat(http_client source): #23338 Enable AWS authentication for the http_client source. Jul 4, 2025
@pront pront requested a review from Copilot July 7, 2025 18:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds AWS SigV4 signing support to the http_client source, allowing Vector to authenticate requests against AWS services (e.g., Amazon Managed Service for Prometheus).

  • Introduces conditional AWS signing in the http_client utility with empty-body support.
  • Refactors shared signing logic into create_signing_instructions and exposes sign_request_with_empty_body.
  • Updates HTTP sink config to streamline region and credentials provider setup and adds a changelog entry.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/sources/util/http_client.rs Wraps request signing and send in timeouts, injects AWS SigV4 code
src/sinks/http/config.rs Simplifies AWS region/credentials resolution in HTTP sink config
src/aws/mod.rs Refactors signing into helper functions and adds empty-body signer
src/aws/auth.rs Adds region() helper on AwsAuthentication
changelog.d/23338.feature.md Adds changelog entry for AWS auth feature
Comments suppressed due to low confidence (1)

src/aws/auth.rs:372

  • The new region() helper on AwsAuthentication covers various enum variants. Adding unit tests for each variant would ensure region extraction remains correct under future changes.
    pub fn region(&self) -> Option<Region> {

@pront pront force-pushed the master branch 4 times, most recently from 1720078 to ffe54be Compare July 10, 2025 15:43
@pront pront added the meta: awaiting author Pull requests that are awaiting their author. label Jul 10, 2025
@github-actions github-actions bot removed the meta: awaiting author Pull requests that are awaiting their author. label Aug 9, 2025
@pront
Copy link
Member

pront commented Aug 27, 2025

Please resolve the merge conflicts and we will take a look

@thomasqueirozb thomasqueirozb added the meta: awaiting author Pull requests that are awaiting their author. label Aug 29, 2025
@github-actions github-actions bot removed the meta: awaiting author Pull requests that are awaiting their author. label Sep 24, 2025
@johannesfloriangeiger
Copy link
Contributor Author

Please resolve the merge conflicts and we will take a look

Thanks, merged master back into my branch - the reorg of the imports has broken git, I try to keep changes to existing code to a minimum in a PR.

Copy link
Member

@pront pront left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Found a few minor issues.

}
}

async fn prepare_request(auth: Option<Auth>, request: Request<Body>) -> Request<Body> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a little bit of refactoring this can be:

async fn prepare_request(auth: Option<Auth>, request: Request<Body>) -> Request<Body> {
    match auth {
        #[cfg(feature = "aws-core")]
        Some(Auth::Aws { auth, service: _ }) => sign_aws_request(auth, request).await,
        _ => request,
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, move the Some branch to a new function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@thomasqueirozb thomasqueirozb added source: http_client Anything `http_client` source related meta: awaiting author Pull requests that are awaiting their author. labels Sep 29, 2025
@github-actions github-actions bot removed the meta: awaiting author Pull requests that are awaiting their author. label Nov 1, 2025
Copy link
Member

@pront pront left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @johannesfloriangeiger, thanks again for this PR. Left some comments. The only real concern is that this is not tested anywhere in the codebase.

let region = auth
.region()
.or(default_region)
.expect("Region must be specified");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace all expect() calls (excluding those in test code) with proper error propagation.

Comment on lines +303 to +310
let default_region = crate::aws::region_provider(&ProxyConfig::default(), None)
.expect("Region provider must be available")
.region()
.await;
let region = auth
.region()
.or(default_region)
.expect("Region must be specified");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: introduce a helper and use it here and also while in config build()

pub async fn resolve_region_from_auth(
    auth: &AwsAuthentication,
    proxy_config: &ProxyConfig,
    tls_config: Option<&TlsConfig>,
) -> crate::Result<Region> {
    if let Some(region) = auth.region() {
        return Ok(region);
    }

    region_provider(proxy_config, tls_config)?
        .region()
        .await
        .ok_or_else(|| {
            "AWS region must be specified either in auth config or via environment/config".into()
        })
}

}
}

async fn prepare_request(auth: Option<Auth>, request: Request<Body>) -> Request<Body> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

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

Labels

domain: sinks Anything related to the Vector's sinks domain: sources Anything related to the Vector's sources source: http_client Anything `http_client` source related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable AWS authentication for http_client source

3 participants