Adds initial support for secretsmanager update_secret

The support in this patch is preliminary and may or may not be feature complete.
It provides the basic support for update_secret so that future work can build
on it as needed.
This commit is contained in:
Tim 2020-04-16 08:20:43 -07:00
commit 92bbc3fbac
3 changed files with 114 additions and 0 deletions

View file

@ -107,6 +107,34 @@ class SecretsManagerBackend(BaseBackend):
return response
def update_secret(
self, secret_id, secret_string=None, secret_binary=None, **kwargs
):
# error if secret does not exist
if secret_id not in self.secrets.keys():
raise SecretNotFoundException()
if "deleted_date" in self.secrets[secret_id]:
raise InvalidRequestException(
"An error occurred (InvalidRequestException) when calling the UpdateSecret operation: "
"You can't perform this operation on the secret because it was marked for deletion."
)
version_id = self._add_secret(
secret_id, secret_string=secret_string, secret_binary=secret_binary
)
response = json.dumps(
{
"ARN": secret_arn(self.region, secret_id),
"Name": secret_id,
"VersionId": version_id,
}
)
return response
def create_secret(
self, name, secret_string=None, secret_binary=None, tags=[], **kwargs
):