Merge pull request #2897 from caphrim007/feature.add-secretsmanager-update-secret
Adds initial support for secretsmanager update_secret
This commit is contained in:
commit
07c33105e5
3 changed files with 114 additions and 0 deletions
|
|
@ -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
|
||||
):
|
||||
|
|
|
|||
|
|
@ -29,6 +29,16 @@ class SecretsManagerResponse(BaseResponse):
|
|||
tags=tags,
|
||||
)
|
||||
|
||||
def update_secret(self):
|
||||
secret_id = self._get_param("SecretId")
|
||||
secret_string = self._get_param("SecretString")
|
||||
secret_binary = self._get_param("SecretBinary")
|
||||
return secretsmanager_backends[self.region].update_secret(
|
||||
secret_id=secret_id,
|
||||
secret_string=secret_string,
|
||||
secret_binary=secret_binary,
|
||||
)
|
||||
|
||||
def get_random_password(self):
|
||||
password_length = self._get_param("PasswordLength", if_none=32)
|
||||
exclude_characters = self._get_param("ExcludeCharacters", if_none="")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue