Docs
Roles
Dormeto acts in your AWS accounts and Google Cloud projects through roles you can read. The manager holds no key or credential for them.
19 min read
The router's roles
A router acts under identities of its own, which its install creates and its removal deletes.
AWS
- Four roles under
/dormeto/router/:dmtr-<env>-<region>-controller,-waker,-schedulerand-onboarder. - The router's functions act as them; EventBridge Scheduler as the scheduler's.
- Each carries the permissions boundary
DmtRouterBoundary, which caps what it can do. - Their policies are in the router's blueprint,
modules/manager/artifacts/router/blueprint.jsonin terraform-aws-dormeto-0.24.0.zip. - The boundary is
router-boundary.json, in that archive and in dormeto-access-0.24.0.zip.
Google Cloud
- A service account,
dmtr-<region>@<project>.iam.gserviceaccount.com, one per router. Its services and tasks run as it, with no key. dormeto gcp routers installcreates it and grants it these roles, as you.dormeto gcp routers uninstalldeletes it with its grants.- Two custom roles and five predefined ones (the grants).
- The optional access adds roles of its own.
dmtr-<env>-<region>-controller
AWS only
Naps, wakes and checks the workloads. It starts and stops only what carries dormeto:workload.
| Service | Permissions |
|---|---|
dynamodb | dynamodb:GetItem, dynamodb:UpdateItem, dynamodb:Scan, dynamodb:Query, dynamodb:DeleteItem |
ec2 | ec2:DescribeInstances, ec2:StartInstances, ec2:StopInstances, ec2:ModifyInstanceAttribute, ec2:CreateTags, ec2:DeleteTags |
elasticloadbalancing | elasticloadbalancing:DescribeRules, elasticloadbalancing:DescribeTargetHealth, elasticloadbalancing:DescribeTargetGroups, elasticloadbalancing:DescribeListeners, elasticloadbalancing:DescribeTags, elasticloadbalancing:ModifyRule |
autoscaling | autoscaling:DescribeAutoScalingGroups, autoscaling:DescribeScalingActivities, autoscaling:UpdateAutoScalingGroup, autoscaling:SuspendProcesses, autoscaling:ResumeProcesses |
ecs | ecs:DescribeServices, ecs:DescribeTaskDefinition, ecs:UpdateService |
application-autoscaling | application-autoscaling:DescribeScalableTargets, application-autoscaling:RegisterScalableTarget |
rds | rds:DescribeDBInstances, rds:DescribeDBClusters, rds:StartDBInstance, rds:StopDBInstance, rds:StartDBCluster, rds:StopDBCluster |
cloudwatch | cloudwatch:GetMetricData |
tag | tag:GetResources |
cognito-idp | cognito-idp:DescribeUserPoolClient |
lambda | lambda:InvokeFunction, lambda:GetAccountSettings |
sqs | sqs:SendMessage, sqs:ReceiveMessage, sqs:DeleteMessage, sqs:GetQueueAttributes, sqs:ChangeMessageVisibility |
events | events:PutEvents |
s3 | s3:GetObject |
eks | eks:DescribeCluster |
logs | logs:CreateLogStream, logs:PutLogEvents |
dmtr-<env>-<region>-waker
AWS only
Answers the requests while a workload sleeps, and asks the controller for the wake.
| Service | Permissions |
|---|---|
dynamodb | dynamodb:GetItem, dynamodb:UpdateItem, dynamodb:Query |
lambda | lambda:InvokeFunction |
events | events:PutEvents |
s3 | s3:GetObject |
eks | eks:DescribeCluster |
logs | logs:CreateLogStream, logs:PutLogEvents |
dmtr-<env>-<region>-scheduler
AWS only
EventBridge Scheduler's, for the idle check every 5 minutes.
| Service | Permissions |
|---|---|
lambda | lambda:InvokeFunction |
sqs | sqs:SendMessage |
dmtr-<env>-<region>-onboarder
AWS only
Onboards, offboards and repairs: it changes your rules, adds Dormeto's rules and target groups, and tags the backends.
| Service | Permissions |
|---|---|
dynamodb | dynamodb:GetItem, dynamodb:UpdateItem, dynamodb:Query, dynamodb:Scan, dynamodb:DeleteItem |
ec2 | ec2:DescribeInstances, ec2:CreateTags, ec2:DeleteTags |
elasticloadbalancing | elasticloadbalancing:DescribeTargetGroups, elasticloadbalancing:DescribeListeners, elasticloadbalancing:DescribeRules, elasticloadbalancing:DescribeTags, elasticloadbalancing:DescribeTargetHealth, elasticloadbalancing:DescribeAccountLimits, elasticloadbalancing:CreateTargetGroup, elasticloadbalancing:ModifyTargetGroupAttributes, elasticloadbalancing:DeleteTargetGroup, elasticloadbalancing:RegisterTargets, elasticloadbalancing:DeregisterTargets, elasticloadbalancing:ModifyRule, elasticloadbalancing:CreateRule, elasticloadbalancing:DeleteRule, elasticloadbalancing:SetRulePriorities, elasticloadbalancing:AddTags, elasticloadbalancing:RemoveTags |
autoscaling | autoscaling:DescribeAutoScalingGroups, autoscaling:CreateOrUpdateTags, autoscaling:DeleteTags |
ecs | ecs:ListClusters, ecs:ListServices, ecs:DescribeServices, ecs:TagResource, ecs:UntagResource |
rds | rds:DescribeDBInstances, rds:DescribeDBClusters, rds:AddTagsToResource, rds:RemoveTagsFromResource |
cognito-idp | cognito-idp:DescribeUserPoolClient |
lambda | lambda:InvokeFunction, lambda:RemovePermission |
sqs | sqs:ReceiveMessage, sqs:DeleteMessage, sqs:GetQueueAttributes, sqs:ChangeMessageVisibility |
eks | eks:DescribeCluster |
logs | logs:CreateLogStream, logs:PutLogEvents |
dormetoRouter Google Cloud only
Dormeto router. Reads its workloads' load balancers, VMs and groups, and updates their URL maps. Manages their waker backend services and autoscalers; reads request counts.
| Resource | Permissions |
|---|---|
compute.urlMaps | compute.urlMaps.get, compute.urlMaps.list, compute.urlMaps.update |
compute.backendServices | compute.backendServices.get, compute.backendServices.use, compute.backendServices.create, compute.backendServices.delete |
compute.regionNetworkEndpointGroups | compute.regionNetworkEndpointGroups.use |
compute.globalForwardingRules | compute.globalForwardingRules.list |
compute.targetHttpProxies | compute.targetHttpProxies.list |
compute.targetHttpsProxies | compute.targetHttpsProxies.list |
compute.instances | compute.instances.get |
compute.instanceGroups | compute.instanceGroups.get |
compute.instanceGroupManagers | compute.instanceGroupManagers.get |
compute.autoscalers | compute.autoscalers.get, compute.autoscalers.update |
compute.machineTypes | compute.machineTypes.get |
compute.globalOperations | compute.globalOperations.get |
compute.zoneOperations | compute.zoneOperations.get |
compute.regionOperations | compute.regionOperations.get |
monitoring.timeSeries | monitoring.timeSeries.list |
compute.networkEndpointGroups | compute.networkEndpointGroups.get |
compute.regionUrlMaps | compute.regionUrlMaps.get, compute.regionUrlMaps.list, compute.regionUrlMaps.update |
compute.regionBackendServices | compute.regionBackendServices.get, compute.regionBackendServices.use, compute.regionBackendServices.create, compute.regionBackendServices.delete |
compute.regionTargetHttpProxies | compute.regionTargetHttpProxies.list |
compute.regionTargetHttpsProxies | compute.regionTargetHttpsProxies.list |
compute.forwardingRules | compute.forwardingRules.list |
Google marks compute.urlMaps.get, compute.urlMaps.list and compute.urlMaps.update as TESTING in custom roles; no narrower predefined role holds them. compute.autoscalers.update has no tag condition: an autoscaler carries none.
dormetoRouterBackends Google Cloud only
Dormeto router backends. Starts, stops, suspends and resumes its workloads' VMs and managed groups. It changes a stopped VM's machine type, for the fallback types.
| Resource | Permissions |
|---|---|
compute.instances | compute.instances.start, compute.instances.stop, compute.instances.suspend, compute.instances.resume, compute.instances.setMachineType |
compute.instanceGroupManagers | compute.instanceGroupManagers.update, compute.instanceGroupManagers.use |
Granted only on what carries the tag dormeto=managed. An autoscaler's change is checked on its group's tag.
Predefined roles Google Cloud only
The permissions Dormeto uses:
| Role | Permissions |
|---|---|
roles/datastore.user | datastore.entities.get, datastore.entities.list, datastore.entities.create, datastore.entities.update, datastore.entities.delete |
roles/logging.viewAccessor | logging.views.access |
roles/cloudtasks.enqueuer | cloudtasks.tasks.create |
roles/run.invoker | run.routes.invoke |
roles/iam.serviceAccountUser | iam.serviceAccounts.actAs |
The grants Google Cloud only
The CLI adds exactly these bindings, and never changes or removes one it did not add. In a condition, {project} is the project's ID, {region} the router's region, {database} its database, dmtr-<region>.
| Role | Member | Where | Condition | What it allows |
|---|---|---|---|---|
projects/{project}/roles/dormetoRouter | The router's account | The project | None | The role's permissions. |
projects/{project}/roles/dormetoRouterBackends | The router's account | The project | Dormeto-managed resources: resource.matchTag('{project}/dormeto', 'managed') | Starts, stops, suspends and resumes what carries the tag; changes a stopped VM's type. |
roles/datastore.user | The router's account | The project | The router's database: resource.name == "projects/{project}/databases/{database}" | The router's Firestore documents. |
roles/logging.viewAccessor | The router's account | The project | The router's log view: resource.name == "projects/{project}/locations/global/buckets/_Default/views/dmtr-{region}-lb" | Reads the request logs, through that view only (Router). |
roles/cloudtasks.enqueuer | The router's account | The queue dmtr-<region> | None | Creates tasks in the router's queue. |
roles/run.invoker | The router's account | The Cloud Run service dmtr-<region>-controller | None | Calls the controller, as the job and the tasks do. |
roles/iam.serviceAccountUser | The router's account | The service account itself | None | Signs the tasks' OIDC tokens as itself. |
The optional access's roles Google Cloud only
Each feature asked at the install adds its roles to the router's service account (Router).
| Role | Member | Where | Condition | What it allows |
|---|---|---|---|---|
dormetoRouterDatabasesRead, for cloud-sqlprojects/{project}/roles/dormetoRouterDatabasesRead | The router's account | The project | None | cloudsql.instances.get, cloudsql.instances.list |
dormetoRouterDatabases, for cloud-sqlprojects/{project}/roles/dormetoRouterDatabases | The router's account | The project | Dormeto-managed resources: resource.matchTag('{project}/dormeto', 'managed') | cloudsql.instances.update |
dormetoRouterKubernetes, for gkeprojects/{project}/roles/dormetoRouterKubernetes | The router's account | The project | None | container.clusters.get, container.clusters.connect |
The discovery role
The manager discovers through a read-only role.
AWS
DmtDiscoveryRole, in every account to discover, assumed at each run bydmt-<env>-manager-discovery.- Its policy is
discovery-policy.jsonin the access archive. What it reads, and how to create it: Access.
Google Cloud
dormetoDiscovery, the custom role of the manager's discovery account, granted at each scope (the manager's grants).- Defined in a project scope's project, or in the organization for a folder or organization scope.
dormetoDiscovery Google Cloud only
Dormeto manager discovery. Reads its scopes' projects, folders, organizations, load balancers, VMs, groups, Cloud Run services and request counts.
| Resource | Permissions |
|---|---|
resourcemanager.projects | resourcemanager.projects.get |
compute.urlMaps | compute.urlMaps.get, compute.urlMaps.list |
compute.regionUrlMaps | compute.regionUrlMaps.get, compute.regionUrlMaps.list |
compute.backendServices | compute.backendServices.get, compute.backendServices.list |
compute.regionBackendServices | compute.regionBackendServices.get, compute.regionBackendServices.list |
compute.targetHttpProxies | compute.targetHttpProxies.get, compute.targetHttpProxies.list |
compute.targetHttpsProxies | compute.targetHttpsProxies.get, compute.targetHttpsProxies.list |
compute.regionTargetHttpProxies | compute.regionTargetHttpProxies.get, compute.regionTargetHttpProxies.list |
compute.regionTargetHttpsProxies | compute.regionTargetHttpsProxies.get, compute.regionTargetHttpsProxies.list |
compute.globalForwardingRules | compute.globalForwardingRules.get, compute.globalForwardingRules.list |
compute.forwardingRules | compute.forwardingRules.get, compute.forwardingRules.list |
compute.instanceGroups | compute.instanceGroups.get, compute.instanceGroups.list |
compute.instanceGroupManagers | compute.instanceGroupManagers.get, compute.instanceGroupManagers.list |
compute.instances | compute.instances.get, compute.instances.list |
compute.networkEndpointGroups | compute.networkEndpointGroups.get, compute.networkEndpointGroups.list |
run.services | run.services.get, run.services.list |
monitoring.timeSeries | monitoring.timeSeries.list |
Defined in an organization only, for folder and organization scopes:
| Resource | Permissions |
|---|---|
resourcemanager.folders | resourcemanager.folders.get, resourcemanager.folders.list |
resourcemanager.organizations | resourcemanager.organizations.get |
The command role
The manager acts on routers through a role in each router's account or project.
AWS
DmtCommandRoleby default, in the router's account: the manager assumes it to install, upgrade or remove a router.- Each call is in that account's CloudTrail, by
assumed-role/DmtCommandRole/dmt-<env>-operations. - The access module and the AWS CLI script create it at the root path, with
DmtRouterBoundary(Access). - The manager's account gets them from its module. Or bring your own role.
Google Cloud
dormetoCommand, the custom role of the manager's command account, in each router's project.- With the invoker and tag user roles (the manager's grants), it binds and removes
dormeto=managed.
From your request to the router
AWS only
- The operations role,
dmt-<env>-manager-operations, may assume the command role's name only, in your organization (aws:ResourceOrgID). - Its trust accepts that role alone, by name.
- With it, the operation creates the router's roles, then its functions, table, queues, log groups and schedule.
- Then the router's access entries in the region's EKS clusters, and the private clusters' proxies.
- The router then runs as its own roles.
- At each discovery run, the manager checks it can assume the command role. Discovery lists the accounts where it can't, and refuses onboarding there.
dormetoCommand Google Cloud only
Dormeto manager command. Binds and unbinds the managed tag on a router project's VMs, groups and Cloud SQL instances.
| Resource | Permissions |
|---|---|
compute.instances | compute.instances.listTagBindings, compute.instances.createTagBinding, compute.instances.deleteTagBinding |
compute.instanceGroupManagers | compute.instanceGroupManagers.listTagBindings, compute.instanceGroupManagers.createTagBinding, compute.instanceGroupManagers.deleteTagBinding |
cloudsql.instances | cloudsql.instances.get, cloudsql.instances.listTagBindings, cloudsql.instances.createTagBinding, cloudsql.instances.deleteTagBinding |
The manager's accounts Google Cloud only
The manager, in AWS, acts in Google Cloud as two service accounts of a host project. dormeto gcp connect creates them, their roles and every grant, as you (Manager).
The accounts and the federation
- The APIs it turns on in the host project, never off:
iam.googleapis.com,iamcredentials.googleapis.com,sts.googleapis.com,cloudresourcemanager.googleapis.com,cloudbilling.googleapis.com. dmt-<env>-discovery@<host>.iam.gserviceaccount.comreads at the scopes, and Google's list prices; it writes nothing.dmt-<env>-command@<host>.iam.gserviceaccount.comcalls the routers' controllers and binds the tag, in their projects only.- The workload identity pool
dmt-<env>has the provideraws-<account>, such asaws-121014831971. - It maps
google.subject=assertion.arnandattribute.aws_role=assertion.arn.extract('assumed-role/{role}/'). - Its condition admits the manager's roles only:
assertion.arn.startsWith('arn:aws:sts::<account>:assumed-role/dmt-<env>-manager-'). - Each service account grants
roles/iam.workloadIdentityUsertoprincipalSet://iam.googleapis.com/projects/<hostNumber>/locations/global/workloadIdentityPools/dmt-<env>/attribute.aws_role/<awsRole>, for these roles: - The discovery account's:
dmt-<env>-manager-discovery,dmt-<env>-manager-api,dmt-<env>-manager-savings. - The command account's:
dmt-<env>-manager-operations,dmt-<env>-manager-api,dmt-<env>-manager-fleet. - No key is made or stored: a call trades its AWS signature for a short-lived Google token.
The manager's grants
The CLI adds exactly these bindings. <host> is the host project, <project> a project with a router. Your permissions to make them: connect.
| Role | Member | Where | Condition | What it allows |
|---|---|---|---|---|
dormetoDiscovery | The discovery account | Each scope: an organization, a folder or a project | None | Reads what the scopes hold. Writes nothing. |
roles/run.invoker | The command account | The router's controller, the Cloud Run service dmtr-<region>-controller | None | Calls the controller. |
roles/resourcemanager.tagUser | The command account | The tag value <project>/dormeto/managed | None | Binds the tag to a workload's VMs and groups. |
dormetoCommand | The command account | The router's project | None | Lists, creates and deletes the tag's bindings, on VMs, groups and Cloud SQL instances. |
The operator's permissions
Calling the manager
- The CLI calls the API's
/iam/*routes: the caller needsexecute-api:Invokeon them, in the manager's account. - It also needs
apigateway:GETto find the API by name, unless given--api-url. - The manager treats the caller as an administrator; the audit and the operations name its ARN.
- Its IAM policy is the only limit: grant the routes its commands call, by method and path.
- Read-only: every command that only reads,
arn:aws:execute-api:<region>:<account>:<api id>/*/GET/iam/*. It still reads the users and the audit. - Every command:
arn:aws:execute-api:<region>:<account>:<api id>/*/*/iam/*, the module'sapi_iam_arnoutput. - Wake and nap: check the caller with
whoami, read the workloads, wake and nap them.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "execute-api:Invoke",
"Resource": [
"arn:aws:execute-api:<region>:<account>:<api id>/*/GET/iam/me",
"arn:aws:execute-api:<region>:<account>:<api id>/*/GET/iam/health",
"arn:aws:execute-api:<region>:<account>:<api id>/*/GET/iam/workloads",
"arn:aws:execute-api:<region>:<account>:<api id>/*/GET/iam/workloads/*",
"arn:aws:execute-api:<region>:<account>:<api id>/*/POST/iam/workloads/*/wake",
"arn:aws:execute-api:<region>:<account>:<api id>/*/POST/iam/workloads/*/nap"
]
}]
}
For keep-awake, pause and resume, add /*/POST/iam/workloads/*/pause and /*/POST/iam/workloads/*/resume. Each change's route: Permission to call the manager.
Calling a Google Cloud router Google Cloud only
Each command tests its steps' permissions first: one missing stops it, with nothing changed. roles/owner holds them all. A step names what it reads, makes or removes; neg is the waker's network endpoint group.
dormeto gcp check
| Step | Permissions |
|---|---|
read | resourcemanager.projects.get, resourcemanager.projects.getIamPolicy, serviceusage.services.list, serviceusage.services.use |
dormeto gcp routers install
| Step | Permissions |
|---|---|
read | resourcemanager.projects.get, resourcemanager.projects.getIamPolicy, serviceusage.services.list, serviceusage.services.use |
apis | serviceusage.services.enable, serviceusage.operations.get |
roles | iam.roles.get, iam.roles.create, iam.roles.update, iam.roles.undelete |
serviceAccount | iam.serviceAccounts.get, iam.serviceAccounts.create, iam.serviceAccounts.getIamPolicy, iam.serviceAccounts.setIamPolicy, iam.serviceAccounts.actAs |
projectBindings | resourcemanager.projects.getIamPolicy, resourcemanager.projects.setIamPolicy |
tag | resourcemanager.tagKeys.create, resourcemanager.tagKeys.get, resourcemanager.tagValues.create, resourcemanager.tagValues.get |
database | datastore.databases.create, datastore.databases.get, datastore.operations.get, datastore.entities.create, datastore.entities.get, datastore.entities.update |
queue | cloudtasks.queues.create, cloudtasks.queues.get, cloudtasks.queues.update, cloudtasks.queues.getIamPolicy, cloudtasks.queues.setIamPolicy |
logView | logging.views.create, logging.views.get, logging.views.update |
roles undeletes a custom role deleted before, whose ID Google blocks 37 days.
dormeto gcp routers install, the router
Added to install unless --access-only; image only for --image.
| Step | Permissions |
|---|---|
image | artifactregistry.repositories.get, artifactregistry.repositories.downloadArtifacts, artifactregistry.dockerimages.get |
cloudRun | run.services.create, run.services.get, run.services.update, run.services.getIamPolicy, run.services.setIamPolicy, run.operations.get, run.routes.invoke, iam.serviceAccounts.actAs |
neg | compute.regionNetworkEndpointGroups.create, compute.regionNetworkEndpointGroups.get, compute.regionOperations.get |
job | cloudscheduler.jobs.create, cloudscheduler.jobs.get, cloudscheduler.jobs.update, iam.serviceAccounts.actAs |
dormeto gcp routers uninstall
| Step | Permissions |
|---|---|
read | resourcemanager.projects.get, resourcemanager.projects.getIamPolicy, serviceusage.services.list, serviceusage.services.use, datastore.databases.list, datastore.databases.get, datastore.entities.get, datastore.entities.list, run.routes.invoke |
job | cloudscheduler.jobs.get, cloudscheduler.jobs.delete |
neg | compute.regionNetworkEndpointGroups.get, compute.regionNetworkEndpointGroups.delete, compute.regionOperations.get |
cloudRun | run.services.get, run.services.delete, run.operations.get |
logView | logging.views.get, logging.views.delete |
queue | cloudtasks.queues.get, cloudtasks.queues.delete |
database | datastore.databases.get, datastore.databases.delete, datastore.operations.get |
projectBindings | resourcemanager.projects.getIamPolicy, resourcemanager.projects.setIamPolicy |
tag | resourcemanager.tagKeys.get, resourcemanager.tagKeys.delete, resourcemanager.tagValues.get, resourcemanager.tagValues.delete |
serviceAccount | iam.serviceAccounts.get, iam.serviceAccounts.delete |
roles | iam.roles.get, iam.roles.delete |
The tag and the custom roles stay while another router lists them.
dormeto gcp workloads list
Also show, nap and wake, which call the controller with your identity token.
| Step | Permissions |
|---|---|
invoke | run.routes.invoke |
dormeto gcp workloads onboard
| Step | Permissions |
|---|---|
invoke | run.routes.invoke |
tag | resourcemanager.tagValues.get, resourcemanager.tagValueBindings.create, resourcemanager.tagValueBindings.delete, compute.instances.listTagBindings, compute.instances.createTagBinding, compute.instances.deleteTagBinding, compute.instanceGroupManagers.listTagBindings, compute.instanceGroupManagers.createTagBinding, compute.instanceGroupManagers.deleteTagBinding |
requestLogs | compute.backendServices.get, compute.backendServices.update, compute.regionBackendServices.get, compute.regionBackendServices.update, compute.globalOperations.get, compute.regionOperations.get |
It asks the whole step requestLogs only with --request-logs; without, only compute.backendServices.get and compute.regionBackendServices.get. dormeto gcp check tests the whole list.
dormeto gcp workloads offboard
| Step | Permissions |
|---|---|
invoke | run.routes.invoke |
tag | resourcemanager.tagValues.get, resourcemanager.tagValueBindings.delete, compute.instances.listTagBindings, compute.instances.deleteTagBinding, compute.instanceGroupManagers.listTagBindings, compute.instanceGroupManagers.deleteTagBinding |
requestLogs | compute.backendServices.get, compute.backendServices.update, compute.regionBackendServices.get, compute.regionBackendServices.update, compute.globalOperations.get, compute.regionOperations.get |
It asks the step requestLogs only for a workload whose onboarding turned its request logs on.
With the optional access
| Access | Command | Step | Permissions |
|---|---|---|---|
cloud-sql | gcp workloads onboard | tag | cloudsql.instances.get, cloudsql.instances.listTagBindings, cloudsql.instances.createTagBinding, cloudsql.instances.deleteTagBinding, datastore.entities.get |
cloud-sql | gcp workloads offboard | tag | cloudsql.instances.get, cloudsql.instances.listTagBindings, cloudsql.instances.deleteTagBinding |
gke | gcp workloads onboard | cluster | container.clusters.get, container.roles.create, container.roles.update, container.roleBindings.create, container.roleBindings.update, container.services.get, container.roles.escalate, container.roles.bind, container.clusters.connect, container.replicaSets.list, container.pods.list, container.roles.get, container.roleBindings.get, container.roles.delete, container.roleBindings.delete, datastore.databases.get, datastore.entities.get, datastore.entities.update |
gke | gcp workloads offboard | cluster | container.roles.delete, container.roleBindings.delete, container.roleBindings.update, container.roles.bind, container.clusters.connect, container.clusters.get, container.roles.get, container.roleBindings.get, datastore.databases.get, datastore.entities.get, datastore.entities.update |
dormeto gcp connect
Tested at the host, and at each scope and router project for the steps acting there.
| Step | Permissions |
|---|---|
read | resourcemanager.projects.get, resourcemanager.projects.getIamPolicy, serviceusage.services.list, serviceusage.services.use, run.services.list |
apis | serviceusage.services.enable, serviceusage.operations.get |
roles | iam.roles.get, iam.roles.create, iam.roles.update, iam.roles.undelete |
federation | iam.workloadIdentityPools.get, iam.workloadIdentityPools.create, iam.workloadIdentityPools.update, iam.workloadIdentityPools.undelete, iam.workloadIdentityPoolProviders.get, iam.workloadIdentityPoolProviders.create, iam.workloadIdentityPoolProviders.update, iam.workloadIdentityPoolProviders.undelete |
serviceAccounts | iam.serviceAccounts.get, iam.serviceAccounts.create, iam.serviceAccounts.getIamPolicy, iam.serviceAccounts.setIamPolicy |
projectBindings | resourcemanager.projects.getIamPolicy, resourcemanager.projects.setIamPolicy |
folderBindings | resourcemanager.folders.getIamPolicy, resourcemanager.folders.setIamPolicy |
organizationBindings | resourcemanager.organizations.getIamPolicy, resourcemanager.organizations.setIamPolicy |
controller | run.services.get, run.services.getIamPolicy, run.services.setIamPolicy |
tag | resourcemanager.tagValues.get, resourcemanager.tagValues.getIamPolicy, resourcemanager.tagValues.setIamPolicy |
dormeto gcp disconnect
| Step | Permissions |
|---|---|
read | resourcemanager.projects.get, resourcemanager.projects.getIamPolicy, serviceusage.services.list, serviceusage.services.use, run.services.list |
controller | run.services.get, run.services.getIamPolicy, run.services.setIamPolicy |
tag | resourcemanager.tagValues.get, resourcemanager.tagValues.getIamPolicy, resourcemanager.tagValues.setIamPolicy |
projectBindings | resourcemanager.projects.getIamPolicy, resourcemanager.projects.setIamPolicy |
folderBindings | resourcemanager.folders.getIamPolicy, resourcemanager.folders.setIamPolicy |
organizationBindings | resourcemanager.organizations.getIamPolicy, resourcemanager.organizations.setIamPolicy |
roles | iam.roles.get, iam.roles.delete |
serviceAccounts | iam.serviceAccounts.get, iam.serviceAccounts.delete |
federation | iam.workloadIdentityPools.get, iam.workloadIdentityPools.delete, iam.workloadIdentityPoolProviders.get, iam.workloadIdentityPoolProviders.delete |
A custom role for a narrower operator
If roles/owner is too much, create a role of the operator's commands' permissions, all of them here:
title: Dormeto operator
description: Runs dormeto gcp in this project
stage: GA
includedPermissions:
- artifactregistry.dockerimages.get
- artifactregistry.repositories.downloadArtifacts
- artifactregistry.repositories.get
- cloudscheduler.jobs.create
- cloudscheduler.jobs.delete
- cloudscheduler.jobs.get
- cloudscheduler.jobs.update
- cloudtasks.queues.create
- cloudtasks.queues.delete
- cloudtasks.queues.get
- cloudtasks.queues.getIamPolicy
- cloudtasks.queues.setIamPolicy
- cloudtasks.queues.update
- compute.backendServices.get
- compute.backendServices.update
- compute.globalOperations.get
- compute.instanceGroupManagers.createTagBinding
- compute.instanceGroupManagers.deleteTagBinding
- compute.instanceGroupManagers.listTagBindings
- compute.instances.createTagBinding
- compute.instances.deleteTagBinding
- compute.instances.listTagBindings
- compute.regionBackendServices.get
- compute.regionBackendServices.update
- compute.regionNetworkEndpointGroups.create
- compute.regionNetworkEndpointGroups.delete
- compute.regionNetworkEndpointGroups.get
- compute.regionOperations.get
- datastore.databases.create
- datastore.databases.delete
- datastore.databases.get
- datastore.databases.list
- datastore.entities.create
- datastore.entities.get
- datastore.entities.list
- datastore.entities.update
- datastore.operations.get
- iam.roles.create
- iam.roles.delete
- iam.roles.get
- iam.roles.undelete
- iam.roles.update
- iam.serviceAccounts.actAs
- iam.serviceAccounts.create
- iam.serviceAccounts.delete
- iam.serviceAccounts.get
- iam.serviceAccounts.getIamPolicy
- iam.serviceAccounts.setIamPolicy
- iam.workloadIdentityPoolProviders.create
- iam.workloadIdentityPoolProviders.delete
- iam.workloadIdentityPoolProviders.get
- iam.workloadIdentityPoolProviders.undelete
- iam.workloadIdentityPoolProviders.update
- iam.workloadIdentityPools.create
- iam.workloadIdentityPools.delete
- iam.workloadIdentityPools.get
- iam.workloadIdentityPools.undelete
- iam.workloadIdentityPools.update
- logging.views.create
- logging.views.delete
- logging.views.get
- logging.views.update
- resourcemanager.folders.getIamPolicy
- resourcemanager.folders.setIamPolicy
- resourcemanager.organizations.getIamPolicy
- resourcemanager.organizations.setIamPolicy
- resourcemanager.projects.get
- resourcemanager.projects.getIamPolicy
- resourcemanager.projects.setIamPolicy
- resourcemanager.tagKeys.create
- resourcemanager.tagKeys.delete
- resourcemanager.tagKeys.get
- resourcemanager.tagValueBindings.create
- resourcemanager.tagValueBindings.delete
- resourcemanager.tagValues.create
- resourcemanager.tagValues.delete
- resourcemanager.tagValues.get
- resourcemanager.tagValues.getIamPolicy
- resourcemanager.tagValues.setIamPolicy
- run.operations.get
- run.routes.invoke
- run.services.create
- run.services.delete
- run.services.get
- run.services.getIamPolicy
- run.services.list
- run.services.setIamPolicy
- run.services.update
- serviceusage.operations.get
- serviceusage.services.enable
- serviceusage.services.list
- serviceusage.services.use
gcloud iam roles create dormetoOperator --project=my-project --file=operator-role.yaml
gcloud projects add-iam-policy-binding my-project \
--member="user:you@example.com" --role="projects/my-project/roles/dormetoOperator"
- A project's role can't hold
connect's folder and organization permissions. Hold those through an organization's role. - Drop the permissions of the commands you don't give, then check with
dormeto gcp check. resourcemanager.projects.setIamPolicylets its holder grant themselves any role in the project. Give this role for the install, then take it back.- Google lists
cloudtasks.queues.getIamPolicy,cloudtasks.queues.setIamPolicyandserviceusage.operations.getasTESTINGin custom roles. They work.
Your own command role
AWS only
You may create the command role with your own tooling: the manager only checks it can assume it. Each step then needs these:
| Part | What it needs |
|---|---|
| Name | The same name and path in every account, given to the manager (command_role_name). Sessions of one hour or more. |
| Trust | The manager's operations role, by name in its account, one per environment. |
| Permissions | command-role/command-policy.json of dormeto-access-0.24.0.zip, ${account} and ${partition} filled. It reaches the router's namespace and, for private clusters, security groups by tag: dormeto:role = kubernetes-proxy, or aws:eks:cluster-name. |
| Boundary | The managed policy DmtRouterBoundary, at the root path, from router-boundary.json filled the same way. The command role creates roles only with it. |
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Principal": { "AWS": "arn:aws:iam::111122223333:root" },
"Condition": {
"ArnLike": { "aws:PrincipalArn": ["arn:aws:iam::111122223333:role/dmt-prod-manager-operations"] }
}
}]
}
- You may add tags, a description, a condition on
aws:PrincipalOrgID. Or a boundary of yours, allowing every action of the policy. - Keep the boundary's name, the namespace and every statement. A step lacking a permission fails in Operations.
- A service control policy requiring its own boundary must accept
DmtRouterBoundaryunder/dormeto/router/: a role carries one boundary. - Keep
DmtDiscoveryRole's name: the command policy names it for the clusters' access entries.
Another name or path
- Create the role under your name in every account: the access module's
command_role_name, or the script'sCOMMAND_ROLE=platform/DormetoRouters. - Apply the manager with that name.
module "dormeto" { source = "https://releases.dormeto.com/manager/0.24.0/terraform-aws-dormeto-0.24.0.zip//modules/manager" # … your other inputs command_role_name = "platform/DormetoRouters" } module "dormeto_access_shop" { source = "https://releases.dormeto.com/manager/0.24.0/dormeto-access-0.24.0.zip" # … as in Access command_role_name = "platform/DormetoRouters" }
The operations role may then assume arn:aws:iam::*:role/platform/DormetoRouters only. Until both match, Discovery lists the accounts where it can't. Both discovery_role_name and command_role_name are Terraform settings.
With Terraform
- Download the access archive, check it and unzip it beside your code.
curl -O https://releases.dormeto.com/manager/0.24.0/dormeto-access-0.24.0.zip curl -O https://releases.dormeto.com/manager/0.24.0/SHA256SUMS shasum -a 256 -c --ignore-missing SHA256SUMS unzip dormeto-access-0.24.0.zip -d dormeto-access - Write the module
dormeto-roles/main.tf, with the release's policies unchanged.terraform { required_providers { aws = { source = "hashicorp/aws" } } } variable "manager_account_id" { type = string } variable "envs" { type = list(string) } variable "organization_id" { type = string } data "aws_caller_identity" "current" {} data "aws_partition" "current" {} locals { files = "${path.module}/../dormeto-access" # dormeto-access-0.24.0.zip, unzipped vars = { account = data.aws_caller_identity.current.account_id, partition = data.aws_partition.current.partition } manager = "arn:${local.vars.partition}:iam::${var.manager_account_id}" # Each role trusts one role of the manager, by name in its account, one per environment. trust = { for role in ["operations", "discovery"] : role => jsonencode({ Version = "2012-10-17" Statement = [{ Effect = "Allow" Action = "sts:AssumeRole" Principal = { AWS = "${local.manager}:root" } Condition = { ArnLike = { "aws:PrincipalArn" = [for env in var.envs : "${local.manager}:role/dmt-${env}-manager-${role}"] } StringEquals = { "aws:PrincipalOrgID" = var.organization_id } } }] }) } } # Your name and path: give the same to the manager (command_role_name). resource "aws_iam_role" "command" { name = "DormetoRouters" path = "/platform/" max_session_duration = 3600 assume_role_policy = local.trust["operations"] # permissions_boundary = "arn:aws:iam::222233334444:policy/YourBoundary" } resource "aws_iam_role_policy" "command" { name = "command" role = aws_iam_role.command.id policy = templatefile("${local.files}/command-role/command-policy.json", local.vars) } # This name, at the root: the manager gives it to every role it creates for a router. resource "aws_iam_policy" "boundary" { name = "DmtRouterBoundary" description = "Permissions boundary of every role Dormeto creates for a router." policy = templatefile("${local.files}/router-boundary.json", local.vars) } resource "aws_iam_role" "discovery" { name = "DmtDiscoveryRole" max_session_duration = 3600 assume_role_policy = local.trust["discovery"] tags = { "dormeto:component" = "discovery" } # it reads its own role's tags by this one } resource "aws_iam_role_policy" "discovery" { name = "discovery" role = aws_iam_role.discovery.id policy = file("${local.files}/discovery-policy.json") } - Instantiate it once per account, with a provider each, as in Access.
module "dormeto_roles_shop" { source = "./dormeto-roles" providers = { aws = aws.shop } manager_account_id = "111122223333" envs = ["prod"] organization_id = "o-exampleorgid" } - Give the manager's module
command_role_name = "platform/DormetoRouters", and apply.
At a new release, unzip its archive over the previous one, then plan. Its Releases entry says if the roles change.
With a CloudFormation StackSet
With StackSets, the same roles fit one stack, which reaches every new account of an organizational unit. Dormeto never creates a stack itself.
- Build the template from the release's policies with
jq, where you unzipped the archive.MANAGER_ACCOUNT=111122223333 ENVS="prod" ORGANIZATION=o-exampleorgid COMMAND_ROLE=platform/DormetoRouters jq -n --arg manager "$MANAGER_ACCOUNT" --arg envs "$ENVS" --arg org "$ORGANIZATION" --arg command "$COMMAND_ROLE" \ --slurpfile commandPolicy dormeto-access/command-role/command-policy.json \ --slurpfile boundary dormeto-access/router-boundary.json \ --slurpfile discovery dormeto-access/discovery-policy.json ' def name($full): ($full | split("/")) as $p | {RoleName: $p[-1], Path: (if ($p | length) > 1 then "/\($p[:-1] | join("/"))/" else "/" end)}; def trust($role): {Version: "2012-10-17", Statement: [{Effect: "Allow", Action: "sts:AssumeRole", Principal: {AWS: "arn:${partition}:iam::\($manager):root"}, Condition: {ArnLike: {"aws:PrincipalArn": [$envs | splits(" +") | select(. != "") | "arn:${partition}:iam::\($manager):role/dmt-\(.)-manager-\($role)"]}, StringEquals: {"aws:PrincipalOrgID": $org}}}]}; {AWSTemplateFormatVersion: "2010-09-09", Description: "Dormeto organization roles", Resources: { CommandRole: {Type: "AWS::IAM::Role", Properties: (name($command) + {MaxSessionDuration: 3600, AssumeRolePolicyDocument: trust("operations"), Policies: [{PolicyName: "command", PolicyDocument: $commandPolicy[0]}]})}, RouterBoundary: {Type: "AWS::IAM::ManagedPolicy", Properties: {ManagedPolicyName: "DmtRouterBoundary", Description: "Permissions boundary of every role Dormeto creates for a router.", PolicyDocument: $boundary[0]}}, DiscoveryRole: {Type: "AWS::IAM::Role", Properties: {RoleName: "DmtDiscoveryRole", MaxSessionDuration: 3600, AssumeRolePolicyDocument: trust("discovery"), Policies: [{PolicyName: "discovery", PolicyDocument: $discovery[0]}], Tags: [{Key: "dormeto:component", Value: "discovery"}]}}}} | walk(if type == "string" and test("\\$\\{(account|partition)\\}") then {"Fn::Sub": (gsub("\\$\\{account\\}"; "${AWS::AccountId}") | gsub("\\$\\{partition\\}"; "${AWS::Partition}"))} else . end)' > dormeto-roles.json - Create the stack set and its instances, from the management account or a delegated administrator (
--call-as DELEGATED_ADMIN). Trusted access must be on (aws cloudformation activate-organizations-access).aws cloudformation create-stack-set --stack-set-name dormeto-roles \ --template-body file://dormeto-roles.json --capabilities CAPABILITY_NAMED_IAM \ --permission-model SERVICE_MANAGED --auto-deployment Enabled=true,RetainStacksOnAccountRemoval=false aws cloudformation create-stack-instances --stack-set-name dormeto-roles --regions us-east-1 \ --deployment-targets OrganizationalUnitIds=ou-exmp-12345678,Accounts=111122223333,AccountFilterType=DIFFERENCE
- One region: IAM is global; a second region would fail creating the same roles.
- Not the manager's account: its module creates its roles (
AccountFilterType=DIFFERENCE). The management account needs only the delegation policy. - A new account: one of the unit gets the roles, and the next discovery run finds it.
- A new release: build the template again, then
aws cloudformation update-stack-set --stack-set-name dormeto-roles --template-body file://dormeto-roles.json --capabilities CAPABILITY_NAMED_IAM. - Remove: uninstall the routers, then
delete-stack-instanceswith the same targets and--no-retain-stacks, thendelete-stack-set.
What Google adds Google Cloud only
Turning APIs on and creating resources makes Google add its own bindings to the project. Dormeto uses none; the CLI prints and records each, with its step.
| Role | Member | Appeared after | Whose |
|---|---|---|---|
roles/cloudscheduler.serviceAgent | serviceAccount:service-<project number>@gcp-sa-cloudscheduler.iam.gserviceaccount.com | apis | Cloud Scheduler's service agent |
roles/cloudtasks.serviceAgent | serviceAccount:service-<project number>@gcp-sa-cloudtasks.iam.gserviceaccount.com | apis | Cloud Tasks' service agent |
roles/containerregistry.ServiceAgent | serviceAccount:service-<project number>@containerregistry.iam.gserviceaccount.com | apis | Container Registry's service agent |
roles/pubsub.serviceAgent | serviceAccount:service-<project number>@gcp-sa-pubsub.iam.gserviceaccount.com | apis | Pub/Sub's service agent |
roles/run.serviceAgent | serviceAccount:service-<project number>@serverless-robot-prod.iam.gserviceaccount.com | apis | Cloud Run's service agent |
roles/firestore.serviceAgent | serviceAccount:service-<project number>@gcp-sa-firestore.iam.gserviceaccount.com | database | Firestore's service agent |
roles/firebaserules.system | serviceAccount:service-<project number>@firebase-rules.iam.gserviceaccount.com | projectBindings | Firebase Rules' system account, added late, from the database |
roles/artifactregistry.serviceAgent | serviceAccount:service-<project number>@gcp-sa-artifactregistry.iam.gserviceaccount.com | Creating the image's repository, which the CLI doesn't do | Artifact Registry's service agent. The CLI's next run shows it as seen later |
Leave these agents to Google: uninstall leaves them too, listed.
The default service account's Editor
Outside an organization enforcing iam.automaticIamGrantsForDefaultServiceAccounts, turning Compute Engine on gives <project number>-compute@developer.gserviceaccount.com roles/editor on the project. Dormeto does not use it. dormeto gcp check warns of it, and leaves it to you.
- List what runs as that account: VMs, instance templates and services lose what Editor gave them.
gcloud compute instances list --format="table(name,zone.basename(),serviceAccounts[].email)" - Remove the grant.
gcloud projects remove-iam-policy-binding my-project \ --member="serviceAccount:123456789012-compute@developer.gserviceaccount.com" \ --role="roles/editor" - Enforce
iam.automaticIamGrantsForDefaultServiceAccountson the organization or folder, so your next projects don't get it.
With the optional access
Each feature of the optional access turns its API on, and Google adds bindings there too. One from a resource you create appears at the CLI's next run.
| Role | Member | Appeared after | Whose |
|---|---|---|---|
roles/container.serviceAgent | serviceAccount:service-<project number>@container-engine-robot.iam.gserviceaccount.com | gke: turning on container.googleapis.com (apis) | GKE's service agent |
roles/file.serviceAgent | serviceAccount:service-<project number>@cloud-filer.iam.gserviceaccount.com | gke: turning on container.googleapis.com (apis) | Filestore's service agent |
roles/container.defaultNodeServiceAgent | serviceAccount:service-<project number>@gcp-sa-gkenode.iam.gserviceaccount.com | gke: creating a GKE cluster, which the CLI doesn't do | GKE's node service agent. The CLI's next run shows it as seen later |
- With
gke, Google turns on six more APIs:autoscaling.googleapis.com,containerfilesystem.googleapis.com,dns.googleapis.com,file.googleapis.com,gkebackup.googleapis.comandnetworkconnectivity.googleapis.com. - With
cloud-sql, turning onsqladmin.googleapis.comadds no binding and no other API. - Each Cloud SQL instance has a service account of its own,
p<project number>-…@gcp-sa-cloud-sql.iam.gserviceaccount.com, with no binding on the project.
uninstall removes the features' roles and grants, not Google's bindings.