MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / KMSScenario

Class KMSScenario

python/example_code/kms/kms_scenario.py:23–339  ·  view source on GitHub ↗

Runs an interactive scenario that shows how to get started with KMS.

Source from the content-addressed store, hash-verified

21
22# snippet-start:[python.example_code.kms.kms_basics]
23class KMSScenario:
24 """Runs an interactive scenario that shows how to get started with KMS."""
25
26 def __init__(
27 self,
28 key_manager: KeyManager,
29 key_encryption: KeyEncrypt,
30 alias_manager: AliasManager,
31 grant_manager: GrantManager,
32 key_policy: KeyPolicy,
33 ):
34 self.key_manager = key_manager
35 self.key_encryption = key_encryption
36 self.alias_manager = alias_manager
37 self.grant_manager = grant_manager
38 self.key_policy = key_policy
39 self.key_id = ""
40 self.alias_name = ""
41 self.asymmetric_key_id = ""
42
43 def kms_scenario(self):
44 key_description = "Created by the AWS KMS API"
45
46 print(DASHES)
47 print(
48 """
49Welcome to the AWS Key Management SDK Basics scenario.
50
51This program demonstrates how to interact with AWS Key Management using the AWS SDK for Python (Boto3).
52The AWS Key Management Service (KMS) is a secure and highly available service that allows you to create
53and manage AWS KMS keys and control their use across a wide range of AWS services and applications.
54KMS provides a centralized and unified approach to managing encryption keys, making it easier to meet your
55data protection and regulatory compliance requirements.
56
57This Basics scenario creates two key types:
58
59- A symmetric encryption key is used to encrypt and decrypt data.
60- An asymmetric key used to digitally sign data.
61
62Let's get started...
63 """
64 )
65 q.ask("Press Enter to continue...")
66
67 print(DASHES)
68 print(f"1. Create a symmetric KMS key\n")
69 print(
70 f"First, the program will creates a symmetric KMS key that you can used to encrypt and decrypt data."
71 )
72 q.ask("Press Enter to continue...")
73 self.key_id = self.key_manager.create_key(key_description)["KeyId"]
74 print(f"A symmetric key was successfully created {self.key_id}.")
75 q.ask("Press Enter to continue...")
76 print(DASHES)
77 print(
78 """
792. Enable a KMS key
80

Callers 1

kms_scenario.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected