Dormeto

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.

Amazon Web ServicesAWS

  • Four roles under /dormeto/router/: dmtr-<env>-<region>-controller, -waker, -scheduler and -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.json in 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 install creates it and grants it these roles, as you. dormeto gcp routers uninstall deletes 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 Amazon Web ServicesAWS only

Naps, wakes and checks the workloads. It starts and stops only what carries dormeto:workload.

ServicePermissions
dynamodbdynamodb:GetItem, dynamodb:UpdateItem, dynamodb:Scan, dynamodb:Query, dynamodb:DeleteItem
ec2ec2:DescribeInstances, ec2:StartInstances, ec2:StopInstances, ec2:ModifyInstanceAttribute, ec2:CreateTags, ec2:DeleteTags
elasticloadbalancingelasticloadbalancing:DescribeRules, elasticloadbalancing:DescribeTargetHealth, elasticloadbalancing:DescribeTargetGroups, elasticloadbalancing:DescribeListeners, elasticloadbalancing:DescribeTags, elasticloadbalancing:ModifyRule
autoscalingautoscaling:DescribeAutoScalingGroups, autoscaling:DescribeScalingActivities, autoscaling:UpdateAutoScalingGroup, autoscaling:SuspendProcesses, autoscaling:ResumeProcesses
ecsecs:DescribeServices, ecs:DescribeTaskDefinition, ecs:UpdateService
application-autoscalingapplication-autoscaling:DescribeScalableTargets, application-autoscaling:RegisterScalableTarget
rdsrds:DescribeDBInstances, rds:DescribeDBClusters, rds:StartDBInstance, rds:StopDBInstance, rds:StartDBCluster, rds:StopDBCluster
cloudwatchcloudwatch:GetMetricData
tagtag:GetResources
cognito-idpcognito-idp:DescribeUserPoolClient
lambdalambda:InvokeFunction, lambda:GetAccountSettings
sqssqs:SendMessage, sqs:ReceiveMessage, sqs:DeleteMessage, sqs:GetQueueAttributes, sqs:ChangeMessageVisibility
eventsevents:PutEvents
s3s3:GetObject
ekseks:DescribeCluster
logslogs:CreateLogStream, logs:PutLogEvents

dmtr-<env>-<region>-waker Amazon Web ServicesAWS only

Answers the requests while a workload sleeps, and asks the controller for the wake.

ServicePermissions
dynamodbdynamodb:GetItem, dynamodb:UpdateItem, dynamodb:Query
lambdalambda:InvokeFunction
eventsevents:PutEvents
s3s3:GetObject
ekseks:DescribeCluster
logslogs:CreateLogStream, logs:PutLogEvents

dmtr-<env>-<region>-scheduler Amazon Web ServicesAWS only

EventBridge Scheduler's, for the idle check every 5 minutes.

ServicePermissions
lambdalambda:InvokeFunction
sqssqs:SendMessage

dmtr-<env>-<region>-onboarder Amazon Web ServicesAWS only

Onboards, offboards and repairs: it changes your rules, adds Dormeto's rules and target groups, and tags the backends.

ServicePermissions
dynamodbdynamodb:GetItem, dynamodb:UpdateItem, dynamodb:Query, dynamodb:Scan, dynamodb:DeleteItem
ec2ec2:DescribeInstances, ec2:CreateTags, ec2:DeleteTags
elasticloadbalancingelasticloadbalancing: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
autoscalingautoscaling:DescribeAutoScalingGroups, autoscaling:CreateOrUpdateTags, autoscaling:DeleteTags
ecsecs:ListClusters, ecs:ListServices, ecs:DescribeServices, ecs:TagResource, ecs:UntagResource
rdsrds:DescribeDBInstances, rds:DescribeDBClusters, rds:AddTagsToResource, rds:RemoveTagsFromResource
cognito-idpcognito-idp:DescribeUserPoolClient
lambdalambda:InvokeFunction, lambda:RemovePermission
sqssqs:ReceiveMessage, sqs:DeleteMessage, sqs:GetQueueAttributes, sqs:ChangeMessageVisibility
ekseks:DescribeCluster
logslogs: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.

ResourcePermissions
compute.urlMapscompute.urlMaps.get, compute.urlMaps.list, compute.urlMaps.update
compute.backendServicescompute.backendServices.get, compute.backendServices.use, compute.backendServices.create, compute.backendServices.delete
compute.regionNetworkEndpointGroupscompute.regionNetworkEndpointGroups.use
compute.globalForwardingRulescompute.globalForwardingRules.list
compute.targetHttpProxiescompute.targetHttpProxies.list
compute.targetHttpsProxiescompute.targetHttpsProxies.list
compute.instancescompute.instances.get
compute.instanceGroupscompute.instanceGroups.get
compute.instanceGroupManagerscompute.instanceGroupManagers.get
compute.autoscalerscompute.autoscalers.get, compute.autoscalers.update
compute.machineTypescompute.machineTypes.get
compute.globalOperationscompute.globalOperations.get
compute.zoneOperationscompute.zoneOperations.get
compute.regionOperationscompute.regionOperations.get
monitoring.timeSeriesmonitoring.timeSeries.list
compute.networkEndpointGroupscompute.networkEndpointGroups.get
compute.regionUrlMapscompute.regionUrlMaps.get, compute.regionUrlMaps.list, compute.regionUrlMaps.update
compute.regionBackendServicescompute.regionBackendServices.get, compute.regionBackendServices.use, compute.regionBackendServices.create, compute.regionBackendServices.delete
compute.regionTargetHttpProxiescompute.regionTargetHttpProxies.list
compute.regionTargetHttpsProxiescompute.regionTargetHttpsProxies.list
compute.forwardingRulescompute.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.

ResourcePermissions
compute.instancescompute.instances.start, compute.instances.stop, compute.instances.suspend, compute.instances.resume, compute.instances.setMachineType
compute.instanceGroupManagerscompute.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:

RolePermissions
roles/datastore.userdatastore.entities.get, datastore.entities.list, datastore.entities.create, datastore.entities.update, datastore.entities.delete
roles/logging.viewAccessorlogging.views.access
roles/cloudtasks.enqueuercloudtasks.tasks.create
roles/run.invokerrun.routes.invoke
roles/iam.serviceAccountUseriam.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>.

RoleMemberWhereConditionWhat it allows
projects/{project}/roles/dormetoRouterThe router's accountThe projectNoneThe role's permissions.
projects/{project}/roles/dormetoRouterBackendsThe router's accountThe projectDormeto-managed resources: resource.matchTag('{project}/dormeto', 'managed')Starts, stops, suspends and resumes what carries the tag; changes a stopped VM's type.
roles/datastore.userThe router's accountThe projectThe router's database: resource.name == "projects/{project}/databases/{database}"The router's Firestore documents.
roles/logging.viewAccessorThe router's accountThe projectThe 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.enqueuerThe router's accountThe queue dmtr-<region>NoneCreates tasks in the router's queue.
roles/run.invokerThe router's accountThe Cloud Run service dmtr-<region>-controllerNoneCalls the controller, as the job and the tasks do.
roles/iam.serviceAccountUserThe router's accountThe service account itselfNoneSigns 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).

RoleMemberWhereConditionWhat it allows
dormetoRouterDatabasesRead, for cloud-sqlprojects/{project}/roles/dormetoRouterDatabasesReadThe router's accountThe projectNonecloudsql.instances.get, cloudsql.instances.list
dormetoRouterDatabases, for cloud-sqlprojects/{project}/roles/dormetoRouterDatabasesThe router's accountThe projectDormeto-managed resources: resource.matchTag('{project}/dormeto', 'managed')cloudsql.instances.update
dormetoRouterKubernetes, for gkeprojects/{project}/roles/dormetoRouterKubernetesThe router's accountThe projectNonecontainer.clusters.get, container.clusters.connect

The discovery role

The manager discovers through a read-only role.

Amazon Web ServicesAWS

  • DmtDiscoveryRole, in every account to discover, assumed at each run by dmt-<env>-manager-discovery.
  • Its policy is discovery-policy.json in 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.

ResourcePermissions
resourcemanager.projectsresourcemanager.projects.get
compute.urlMapscompute.urlMaps.get, compute.urlMaps.list
compute.regionUrlMapscompute.regionUrlMaps.get, compute.regionUrlMaps.list
compute.backendServicescompute.backendServices.get, compute.backendServices.list
compute.regionBackendServicescompute.regionBackendServices.get, compute.regionBackendServices.list
compute.targetHttpProxiescompute.targetHttpProxies.get, compute.targetHttpProxies.list
compute.targetHttpsProxiescompute.targetHttpsProxies.get, compute.targetHttpsProxies.list
compute.regionTargetHttpProxiescompute.regionTargetHttpProxies.get, compute.regionTargetHttpProxies.list
compute.regionTargetHttpsProxiescompute.regionTargetHttpsProxies.get, compute.regionTargetHttpsProxies.list
compute.globalForwardingRulescompute.globalForwardingRules.get, compute.globalForwardingRules.list
compute.forwardingRulescompute.forwardingRules.get, compute.forwardingRules.list
compute.instanceGroupscompute.instanceGroups.get, compute.instanceGroups.list
compute.instanceGroupManagerscompute.instanceGroupManagers.get, compute.instanceGroupManagers.list
compute.instancescompute.instances.get, compute.instances.list
compute.networkEndpointGroupscompute.networkEndpointGroups.get, compute.networkEndpointGroups.list
run.servicesrun.services.get, run.services.list
monitoring.timeSeriesmonitoring.timeSeries.list

Defined in an organization only, for folder and organization scopes:

ResourcePermissions
resourcemanager.foldersresourcemanager.folders.get, resourcemanager.folders.list
resourcemanager.organizationsresourcemanager.organizations.get

The command role

The manager acts on routers through a role in each router's account or project.

Amazon Web ServicesAWS

  • DmtCommandRole by 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 Amazon Web ServicesAWS 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.

ResourcePermissions
compute.instancescompute.instances.listTagBindings, compute.instances.createTagBinding, compute.instances.deleteTagBinding
compute.instanceGroupManagerscompute.instanceGroupManagers.listTagBindings, compute.instanceGroupManagers.createTagBinding, compute.instanceGroupManagers.deleteTagBinding
cloudsql.instancescloudsql.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.com reads at the scopes, and Google's list prices; it writes nothing.
  • dmt-<env>-command@<host>.iam.gserviceaccount.com calls the routers' controllers and binds the tag, in their projects only.
  • The workload identity pool dmt-<env> has the provider aws-<account>, such as aws-121014831971.
  • It maps google.subject=assertion.arn and attribute.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.workloadIdentityUser to principalSet://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.

RoleMemberWhereConditionWhat it allows
dormetoDiscoveryThe discovery accountEach scope: an organization, a folder or a projectNoneReads what the scopes hold. Writes nothing.
roles/run.invokerThe command accountThe router's controller, the Cloud Run service dmtr-<region>-controllerNoneCalls the controller.
roles/resourcemanager.tagUserThe command accountThe tag value <project>/dormeto/managedNoneBinds the tag to a workload's VMs and groups.
dormetoCommandThe command accountThe router's projectNoneLists, 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 needs execute-api:Invoke on them, in the manager's account.
  • It also needs apigateway:GET to 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's api_iam_arn output.
  • 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

StepPermissions
readresourcemanager.projects.get, resourcemanager.projects.getIamPolicy, serviceusage.services.list, serviceusage.services.use

dormeto gcp routers install

StepPermissions
readresourcemanager.projects.get, resourcemanager.projects.getIamPolicy, serviceusage.services.list, serviceusage.services.use
apisserviceusage.services.enable, serviceusage.operations.get
rolesiam.roles.get, iam.roles.create, iam.roles.update, iam.roles.undelete
serviceAccountiam.serviceAccounts.get, iam.serviceAccounts.create, iam.serviceAccounts.getIamPolicy, iam.serviceAccounts.setIamPolicy, iam.serviceAccounts.actAs
projectBindingsresourcemanager.projects.getIamPolicy, resourcemanager.projects.setIamPolicy
tagresourcemanager.tagKeys.create, resourcemanager.tagKeys.get, resourcemanager.tagValues.create, resourcemanager.tagValues.get
databasedatastore.databases.create, datastore.databases.get, datastore.operations.get, datastore.entities.create, datastore.entities.get, datastore.entities.update
queuecloudtasks.queues.create, cloudtasks.queues.get, cloudtasks.queues.update, cloudtasks.queues.getIamPolicy, cloudtasks.queues.setIamPolicy
logViewlogging.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.

StepPermissions
imageartifactregistry.repositories.get, artifactregistry.repositories.downloadArtifacts, artifactregistry.dockerimages.get
cloudRunrun.services.create, run.services.get, run.services.update, run.services.getIamPolicy, run.services.setIamPolicy, run.operations.get, run.routes.invoke, iam.serviceAccounts.actAs
negcompute.regionNetworkEndpointGroups.create, compute.regionNetworkEndpointGroups.get, compute.regionOperations.get
jobcloudscheduler.jobs.create, cloudscheduler.jobs.get, cloudscheduler.jobs.update, iam.serviceAccounts.actAs

dormeto gcp routers uninstall

StepPermissions
readresourcemanager.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
jobcloudscheduler.jobs.get, cloudscheduler.jobs.delete
negcompute.regionNetworkEndpointGroups.get, compute.regionNetworkEndpointGroups.delete, compute.regionOperations.get
cloudRunrun.services.get, run.services.delete, run.operations.get
logViewlogging.views.get, logging.views.delete
queuecloudtasks.queues.get, cloudtasks.queues.delete
databasedatastore.databases.get, datastore.databases.delete, datastore.operations.get
projectBindingsresourcemanager.projects.getIamPolicy, resourcemanager.projects.setIamPolicy
tagresourcemanager.tagKeys.get, resourcemanager.tagKeys.delete, resourcemanager.tagValues.get, resourcemanager.tagValues.delete
serviceAccountiam.serviceAccounts.get, iam.serviceAccounts.delete
rolesiam.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.

StepPermissions
invokerun.routes.invoke

dormeto gcp workloads onboard

StepPermissions
invokerun.routes.invoke
tagresourcemanager.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
requestLogscompute.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

StepPermissions
invokerun.routes.invoke
tagresourcemanager.tagValues.get, resourcemanager.tagValueBindings.delete, compute.instances.listTagBindings, compute.instances.deleteTagBinding, compute.instanceGroupManagers.listTagBindings, compute.instanceGroupManagers.deleteTagBinding
requestLogscompute.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

AccessCommandStepPermissions
cloud-sqlgcp workloads onboardtagcloudsql.instances.get, cloudsql.instances.listTagBindings, cloudsql.instances.createTagBinding, cloudsql.instances.deleteTagBinding, datastore.entities.get
cloud-sqlgcp workloads offboardtagcloudsql.instances.get, cloudsql.instances.listTagBindings, cloudsql.instances.deleteTagBinding
gkegcp workloads onboardclustercontainer.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
gkegcp workloads offboardclustercontainer.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.

StepPermissions
readresourcemanager.projects.get, resourcemanager.projects.getIamPolicy, serviceusage.services.list, serviceusage.services.use, run.services.list
apisserviceusage.services.enable, serviceusage.operations.get
rolesiam.roles.get, iam.roles.create, iam.roles.update, iam.roles.undelete
federationiam.workloadIdentityPools.get, iam.workloadIdentityPools.create, iam.workloadIdentityPools.update, iam.workloadIdentityPools.undelete, iam.workloadIdentityPoolProviders.get, iam.workloadIdentityPoolProviders.create, iam.workloadIdentityPoolProviders.update, iam.workloadIdentityPoolProviders.undelete
serviceAccountsiam.serviceAccounts.get, iam.serviceAccounts.create, iam.serviceAccounts.getIamPolicy, iam.serviceAccounts.setIamPolicy
projectBindingsresourcemanager.projects.getIamPolicy, resourcemanager.projects.setIamPolicy
folderBindingsresourcemanager.folders.getIamPolicy, resourcemanager.folders.setIamPolicy
organizationBindingsresourcemanager.organizations.getIamPolicy, resourcemanager.organizations.setIamPolicy
controllerrun.services.get, run.services.getIamPolicy, run.services.setIamPolicy
tagresourcemanager.tagValues.get, resourcemanager.tagValues.getIamPolicy, resourcemanager.tagValues.setIamPolicy

dormeto gcp disconnect

StepPermissions
readresourcemanager.projects.get, resourcemanager.projects.getIamPolicy, serviceusage.services.list, serviceusage.services.use, run.services.list
controllerrun.services.get, run.services.getIamPolicy, run.services.setIamPolicy
tagresourcemanager.tagValues.get, resourcemanager.tagValues.getIamPolicy, resourcemanager.tagValues.setIamPolicy
projectBindingsresourcemanager.projects.getIamPolicy, resourcemanager.projects.setIamPolicy
folderBindingsresourcemanager.folders.getIamPolicy, resourcemanager.folders.setIamPolicy
organizationBindingsresourcemanager.organizations.getIamPolicy, resourcemanager.organizations.setIamPolicy
rolesiam.roles.get, iam.roles.delete
serviceAccountsiam.serviceAccounts.get, iam.serviceAccounts.delete
federationiam.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.setIamPolicy lets 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.setIamPolicy and serviceusage.operations.get as TESTING in custom roles. They work.

Your own command role Amazon Web ServicesAWS only

You may create the command role with your own tooling: the manager only checks it can assume it. Each step then needs these:

PartWhat it needs
NameThe same name and path in every account, given to the manager (command_role_name). Sessions of one hour or more.
TrustThe manager's operations role, by name in its account, one per environment.
Permissionscommand-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.
BoundaryThe 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 DmtRouterBoundary under /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

  1. Create the role under your name in every account: the access module's command_role_name, or the script's COMMAND_ROLE=platform/DormetoRouters.
  2. 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

  1. 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
  2. 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")
    }
  3. 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"
    }
  4. 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.

  1. 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
  2. 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-instances with the same targets and --no-retain-stacks, then delete-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.

RoleMemberAppeared afterWhose
roles/cloudscheduler.serviceAgentserviceAccount:service-<project number>@gcp-sa-cloudscheduler.iam.gserviceaccount.comapisCloud Scheduler's service agent
roles/cloudtasks.serviceAgentserviceAccount:service-<project number>@gcp-sa-cloudtasks.iam.gserviceaccount.comapisCloud Tasks' service agent
roles/containerregistry.ServiceAgentserviceAccount:service-<project number>@containerregistry.iam.gserviceaccount.comapisContainer Registry's service agent
roles/pubsub.serviceAgentserviceAccount:service-<project number>@gcp-sa-pubsub.iam.gserviceaccount.comapisPub/Sub's service agent
roles/run.serviceAgentserviceAccount:service-<project number>@serverless-robot-prod.iam.gserviceaccount.comapisCloud Run's service agent
roles/firestore.serviceAgentserviceAccount:service-<project number>@gcp-sa-firestore.iam.gserviceaccount.comdatabaseFirestore's service agent
roles/firebaserules.systemserviceAccount:service-<project number>@firebase-rules.iam.gserviceaccount.comprojectBindingsFirebase Rules' system account, added late, from the database
roles/artifactregistry.serviceAgentserviceAccount:service-<project number>@gcp-sa-artifactregistry.iam.gserviceaccount.comCreating the image's repository, which the CLI doesn't doArtifact 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.

  1. 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)"
  2. Remove the grant.
    gcloud projects remove-iam-policy-binding my-project \
      --member="serviceAccount:123456789012-compute@developer.gserviceaccount.com" \
      --role="roles/editor"
  3. Enforce iam.automaticIamGrantsForDefaultServiceAccounts on 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.

RoleMemberAppeared afterWhose
roles/container.serviceAgentserviceAccount:service-<project number>@container-engine-robot.iam.gserviceaccount.comgke: turning on container.googleapis.com (apis)GKE's service agent
roles/file.serviceAgentserviceAccount:service-<project number>@cloud-filer.iam.gserviceaccount.comgke: turning on container.googleapis.com (apis)Filestore's service agent
roles/container.defaultNodeServiceAgentserviceAccount:service-<project number>@gcp-sa-gkenode.iam.gserviceaccount.comgke: creating a GKE cluster, which the CLI doesn't doGKE'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.com and networkconnectivity.googleapis.com.
  • With cloud-sql, turning on sqladmin.googleapis.com adds 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.