use of software.amazon.awssdk.services.secretsmanager.model.Tag in project signers by ConsenSys.
the class AwsSecretsManagerTest method updateIfDifferentSecretTag.
private void updateIfDifferentSecretTag(final String secretName, final Tag newTag) {
final DescribeSecretResponse describeSecretResponse = testSecretsManagerClient.describeSecret(DescribeSecretRequest.builder().secretId(secretName).build());
final boolean hasDifferentSecretTag = !describeSecretResponse.hasTags() || !describeSecretResponse.tags().equals(List.of(newTag));
if (hasDifferentSecretTag) {
testSecretsManagerClient.untagResource(UntagResourceRequest.builder().secretId(secretName).tagKeys(describeSecretResponse.tags().stream().map(Tag::key).collect(Collectors.toList())).build());
testSecretsManagerClient.tagResource(TagResourceRequest.builder().secretId(secretName).tags(newTag).build());
}
}
use of software.amazon.awssdk.services.secretsmanager.model.Tag in project radixdlt by radixdlt.
the class AWSSecretManager method createNewSecret.
private static String createNewSecret(SecretsManagerClient secretsClient, String secretName, Object secretValue, String network, boolean binarySecret) {
List<Tag> tagList = buildTags(network, secretName);
CreateSecretRequest secretRequest;
if (binarySecret) {
secretRequest = CreateSecretRequest.builder().name(secretName).description("Validator keys").secretBinary((SdkBytes) secretValue).tags(tagList).build();
} else {
secretRequest = CreateSecretRequest.builder().name(secretName).description("Validator keys").secretString((String) secretValue).tags(tagList).build();
}
CreateSecretResponse secretResponse = secretsClient.createSecret(secretRequest);
return secretResponse.arn();
}
use of software.amazon.awssdk.services.secretsmanager.model.Tag in project radixdlt by radixdlt.
the class AWSSecretManager method buildTags.
private static List<Tag> buildTags(String network, String name) {
List<Tag> tagList = new ArrayList<>();
Tag envTypeTag = Tag.builder().key("radixdlt:environment-type").value("development").build();
Tag teamTag = Tag.builder().key("radixdlt:team").value("devops").build();
Tag appTag = Tag.builder().key("radixdlt:application").value("validator").build();
Tag nameTag = Tag.builder().key("radixdlt:name").value(name).build();
Tag networkTag = Tag.builder().key("radixdlt:network").value(network).build();
tagList.add(envTypeTag);
tagList.add(appTag);
tagList.add(teamTag);
tagList.add(nameTag);
tagList.add(networkTag);
return tagList;
}
use of software.amazon.awssdk.services.secretsmanager.model.Tag in project signers by ConsenSys.
the class AwsSecretsManagerTest method createOrUpdateSecret.
private void createOrUpdateSecret(final String testSecretName, final String tagKey, final String tagVal, final String secretValue) {
final Tag testSecretTag = Tag.builder().key(tagKey).value(tagVal).build();
try {
updateIfDifferentSecretValue(testSecretName, secretValue);
updateIfDifferentSecretTag(testSecretName, testSecretTag);
} catch (final ResourceNotFoundException e) {
createTestSecret(testSecretName, testSecretTag, secretValue);
}
}
Aggregations