bug: properly handle already initted kms client (#614)

buddies-main-deployment
James Prestwich 3 years ago committed by GitHub
parent 0d966459e6
commit fab6a6d428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      rust/optics-base/src/settings/mod.rs

@ -96,20 +96,17 @@ impl SignerConf {
match self { match self {
SignerConf::HexKey { key } => Ok(Signers::Local(key.as_ref().parse()?)), SignerConf::HexKey { key } => Ok(Signers::Local(key.as_ref().parse()?)),
SignerConf::Aws { id, region } => { SignerConf::Aws { id, region } => {
let client = rusoto_core::Client::new_with( let client = KMS_CLIENT.get_or_init(|| {
KmsClient::new_with_client(
rusoto_core::Client::new_with(
EnvironmentProvider::default(), EnvironmentProvider::default(),
HttpClient::new().unwrap(), HttpClient::new().unwrap(),
); ),
if KMS_CLIENT
.set(KmsClient::new_with_client(
client,
region.parse().expect("invalid region"), region.parse().expect("invalid region"),
)) )
.is_err() });
{
panic!("couldn't set cell") let signer = AwsSigner::new(client, id, 0).await?;
}
let signer = AwsSigner::new(KMS_CLIENT.get().unwrap(), id, 0).await?;
Ok(Signers::Aws(signer)) Ok(Signers::Aws(signer))
} }
SignerConf::Node => bail!("Node signer"), SignerConf::Node => bail!("Node signer"),

Loading…
Cancel
Save