Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: KMS, basics #6963

Merged
119 changes: 83 additions & 36 deletions .doc_gen/metadata/kms_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ kms_TagResource:
- description:
snippet_tags:
- kms.java2_tag.main
Python:
versions:
- sdk_version: 3
github: python/example_code/kms
excerpts:
- description:
snippet_tags:
- python.example_code.kms.KeyManager
- python.example_code.kms.TagResource
services:
kms: {TagResource}
kms_Sign:
Expand All @@ -40,8 +49,30 @@ kms_Sign:
- description:
snippet_tags:
- kms.java2_sign.main
Python:
versions:
- sdk_version: 3
github: python/example_code/kms
excerpts:
- description:
snippet_tags:
- python.example_code.kms.KeyEncrypt
- python.example_code.kms.Sign
services:
kms: {Sign}
kms_Verify:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/kms
excerpts:
- description:
snippet_tags:
- python.example_code.kms.KeyEncrypt
- python.example_code.kms.Verify
services:
kms: {Verify}
kms_CreateKey:
languages:
Kotlin:
Expand Down Expand Up @@ -471,7 +502,7 @@ kms_DisableKey:
- description:
snippet_tags:
- python.example_code.kms.KeyManager
- python.example_code.kms.EnableDisableKey
- python.example_code.kms.DisableKey
services:
kms: {DisableKey}
kms_EnableKey:
Expand Down Expand Up @@ -511,7 +542,7 @@ kms_EnableKey:
- description:
snippet_tags:
- python.example_code.kms.KeyManager
- python.example_code.kms.EnableDisableKey
- python.example_code.kms.EnableKey
services:
kms: {EnableKey}
kms_ScheduleKeyDeletion:
Expand Down Expand Up @@ -742,36 +773,7 @@ kms_PutKeyPolicy:
- python.example_code.kms.PutKeyPolicy
services:
kms: {PutKeyPolicy}
kms_Scenario_KeyEncryption:
title: Encrypt and decrypt text with &kms-keys-long; using an &AWS; SDK
title_abbrev: Encrypt and decrypt text
synopsis_list:
- Encrypt plain text by using a &kms-key;.
- Decrypt ciphertext by using a &kms-key;.
- Reencrypt ciphertext by using a second &kms-key;.
category: Scenarios
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/kms
sdkguide:
excerpts:
- description:
snippet_tags:
- python.example_code.kms.Scenario_KeyEncryption
services:
kms: {Encrypt, Decrypt, ReEncrypt}
kms_Scenario_KeyManagement:
title: Manage &kms-keys-long; using an &AWS; SDK
title_abbrev: Manage keys
synopsis_list:
- Create a &kms-key;.
- List &kms-keys; for your account and get details about them.
- Enable and disable &kms-keys;.
- Generate a symmetric data key that can be used for client-side encryption.
- Delete &kms-keys;.
category: Scenarios
kms_EnableKeyRotation:
languages:
Python:
versions:
Expand All @@ -781,12 +783,11 @@ kms_Scenario_KeyManagement:
excerpts:
- description:
snippet_tags:
- python.example_code.kms.Scenario_KeyManagement
- python.example_code.kms.KeyManager
- python.example_code.kms.EnableKeyRotation
services:
kms: {CreateKey, ListKeys, DescribeKey, GenerateDataKey, EnableKey, DisableKey, ScheduleKeyDeletion}
kms: {EnableKeyRotation}
kms_Scenario_Basics:
title: Learn core operations for &kms-key; using an &AWS; SDK
title_abbrev: Learn &kms-key; core operations
synopsis_list:
- Create a &kms-key;.
- List &kms-keys; for your account and get details about them.
Expand All @@ -809,6 +810,52 @@ kms_Scenario_Basics:
- description: Define a class that wraps KMS actions.
snippet_tags:
- kms.java2_actions.main
Python:
versions:
- sdk_version: 3
github: python/example_code/kms
sdkguide:
excerpts:
- description:
snippet_tags:
- python.example_code.kms.kms_basics
- description: Wrapper class and methods for &kms-key; management.
snippet_tags:
- python.example_code.kms.KeyManager
- python.example_code.kms.CreateKey
- python.example_code.kms.DescribeKey
- python.example_code.kms.EnableKeyRotation
- python.example_code.kms.CreateAsymmetricKey
- python.example_code.kms.TagResource
- python.example_code.kms.ScheduleKeyDeletion
- description: >
Wrapper class and methods for &kms-key; aliases.
snippet_tags:
- python.example_code.kms.AliasManager
- python.example_code.kms.CreateAlias
- python.example_code.kms.ListAliases
- python.example_code.kms.DeleteAlias
- description: >
Wrapper class and methods for &kms-key; encryption.
snippet_tags:
- python.example_code.kms.KeyEncrypt
- python.example_code.kms.Encrypt
- python.example_code.kms.Decrypt
- python.example_code.kms.Sign
- python.example_code.kms.Verify
- description: >
Wrapper class and methods for &kms-key; grants.
snippet_tags:
- python.example_code.kms.GrantManager
- python.example_code.kms.CreateGrant
- python.example_code.kms.ListGrants
- python.example_code.kms.RevokeGrant
- description: >
Wrapper class and methods for &kms-key; policies.
snippet_tags:
- python.example_code.kms.KeyPolicy
- python.example_code.kms.set_new_policy
- python.example_code.kms.GetKeyPolicy
services:
kms: {CreateKey, ListKeys, DescribeKey, GenerateDataKey, EnableKey, Sign, DisableKey, ScheduleKeyDeletion}

4 changes: 2 additions & 2 deletions javav2/example_code/kms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `javav

Code examples that show you how to perform the essential operations within a service.

- [Learn KMS key core operations](src/main/java/com/example/kms/scenario/KMSScenario.java)
- [Learn the basics](src/main/java/com/example/kms/scenario/KMSScenario.java)


### Single actions
Expand Down Expand Up @@ -80,7 +80,7 @@ Code excerpts that show you how to call individual service functions.
This example shows you how to get started using KMS key.


#### Learn KMS key core operations
#### Learn the basics

This example shows you how to do the following:

Expand Down
98 changes: 41 additions & 57 deletions python/example_code/kms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,42 @@ python -m pip install -r requirements.txt
<!--custom.prerequisites.start-->
<!--custom.prerequisites.end-->

### Basics

Code examples that show you how to perform the essential operations within a service.

- [Learn the basics](kms_scenario.py)


### Single actions

Code excerpts that show you how to call individual service functions.

- [CreateAlias](alias_management.py#L78)
- [CreateGrant](grant_management.py#L27)
- [CreateKey](key_management.py#L28)
- [Decrypt](key_encryption.py#L50)
- [DeleteAlias](alias_management.py#L164)
- [DescribeKey](key_management.py#L82)
- [DisableKey](key_management.py#L128)
- [EnableKey](key_management.py#L128)
- [Encrypt](key_encryption.py#L26)
- [GenerateDataKey](key_management.py#L104)
- [GetKeyPolicy](key_policies.py#L50)
- [ListAliases](alias_management.py#L103)
- [ListGrants](grant_management.py#L61)
- [ListKeyPolicies](key_policies.py#L28)
- [ListKeys](key_management.py#L54)
- [PutKeyPolicy](key_policies.py#L78)
- [ReEncrypt](key_encryption.py#L76)
- [RetireGrant](grant_management.py#L86)
- [RevokeGrant](grant_management.py#L106)
- [ScheduleKeyDeletion](key_management.py#L161)
- [UpdateAlias](alias_management.py#L135)

### Scenarios

Code examples that show you how to accomplish a specific task by calling multiple
functions within the same service.

- [Encrypt and decrypt text](key_encryption.py)
- [Manage keys](key_management.py)
- [CreateAlias](alias_management.py#L89)
- [CreateGrant](grant_management.py#L38)
- [CreateKey](key_management.py#L39)
- [Decrypt](key_encryption.py#L66)
- [DeleteAlias](alias_management.py#L172)
- [DescribeKey](key_management.py#L110)
- [DisableKey](key_management.py#L175)
- [EnableKey](key_management.py#L156)
- [EnableKeyRotation](key_management.py#L216)
- [Encrypt](key_encryption.py#L37)
- [GenerateDataKey](key_management.py#L132)
- [GetKeyPolicy](key_policies.py#L62)
- [ListAliases](alias_management.py#L113)
- [ListGrants](grant_management.py#L67)
- [ListKeyPolicies](key_policies.py#L39)
- [ListKeys](key_management.py#L82)
- [PutKeyPolicy](key_policies.py#L91)
- [ReEncrypt](key_encryption.py#L88)
- [RetireGrant](grant_management.py#L95)
- [RevokeGrant](grant_management.py#L115)
- [ScheduleKeyDeletion](key_management.py#L189)
- [Sign](key_encryption.py#L123)
- [TagResource](key_management.py#L235)
- [UpdateAlias](alias_management.py#L143)
- [Verify](key_encryption.py#L147)


<!--custom.examples.start-->
Expand All @@ -81,50 +84,31 @@ functions within the same service.
<!--custom.instructions.end-->



#### Encrypt and decrypt text

This example shows you how to do the following:

- Encrypt plain text by using a KMS key.
- Decrypt ciphertext by using a KMS key.
- Reencrypt ciphertext by using a second KMS key.

<!--custom.scenario_prereqs.kms_Scenario_KeyEncryption.start-->
<!--custom.scenario_prereqs.kms_Scenario_KeyEncryption.end-->

Start the example by running the following at a command prompt:

```
python key_encryption.py
```


<!--custom.scenarios.kms_Scenario_KeyEncryption.start-->
<!--custom.scenarios.kms_Scenario_KeyEncryption.end-->

#### Manage keys
#### Learn the basics

This example shows you how to do the following:

- Create a KMS key.
- List KMS keys for your account and get details about them.
- Enable and disable KMS keys.
- Generate a symmetric data key that can be used for client-side encryption.
- Generate an asymmetric key used to digitally sign data.
- Tag keys.
- Delete KMS keys.

<!--custom.scenario_prereqs.kms_Scenario_KeyManagement.start-->
<!--custom.scenario_prereqs.kms_Scenario_KeyManagement.end-->
<!--custom.basic_prereqs.kms_Scenario_Basics.start-->
<!--custom.basic_prereqs.kms_Scenario_Basics.end-->

Start the example by running the following at a command prompt:

```
python key_management.py
python kms_scenario.py
```


<!--custom.scenarios.kms_Scenario_KeyManagement.start-->
<!--custom.scenarios.kms_Scenario_KeyManagement.end-->
<!--custom.basics.kms_Scenario_Basics.start-->
<!--custom.basics.kms_Scenario_Basics.end-->


### Tests

Expand Down
Loading
Loading