Commit Graph

102 Commits

Author SHA1 Message Date
Macwan Nevil
31b971f94e
fixed secretsmanager list api to support filtering correctly (#7511) 2024-03-26 11:19:43 -01:00
Akira Noda
90bdd72555
Admin: Using ruff format instead of black (#7502) 2024-03-21 19:17:29 -01:00
Bert Blommers
0455ebb953
SecretsManager: Ensure AWSPREVIOUS is only ever tied to one version (#7439) 2024-03-07 20:22:13 -01:00
Bert Blommers
4b898740e8
SecretsManager: rotate_secret() now supports the RotateImmediately-parameter (#7347) 2024-02-16 21:19:46 -01:00
Bert Blommers
fd5d7c18c1
SecretsManager: Replica Secrets are now supported (#7270) 2024-01-29 19:44:06 -01:00
Bert Blommers
a7f3b367b4 Introduce mock_aws() (#7194) 2024-01-27 19:38:09 +00:00
tungol
55c589072f
Admin: sorting imports with ruff (#7075) 2023-11-30 14:55:51 -01:00
Bert Blommers
16dd1d483c
Techdebt: Disable some duplicate tests (#7040) 2023-11-17 20:10:11 -01:00
JoshuaLicense
49f5a48f71
fix(secretsmanager): fix update of no-value initial secret (#6771) 2023-09-05 21:04:44 +00:00
Bert Blommers
8aafbdb58f
Techdebt: Streamline AWSLambda/Docker tests (#6735) 2023-08-31 06:47:49 +00:00
Bert Blommers
3cf4f6315b
SecretsManager: Allow creation/update of secrets without values (#6720) 2023-08-24 13:48:53 +00:00
kbalk
eb5fdfa247
Techdebt: Replace sure with regular assertions in secretsmanager (#6616) 2023-08-08 10:08:15 +00:00
Bert Blommers
2d608ecd22
SecretsManager: delete_secret should throw an error for 0 day Recovery (#6469) 2023-07-01 11:35:22 +00:00
Bert Blommers
37cb6cee94
SecretsManager - update_secret() now supports the Description-parameter (#6352) 2023-05-31 23:09:08 +00:00
rafcio19
8516771d15
Secrets: add NextRotationDate and LastRotatedDate to secrets (#6313) 2023-05-12 10:10:52 +00:00
Bert Blommers
f54f4a666f
Techdebt: MyPy SecretsManager (#6244) 2023-04-22 15:39:48 +00:00
Bert Blommers
638171a9e1
SecretsManager - deal with partial ARNs (#6127) 2023-03-25 11:00:17 -01:00
Hans Donner
18ec0c5467
Techdebt: skip tests when docker is not running (#6026) 2023-03-12 15:54:50 -01:00
Bert Blommers
d022b404d3
SecretsManager - put/delete_resource_policy (#6049) 2023-03-10 22:45:21 -01:00
Abdullah Ahmed
031f89dee0
Implement secretsmanager CancelRotateSecret (#5809) 2023-01-03 18:22:38 -01:00
Daniel Roschka
0588db704a
Remove dependency on pytz (#5749) 2022-12-09 22:56:08 -01:00
Pepe Fagoaga
dfd45d80ab
Secretsmanager: fix(add-secret): SecretString can be None (#5672) 2022-11-18 20:18:47 -01:00
Bert Blommers
1a8ddc0f2b
Techdebt: Replace string-format with f-strings (for tests dirs) (#5678) 2022-11-17 21:41:08 -01:00
Bert Blommers
3d913f8f15
MultiAccount support (#5192) 2022-08-13 09:49:43 +00:00
Bryan Schrock
836a2e6538
Update get_secret_value to properly check versions and stages match (#5238) 2022-06-18 11:20:14 +00:00
Matthew Davis
0bf7057866
change secret ARNs to 6 random chars at end (#5200) 2022-06-08 19:54:51 +00:00
Bert Blommers
29d01c35bc
Update Black + formatting (#4926) 2022-03-10 13:39:59 -01:00
Daniel Roschka
d324a77445
Fix deleting secrets by ARN (#4918) 2022-03-08 09:17:28 -01:00
stromp
0e3fef9b42
Fix issue #4906 by removing version stages from old versions (#4907) 2022-03-03 12:02:23 -01:00
stromp
7e88a901d9
fix for duplicate tag keys in secretsmanager (#4900) 2022-03-01 21:50:42 -01:00
MEP
7194456d0d
[LocalStack] Fixes to secretsmanager's PutSecretValue, CreateSecret, DeleteSecret (#4851) 2022-02-11 11:49:14 -01:00
Daniel Fangl
3f534119f4
Add CreatedDate and LastChangedDate in secretsmanager responses (#4770) 2022-01-25 09:24:26 -01:00
George Lungley
29406ed74e
Resolves #4644 - Add negative filter support in secretsmanager (#4645) 2021-12-01 14:33:52 -01:00
Bert Blommers
14a69c7524
Techdebt: Enable pylint rules (#4432) 2021-10-18 19:44:29 +00:00
MarkBrook
663cd7a523
ISSUE-4340: SecretsManager cannot find specified secret using ARN in some operations (#4353) 2021-09-27 19:59:13 +00:00
Miguel Gagliardo
c65d4ddc3b
Fix: Adding ClientRequestToken for SecretsManager update_secret method (#4314) 2021-09-21 16:43:31 +00:00
Bert Blommers
d08ed937f3
AWSLambda - clean up tests (#4317) 2021-09-21 15:19:49 +00:00
George Lungley
0ec99fae8b
#4118 Add KmsKeyId Support to secretsmanager (#4119) 2021-08-03 15:46:23 +01:00
Bert Blommers
7693d77333
Remove Py2 support (#3915) 2021-07-26 07:40:39 +01:00
Bert Blommers
5e4bccc22d
Use centralized ACCOUNT_ID (#4029) 2021-06-23 18:03:11 +01:00
Daniel Samuels
a4b1498665
Support rotating secrets using Lambda [#3905] (#3912)
* Support rotating secrets using Lambda

The Secrets manager rotation process uses an AWS Lambda function
to perform the rotation of a secret. [1]

In fact, it's not possible to trigger rotation of a Secret
without specifying a Lambda function at some point in the life
of the secret:

```
$ aws secretsmanager rotate-secret --secret-id /rotationTest

An error occurred (InvalidRequestException) when calling the RotateSecret operation: No Lambda rotation function ARN is associated with this secret.
```

`moto` can be a little more lenient in this regard and allow
`rotate_secret` to be called without a Lambda function being
present, if only to allow simulation of the `AWSCURRENT` and
`AWSPREVIOUS` labels moving across versions.

However, if a lambda function _has_ been specified when calling
`rotate_secret`, it should be invoked therefore providing the
developer with the full multi-stage process [3] which can be
used to test the Lambda function itself and ensuring that full
end-to-end testing is performed. Without this there's no easy
way to configure the Secret in the state needed to provide the
Lambda function with the data in the format it needs to be in
at each step of the invocation process.

[1]: https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets-lambda-function-overview.html
[2]: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/secretsmanager.html#SecretsManager.Client.rotate_secret
[3]: https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets-lambda-function-overview.html#rotation-explanation-of-steps

* Run `black` over `secretsmanager/models.py`

* Make `lambda_backends` import local to the condition

* Implement `update_secret_version_stage`

Allow a staging label to be moved across versions.

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/secretsmanager.html#SecretsManager.Client.update_secret_version_stage

* Add an integration test for Secrets Manager & Lambda

* Support passing `ClientRequestToken` to `put_secret_value`

By passing `ClientRequestToken` to `put_secret_value` within
the lambda function  invoked by calling `rotate_secret`, one
can update the value associated with the existing (pending)
version, without causing a new secret version to be created.

* Add application logic for `AWSPENDING`

The rotation function must end with the versions of the secret
in one of two states:

 - The `AWSPENDING` and `AWSCURRENT` staging labels are
   attached to the same version of the secret, or
 - The `AWSPENDING` staging label is not attached to any
   version of the secret.

If the `AWSPENDING` staging label is present but not attached
to the same version as `AWSCURRENT` then any later invocation
of RotateSecret assumes that a previous rotation request is
still in progress and returns an error.

* Update `default_version_id` after Lambda rotation concludes

Call `set_default_version_id` directly, rather than going 
through `reset_default_version` as the Lambda function is 
responsible for moving the version labels around, not `rotate_secret`.

* Run `black` over changed files

* Fix Python 2.7 compatibility

* Add additional test coverage for Secrets Manager

* Fix bug found by tests

AWSPENDING + AWSCURRENT check wasn't using `version_stages`.
Also tidy up the AWSCURRENT moving in `update_secret_version_stage`
to remove AWSPREVIOUS it from the new stage.

* Run `black` over changed files

* Add additional `rotate_secret` tests

* Skip `test_rotate_secret_lambda_invocations` in test server mode

* Add test for invalid Lambda ARN
2021-05-11 12:08:01 +01:00
George Vince
4da11da2bf
Secrets manager untag resource (#3767)
* added: untag_resource + test

* formatting

* formatting

* formatting

* added: formatting fix
2021-03-12 10:35:38 +00:00
Bert Blommers
273ca63d59 Linting 2020-11-11 15:55:37 +00:00
Bert Blommers
cb6731f340 Convert fixtures/exceptions to Pytest 2020-11-11 15:54:01 +00:00
Matěj Cepl
6d364dc7aa Pytest model of exceptions uses 'value' attribute instead of 'exception'. 2020-11-11 12:21:04 +01:00
Matěj Cepl
5697ff87a8 Back to Black 2020-11-10 14:12:38 +01:00
Matěj Cepl
ea489bce6c Finish porting from nose to pytest. 2020-11-10 08:25:05 +01:00
Matěj Cepl
77dc60ea97 Port test suite from nose to pytest.
This just eliminates all errors on the tests collection. Elimination of
failures is left to the next commit.
2020-11-10 08:23:44 +01:00
Brian Pandola
76265576ac
Fix: describe/list attribute discrepancy in Secrets Manager (#3432)
`secretsmanager:DescribeSecret` returns `VersionIdsToStages`
`secretsmanager:ListSecrets` returns the same information in `SecretVersionsToStages`

* Verified fix against real AWS backend.

Fixes #3406
2020-11-03 14:18:56 +00:00
usmangani1
53c3eb6240
Fix:SecretsManager :Error on Invalid secretID (#3413)
* Fix:SecretsManager :Error on Invalid secretID

* Fixed tests

Co-authored-by: usmankb <usman@krazybee.com>
2020-11-02 10:15:40 +00:00