-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9625d37
commit 0622127
Showing
4 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
aws_lambda_powertools/utilities/data_classes/secrets_event.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing_extensions import Literal | ||
|
||
from aws_lambda_powertools.utilities.data_classes.common import DictWrapper | ||
|
||
|
||
class SecretManagerEvent(DictWrapper): | ||
@property | ||
def secret_id(self) -> str: | ||
"""SecretId: The secret ARN or identifier""" | ||
return self["SecretId"] | ||
|
||
@property | ||
def client_request_token(self) -> str: | ||
"""ClientRequestToken: The ClientRequestToken of the secret version""" | ||
return self["ClientRequestToken"] | ||
|
||
@property | ||
def step(self) -> Literal["createSecret", "setSecret", "testSecret", "finishSecret"]: | ||
"""Step: The rotation step (one of createSecret, setSecret, testSecret, or finishSecret)""" | ||
return self["Step"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"SecretId":"arn:aws:secretsmanager:us-west-2:123456789012:secret:MyTestDatabaseSecret-a1b2c3", | ||
"ClientRequestToken":"550e8400-e29b-41d4-a716-446655440000", | ||
"Step":"createSecret" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from aws_lambda_powertools.utilities.data_classes.secrets_event import SecretManagerEvent | ||
from tests.functional.utils import load_event | ||
|
||
|
||
def test_vpc_lattice_event(): | ||
raw_event = load_event("secretManagerEvent.json") | ||
parsed_event = SecretManagerEvent(raw_event) | ||
|
||
assert parsed_event.secret_id == raw_event["SecretId"] | ||
assert parsed_event.client_request_token == raw_event["ClientRequestToken"] | ||
assert parsed_event.step == raw_event["Step"] |