|
13 | 13 |
|
14 | 14 |
|
15 | 15 | # [START kms_create_key_rotation_schedule] |
16 | | -def create_key_rotation_schedule(project_id, location_id, key_ring_id, id): |
| 16 | +def create_key_rotation_schedule(project_id, location_id, key_ring_id, key_id): |
17 | 17 | """ |
18 | 18 | Creates a new key in Cloud KMS that automatically rotates. |
19 | 19 |
|
20 | 20 | Args: |
21 | 21 | project_id (string): Google Cloud project ID (e.g. 'my-project'). |
22 | 22 | location_id (string): Cloud KMS location (e.g. 'us-east1'). |
23 | 23 | key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring'). |
24 | | - id (string): ID of the key to create (e.g. 'my-rotating-key'). |
| 24 | + key_id (string): ID of the key to create (e.g. 'my-rotating-key'). |
25 | 25 |
|
26 | 26 | Returns: |
27 | 27 | CryptoKey: Cloud KMS key. |
@@ -51,17 +51,18 @@ def create_key_rotation_schedule(project_id, location_id, key_ring_id, id): |
51 | 51 |
|
52 | 52 | # Rotate the key every 30 days. |
53 | 53 | 'rotation_period': { |
54 | | - 'seconds': 60*60*24*30 |
| 54 | + 'seconds': 60 * 60 * 24 * 30 |
55 | 55 | }, |
56 | 56 |
|
57 | 57 | # Start the first rotation in 24 hours. |
58 | 58 | 'next_rotation_time': { |
59 | | - 'seconds': int(time.time()) + 60*60*24 |
| 59 | + 'seconds': int(time.time()) + 60 * 60 * 24 |
60 | 60 | } |
61 | 61 | } |
62 | 62 |
|
63 | 63 | # Call the API. |
64 | | - created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key}) |
| 64 | + created_key = client.create_crypto_key( |
| 65 | + request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key}) |
65 | 66 | print('Created labeled key: {}'.format(created_key.name)) |
66 | 67 | return created_key |
67 | 68 | # [END kms_create_key_rotation_schedule] |
0 commit comments