Create a Cloud Account for GCP
Follow the steps to create a Cloud Account for GCP.
After you create the Cloud Account, retrieve the serviceAccountEmail
by calling the Describe GCP project API.
Prerequisites
Procedure
- Install the gcloud CLI.
- Install Terraform.
- Set up an environment to run shell scripts.
Using Terraform with gcloud CLI
Create an all-in-one stack by Terraform
Procedure
- Log into gcloud:
gcloud auth application-default login - Set up the gcloud project
gcloud config set project PROJECT-IDwherePROJECT-IDis the ID of the GCP project where you are deploying the stack. - Download the templates:
wget https://file-storage-security.s3.amazonaws.com/latest/gcp-templates/gcp-templates-terraform.zip && unzip gcp-templates-terraform.zip - Configure the GCP project using Terraform deployment:
sed -i.bak "s/<GCP_PROJECT_ID>/<projectID>/g" ./gcp-configuration/terraform.tfvars.jsonterraform -chdir=gcp-configuration init && terraform -chdir=gcp-configuration applywhere...projectIDmust be replaced with the ID of your GCP project.
- Create the all-in-one stack in GCP with the following commands:
sed -i.bak "s/<GCP_PROJECT_ID>/<projectID>/g" ./all-in-one/terraform.tfvars.jsonsed -i "s/<SCANNER_STACK_NAME>/<scannerStackName>/g" ./all-in-one/terraform.tfvars.jsonsed -i "s/<STORAGE_STACK_NAME>/<storageStackName>/g" ./all-in-one/terraform.tfvars.jsonsed -i "s/<GCP_REGION>/<region>/g" ./all-in-one/terraform.tfvars.jsonsed -i "s/<SCANNING_BUCKET_NAME>/<scanningBucketName>/g" ./all-in-one/terraform.tfvars.jsonsed -i "s/<MANAGEMENT_SERVICE_ACCOUNT_GCP_PROJECT_ID>/<managementServiceAccountProjectID>/g" ./all-in-one/terraform.tfvars.jsonsed -i "s/<MANAGEMENT_SERVICE_ACCOUNT_ID>/<managementServiceAccountID>/g" ./all-in-one/terraform.tfvars.jsonterraform -chdir=all-in-one init && terraform -chdir=all-in-one applywhere...projectIDmust be replaced with the ID of your GCP project.scanningBucketNamemust be replaced with the name of your [Cloud Storage Bucket], as it appears in Cloud Storage. You can only specify one bucket. Example:my-bucket-to-scan-01scannerStackNamemust be replaced with the prefix of the stack name. The prefix must be less than 17 characters. Example:FSS-AIO-SCANNERstorageStackNamemust be replaced with the prefix of the stack name. The prefix must be less than 17 characters. Example:FSS-AIO-STORAGEregionmust be replaced with the region of your bucket. For the list of supported GCP regions, please see Supported GCP Regions. Example:us-central1managementServiceAccountProjectIDmust be replaced with the GCP project ID of your management service account retrieved fromserviceAccountEmailin the previous step. Example:cloud-one-service-account@<managementServiceAccountProjectID>.iam.gserviceaccount.commanagementServiceAccountIDmust be replaced with the service account retrieved fromserviceAccountEmailin the previous step. Example:<managementServiceAccountID>@my-gcp-project.iam.gserviceaccount.com
When the deployment is finished, Terraform generates the stack outputs in a tfstate file for the deployment steps later on.
Create a scanner stack by using Terraform
Procedure
- Log into gcloud:
gcloud auth application-default login - Set up the gcloud project
gcloud config set project PROJECT-IDwherePROJECT-IDis the ID of the GCP project where you are deploying the stack. - Download the templates:
wget https://file-storage-security.s3.amazonaws.com/latest/gcp-templates/gcp-templates-terraform.zip && unzip gcp-templates-terraform.zip - Configure the GCP project by using the Terraform deployment:
sed -i.bak "s/<GCP_PROJECT_ID>/<projectID>/g" ./gcp-configuration/terraform.tfvars.jsonterraform -chdir=gcp-configuration init && terraform -chdir=gcp-configuration applywhere...<projectID>must be replaced with the ID of your GCP project.
- Create the scanner stack in GCP with the following commands:
sed -i.bak "s/<GCP_PROJECT_ID>/<projectID>/g" ./scanners/terraform.tfvars.jsonsed -i "s/<SCANNER_STACK_NAME>/<scannerStackName>/g" ./scanners/terraform.tfvars.jsonsed -i "s/<GCP_REGION>/<region>/g" ./scanners/terraform.tfvars.jsonsed -i "s/<MANAGEMENT_SERVICE_ACCOUNT_GCP_PROJECT_ID>/<managementServiceAccountProjectID>/g" ./scanners/terraform.tfvars.jsonsed -i "s/<MANAGEMENT_SERVICE_ACCOUNT_ID>/<managementServiceAccountID>/g" ./scanners/terraform.tfvars.jsonterraform -chdir=scanners init && terraform -chdir=scanners applywhere...projectIDmust be replaced with the ID of your GCP project.scannerStackNamemust be replaced with the prefix of the stack name. The prefix must be less than 17 characters. Example:FSS-AIO-SCANNERregionmust be replaced with the region of your bucket. For the list of supported GCP regions, please see Supported GCP Regions. Example:us-central1managementServiceAccountProjectIDmust be replaced with the GCP project ID of your management service account retrieved fromserviceAccountEmailin the previous step. Example:cloud-one-service-account@<managementServiceAccountProjectID>.iam.gserviceaccount.commanagementServiceAccountIDmust be replaced with the service account retrieved fromserviceAccountEmailin the previous step. Example:<managementServiceAccountID>@my-gcp-project.iam.gserviceaccount.com
When the deployment is finished, Terraform generates the stack outputs in a tfstate file for the deployment steps later on.
Create a storage stack by using Terraform
Procedure
- Log into gcloud:
gcloud auth application-default login - Set up the gcloud project
gcloud config set project PROJECT-IDwherePROJECT-IDis the ID of the GCP project where you are deploying the stack. - Download the templates:
wget https://file-storage-security.s3.amazonaws.com/latest/gcp-templates/gcp-templates-terraform.zip && unzip gcp-templates-terraform.zip - Configure the GCP project using Terraform deployment:
sed -i.bak "s/<GCP_PROJECT_ID>/<projectID>/g" ./gcp-configuration/terraform.tfvars.jsonterraform -chdir=gcp-configuration init && terraform -chdir=gcp-configuration applywhere...projectIDmust be replaced with the ID of your GCP project.
- Create the storage stack in GCP with the following commands:
sed -i.bak "s/<GCP_PROJECT_ID>/<projectID>/g" ./storages/terraform.tfvars.jsonsed -i "s/<STORAGE_STACK_NAME>/<storageStackName>/g" ./storages/terraform.tfvars.jsonsed -i "s/<GCP_REGION>/<region>/g" ./storages/terraform.tfvars.jsonsed -i "s/<SCANNING_BUCKET_NAME>/<scanningBucketName>/g" ./storages/terraform.tfvars.jsonsed -i "s/<MANAGEMENT_SERVICE_ACCOUNT_GCP_PROJECT_ID>/<managementServiceAccountProjectID>/g" ./storages/terraform.tfvars.jsonsed -i "s/<MANAGEMENT_SERVICE_ACCOUNT_ID>/<managementServiceAccountID>/g" ./storages/terraform.tfvars.jsonsed -i "s/<SCANNER_STACK_PROJECT_ID>/<scannerProjectID>/g" ./storages/terraform.tfvars.jsonsed -i "s/<SCANNER_STACK_PUBSUB_TOPIC_NAME>/<scannerTopic>/g" ./storages/terraform.tfvars.jsonsed -i "s/<SCANNER_STACK_SERVICE_ACCOUNT_ID>/<scannerServiceAccountID>/g" ./storages/terraform.tfvars.jsonterraform -chdir=storages init && terraform -chdir=storages applywhere...projectIDmust be replaced with the ID of your GCP project.scanningBucketNamemust be replaced with the name of your [Cloud Storage Bucket], as it appears in Cloud Storage. You can only specify one bucket. Example:my-bucket-to-scan-01storageStackNamemust be replaced with the prefix of the stack name. The prefix must be less than 17 characters. Example:FSS-AIO-STORAGEregionmust be replaced with the region of your bucket. For the list of supported GCP regions, please see Supported GCP Regions. Example:us-central1managementServiceAccountProjectIDmust be replaced with the GCP project ID of your management service account retrieved fromserviceAccountEmailin the previous step. Example:cloud-one-service-account@<managementServiceAccountProjectID>.iam.gserviceaccount.commanagementServiceAccountIDmust be replaced with the service account retrieved fromserviceAccountEmailin the previous step. Example:<managementServiceAccountID>@my-gcp-project.iam.gserviceaccount.comscannerProjectIDmust be replaced with the ID of your scanner's GCP project from thescanner_informationsoutput of the scanner's Terraform deployment.scannerTopicmust be replaced with the name of your scanner's Pub/Sub topic from thescanner_informationsoutput of the scanner's Terraform deployment.scannerServiceAccountIDmust be replaced with the name of your scanner's service account ID from thescanner_informationsoutput of the scanner's Terraform deployment.
When the deployment is finished, Terraform generates the stack outputs in a tfstate file for the deployment steps later on.
