Service account
Cloud functions require a service account to use during runtime, granting the function permissions to use other Google Cloud Platform (GCP) services. There are some permissions commonly required for Cloudera DataFlow Functions.
Creating/adding service account
When configuring your Cloud function:
-
Locate the Runtime service account section of the Runtime, build, connections and security settings.
-
If you already have a service account for this purpose, you may select it here. Otherwise, select Create new service account.
-
Specify the account name and ID.
-
Click Create service account.
You will need to add permissions to the Service Account separately.
When configuring Secrets accessible to the Cloud function, the console automatically prompts you to grant the necessary permissions to the Runtime Service Account. For more information on this, see the Google Cloud Secret Manager section in Parameters.
Adding additional role to service account
When providing custom extensions or resources from a Cloud Storage bucket, you need to add an additional role to the Service Account:
-
Navigate to the IAM & Admin GCP service, and select Roles on the left sidebar.
-
Click Create role.
-
Name the role.
-
Click Add permissions.
-
In the Filter section, add storage.buckets.get for Enter property name or value.
-
Click Add.
-
Do the same for the storage.buckets.list permission.
-
Click Create.
-
Select IAM from the left sidebar.
-
Locate your Cloud function's Runtime Service Account, and click the Edit pencil icon on the far right.
-
In the Role drop-down menu, select .
-
Click Save.
For additional information, see Cloud Storage.
Your Service Account now allows your Cloud function to list and get objects from buckets.
Granting service account access to specific bucket
You need to grant your Service Account access to the specific bucket configured in the CLOUD_STORAGE_BUCKET environment variable:
-
Navigate to the Cloud Storage GCP service, and click your bucket name.
-
Select the Permissions tab under the bucket name.
-
In the Permissions section, click Add.
-
Provide the fully qualified name of the Runtime Service Account.
For example: naaf@projectname.iam.gserviceaccount.com
-
In Select a role, select Cloud Storage on the left, and Storage Object Viewer on the right.
-
Click Save.