Bigtable Cluster Encrypted Remediation
Triage and Remediation
- Remediation
Remediation
Using Console
To remediate the misconfiguration "Bigtable Cluster should be encrypted" in GCP, you can follow the below steps using the GCP console:
-
Open the GCP console and navigate to the Bigtable instance that needs to be encrypted.
-
Click on the "Edit" button on the top of the page.
-
Scroll down to the "Encryption" section and click on the "Edit" button next to it.
-
Select the "Customer-managed key" option and choose the key that you want to use for encryption.
-
Click on the "Save" button to save the changes.
-
Once the changes are saved, the Bigtable cluster will be encrypted using the selected customer-managed key.
-
Verify the encryption status of the Bigtable cluster by checking the "Encryption" section on the Bigtable instance page. It should show that the cluster is encrypted using the selected customer-managed key.
By following these steps, you can remediate the misconfiguration "Bigtable Cluster should be encrypted" in GCP using the GCP console.
Using CLI
To remediate the misconfiguration of a non-encrypted Bigtable cluster in GCP, you can follow these steps using GCP CLI:
-
Open the Cloud Shell in your GCP console.
-
Check the current status of the Bigtable cluster by running the following command:
gcloud beta bigtable clusters describe [CLUSTER_ID] --project=[PROJECT_ID] --instance=[INSTANCE_ID]
- If the output shows that the cluster is not encrypted, then run the following command to enable encryption:
gcloud beta bigtable clusters update [CLUSTER_ID] --project=[PROJECT_ID] --instance=[INSTANCE_ID] --encryption-at-rest-state=ENABLED
-
Wait for the update to complete. This may take a few minutes.
-
Verify that the encryption is enabled by running the following command:
gcloud beta bigtable clusters describe [CLUSTER_ID] --project=[PROJECT_ID] --instance=[INSTANCE_ID]
-
Check the output to confirm that the encryption-at-rest-state is set to ENABLED.
-
Once you have confirmed that the encryption is enabled, you have successfully remediated the non-encrypted Bigtable cluster misconfiguration.
Using Python
To remediate the misconfiguration "Bigtable Cluster Should Be Encrypted" in GCP using python, you can follow the below steps:
-
Open the GCP console and navigate to the Bigtable Clusters page.
-
Select the Bigtable cluster that needs to be encrypted.
-
Click on the "Edit" button to edit the cluster configuration.
-
In the "Security" section, check if the "Encryption" option is enabled. If not, enable it.
-
Choose the encryption type that you want to use. You can choose between Google-managed encryption keys or customer-managed encryption keys.
-
If you choose customer-managed encryption keys, provide the key name and key version.
-
Save the changes to update the Bigtable cluster configuration.
-
To automate this process using python, you can use the GCP SDK libraries. Here is an example code snippet to enable encryption for a Bigtable cluster using python:
from google.cloud import bigtable
client = bigtable.Client(project='your-project-id')
instance = client.instance('your-instance-id')
cluster = instance.cluster('your-cluster-id')
# Enable encryption
cluster.encryption_at_rest_type = 'GOOGLE_DEFAULT_ENCRYPTION'
cluster.update()
In the above code snippet, replace "your-project-id", "your-instance-id" and "your-cluster-id" with the actual values for your Bigtable cluster. Also, you can choose the encryption type as per your requirement.
Using Terraform
resource "google_bigtable_instance" "encrypted_instance" {
name = "BIGTABLE_INSTANCE_NAME" # e.g. "prod-bigtable"
instance_type = "PRODUCTION" # or "DEVELOPMENT"
project = "PROJECT_ID" # replace with your GCP project ID
display_name = "BIGTABLE_DISPLAY_NAME"
cluster {
cluster_id = "BIGTABLE_CLUSTER_ID" # e.g. "prod-cluster-1"
zone = "BIGTABLE_ZONE" # e.g. "us-central1-b"
num_nodes = 3 # adjust as needed
storage_type = "SSD" # or "HDD"
# Enable CMEK encryption for this Bigtable cluster
kms_key_name = "projects/PROJECT_ID/locations/KEY_LOCATION/keyRings/KEY_RING_NAME/cryptoKeys/KEY_NAME"
# Replace:
# PROJECT_ID with your GCP project ID
# KEY_LOCATION with KMS key location, e.g. "us-central1"
# KEY_RING_NAME with your key ring name
# KEY_NAME with your crypto key name
}
}
Changing or adding kms_key_name on an existing Bigtable cluster forces replacement of that cluster (data loss unless separately migrated); plan carefully before applying.
Verification: terraform plan should show an update to google_bigtable_instance.encrypted_instance where the cluster block for BIGTABLE_CLUSTER_ID is replaced to add kms_key_name referencing your CMEK key.