Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 AWS
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
AWS KMS Bash スクリプト AWS CLI で を使用する例
次のコード例は、Bash スクリプト AWS Command Line Interface で を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています AWS KMS。
「シナリオ」は、1 つのサービス内から、または他の AWS のサービスと組み合わせて複数の関数を呼び出し、特定のタスクを実行する方法を示すコード例です。
各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。
トピック
シナリオ
次のコード例は、DynamoDB テーブルの暗号化オプションを管理する方法を示しています。
デフォルトの暗号化を使用してテーブルを作成します。
カスタマーマネージド CMK を使用してテーブルを作成します。
テーブルの暗号化設定を更新します。
テーブルの暗号化について説明します。
- AWS CLI Bash スクリプトを使用する
-
デフォルトの暗号化を使用してテーブルを作成します。
# Create a table with default encryption (AWS owned key) aws dynamodb create-table \ --table-name CustomerData \ --attribute-definitions \ AttributeName=CustomerID,AttributeType=S \ --key-schema \ AttributeName=CustomerID,KeyType=HASH \ --billing-mode PAY_PER_REQUEST \ --sse-specification Enabled=true,SSEType=KMS
カスタマーマネージド CMK を使用してテーブルを作成します。
# Step 1: Create a customer managed key in KMS aws kms create-key \ --description "Key for DynamoDB table encryption" \ --key-usage ENCRYPT_DECRYPT \ --customer-master-key-spec SYMMETRIC_DEFAULT # Store the key ID for later use KEY_ID=$(aws kms list-keys --query "Keys[?contains(KeyArn, 'Key for DynamoDB')].KeyId" --output text) # Step 2: Create a table with the customer managed key aws dynamodb create-table \ --table-name SensitiveData \ --attribute-definitions \ AttributeName=RecordID,AttributeType=S \ --key-schema \ AttributeName=RecordID,KeyType=HASH \ --billing-mode PAY_PER_REQUEST \ --sse-specification Enabled=true,SSEType=KMS,KMSMasterKeyId=$KEY_ID
テーブルの暗号化を更新します。
# Update a table to use a different KMS key aws dynamodb update-table \ --table-name CustomerData \ --sse-specification Enabled=true,SSEType=KMS,KMSMasterKeyId=$KEY_ID
テーブルの暗号化について説明します。
# Describe the table to see encryption settings aws dynamodb describe-table \ --table-name CustomerData \ --query "Table.SSEDescription"
-
API の詳細については、「AWS CLI コマンドリファレンス」の以下のトピックを参照してください。
-