Last active
May 1, 2024 21:58
-
-
Save henriquez/2f91fcc9a8417a8e76c1edf54e1d8002 to your computer and use it in GitHub Desktop.
Secret Manager create secret function examples
This file contains hidden or 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
# Create secret in secret manager: proposed generated sample | |
# All of these samples assume that detail about the arguments is provided on the same page below the sample. | |
# Since the existing docs are not clear, take this as an example not nec. as what the API actually requires. | |
# EX 1: In this example we put the types as comments, see below for other options | |
response = client.create_secret( | |
request={ | |
"parent": parent, # REQUIRED: str | |
"secret_id": secret_id, # REQUIRED: str | |
"secret": { # REQUIRED: google.cloud.secretmanager_v1.types.Secret | |
"replication": { # OPTIONAL: google.cloud.secretmanager_v1.types.Replication | |
"automatic": {}, # OPTIONAL: google.cloud.secretmanager_v1.types.Replication.Automatic | |
"user_managed: { # OPTIONAL, and only if automatic is not specified: google.cloud.secretmanager_v1.types.Replication.UserManaged | |
"replicas": { # REQUIRED with user_managed: MutableSequence[google.cloud.secretmanager_v1.types.Replication.UserManaged.Replica] | |
"location": location_id, # REQUIRED: str | |
"customer_managed_encryption": { # OPTIONAL: google.cloud.secretmanager_v1.types.CustomerManagedEncryption | |
"kms_key_name": kms_key_name # REQUIRED: The expected format is projects/*/locations/*/keyRings/*/cryptoKeys/* | |
} | |
} | |
}. | |
}, | |
"ttl": ttl | |
}, | |
} | |
) | |
# EX 2. Here we put in placeholder strings, with the assumption that the placeholders are generated | |
# in a standardized way, e.g "{key_name}-{type_name}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment