Skip to content

Commit

Permalink
fix(aws provider): Don't unwap external_id (vectordotdev#18452)
Browse files Browse the repository at this point in the history
This field is optional.

Closes: vectordotdev#18340

Signed-off-by: Jesse Szwedko <[email protected]>
  • Loading branch information
jszwedko authored Sep 1, 2023
1 parent e652ea4 commit fd0ccd5
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/aws/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,15 @@ impl AwsAuthentication {
));
if let Some(assume_role) = assume_role {
let auth_region = region.clone().map(Region::new).unwrap_or(service_region);
let auth_external_id = external_id.clone().unwrap();
let provider = AssumeRoleProviderBuilder::new(assume_role)
.region(auth_region)
.external_id(auth_external_id)
.build(provider);
let mut builder =
AssumeRoleProviderBuilder::new(assume_role).region(auth_region);

if let Some(external_id) = external_id {
builder = builder.external_id(external_id)
}

let provider = builder.build(provider);

return Ok(SharedCredentialsProvider::new(provider));
}
Ok(provider)
Expand Down Expand Up @@ -253,11 +257,16 @@ impl AwsAuthentication {
..
} => {
let auth_region = region.clone().map(Region::new).unwrap_or(service_region);
let auth_external_id = external_id.clone().unwrap();
let provider = AssumeRoleProviderBuilder::new(assume_role)
.region(auth_region.clone())
.external_id(auth_external_id)
.build(default_credentials_provider(auth_region, *imds).await?);
let mut builder =
AssumeRoleProviderBuilder::new(assume_role).region(auth_region.clone());

if let Some(external_id) = external_id {
builder = builder.external_id(external_id)
}

let provider =
builder.build(default_credentials_provider(auth_region, *imds).await?);

Ok(SharedCredentialsProvider::new(provider))
}
AwsAuthentication::Default { imds, region, .. } => Ok(SharedCredentialsProvider::new(
Expand Down

0 comments on commit fd0ccd5

Please sign in to comment.