When you preview and deploy applications, you can use an existing service account, or Application Design Center can automatically create a service account.
To deploy applications using your own service account, you must grant the necessary Identity and Access Management roles and permissions, including the following:
- Add IAM policy bindings to the service account and user account.
- Grant the service account the roles required to deploy each resource.
- Add permissions to the service account to deploy outside of the project where the service account was created.
- Update your organization policies to let you create a service account in one project and use it to deploy resources in another project.
Configure your service account
To configure your service account, do the following:
Grant the Service Account User role (
roles/iam.serviceAccountUser) on your service account to the App Design Center service agent of the management project:gcloud iam service-accounts add-iam-policy-binding SERVICE_ACCOUNT_EMAIL \ --member="serviceAccount:service-MANAGEMENT_PROJECT_NUMBER@gcp-sa-designcenter.iam.gserviceaccount.com" \ --role="roles/iam.serviceAccountUser"Replace the following:
SERVICE_ACCOUNT_EMAIL: Your service account email, such asmy-service-account@SERVICE_ACCOUNT_PROJECT_ID.iam.gserviceaccount.com.SERVICE_ACCOUNT_PROJECT_ID: The project ID of the project that contains your service account.MANAGEMENT_PROJECT_NUMBER: The project number of the management project that contains your space.
Grant the
roles/iam.serviceAccountUserrole on your service account to the user who deploys the application:gcloud iam service-accounts add-iam-policy-binding SERVICE_ACCOUNT_EMAIL \ --member="user:USER_EMAIL" \ --role="roles/iam.serviceAccountUser"Replace the following:
SERVICE_ACCOUNT_EMAIL: Your service account email, such asmy-service-account@SERVICE_ACCOUNT_PROJECT_ID.iam.gserviceaccount.com.USER_EMAIL: The email address of the user who performs the deployment.
On the management project that contains your space, grant the App Hub Editor (
roles/apphub.editor) and Cloud Infrastructure Manager Agent (roles/config.agent) roles to your service account:gcloud projects add-iam-policy-binding MANAGEMENT_PROJECT_ID \ --member="serviceAccount:SERVICE_ACCOUNT_EMAIL" \ --role="roles/apphub.editor"gcloud projects add-iam-policy-binding MANAGEMENT_PROJECT_ID \ --member="serviceAccount:SERVICE_ACCOUNT_EMAIL" \ --role="roles/config.agent"Replace the following:
MANAGEMENT_PROJECT_ID: The project ID of the management project that contains your space.SERVICE_ACCOUNT_EMAIL: Your service account email, such asmy-service-account@SERVICE_ACCOUNT_PROJECT_ID.iam.gserviceaccount.com.
In the project that contains your service account, make sure that the
iam.disableCrossProjectServiceAccountUsageorganization policy constraint isn't enforced. This constraint is enforced by default.Disable enforcement of the organization policy constraint:
gcloud resource-manager org-policies disable-enforce \ iam.disableCrossProjectServiceAccountUsage \ --project=SERVICE_ACCOUNT_PROJECT_IDReplace
SERVICE_ACCOUNT_PROJECT_IDwith the project ID of the project that contains your service account.On the deployment project where you're deploying resources, grant your service account the Service Usage Admin role (
roles/serviceusage.serviceUsageAdmin) and the roles required to deploy those resources. App Design Center displays the required roles in the Google Cloud console when you deploy applications.For example, grant the
roles/serviceusage.serviceUsageAdminrole and the Cloud Run Admin role (roles/run.admin) to your service account on the deployment project:gcloud projects add-iam-policy-binding DEPLOYMENT_PROJECT_ID \ --member="serviceAccount:SERVICE_ACCOUNT_EMAIL" \ --role="roles/serviceusage.serviceUsageAdmin"gcloud projects add-iam-policy-binding DEPLOYMENT_PROJECT_ID \ --member="serviceAccount:SERVICE_ACCOUNT_EMAIL" \ --role="roles/run.admin"Replace the following:
DEPLOYMENT_PROJECT_ID: The project ID of the project where you're deploying resources.SERVICE_ACCOUNT_EMAIL: Your service account email, such asmy-service-account@SERVICE_ACCOUNT_PROJECT_ID.iam.gserviceaccount.com.
App Design Center uses Infrastructure Manager to deploy applications in the console. To use your own service account to deploy with Infra Manager, complete the steps in Grant access across multiple projects.
Optional: If the application that you're deploying contains private components that you imported through a Developer Connect connection, grant your service account the Service Account Token Creator role (
roles/iam.serviceAccountTokenCreator) on the project that contains your service account:gcloud projects add-iam-policy-binding SERVICE_ACCOUNT_PROJECT_ID \ --member="serviceAccount:SERVICE_ACCOUNT_EMAIL" \ --role="roles/iam.serviceAccountTokenCreator"Replace the following:
SERVICE_ACCOUNT_PROJECT_ID: The project ID of the project that contains your service account.SERVICE_ACCOUNT_EMAIL: Your service account email, such asmy-service-account@SERVICE_ACCOUNT_PROJECT_ID.iam.gserviceaccount.com.
What's next
- Learn how to update, scale, and delete your resources by managing applications.
- Provision your infrastructure with the console or the command line by deploying applications.