Skip to content

Cloud & infrastructure

Connect an AWS account read-only via CloudFormation or Terraform, with optional just-in-time write elevation.

AWS connects by creating an IAM role Dave assumes, with either a CloudFormation stack or a Terraform command. No access keys are stored.

  1. In the AWS Console, open the account menu (top right) and copy your 12-digit Account ID. It is also in any role ARN. You need the rights listed below.

  2. In Dave, go to Integrations → Add integration → AWS.

  3. Paste the AWS Account ID and pick the Primary region — the region you work in, and the one your organization allows stacks in.

  4. Set a Label — see labels.

  5. Leave Enable agentic JIT (advanced) off unless you want write elevation.

  6. Under How do you want to create the roles?, choose one:

    • Managed (AWS CloudFormation) — choose Open AWS console for a prefilled stack, check the console’s account and region match the ones you entered, then deploy it.
    • Self-managed (Terraform) — you need Terraform 1.3 or later, and AWS credentials for the account that can create IAM roles. Choose Connect AWS Account, copy the command and paste it into a terminal. The command writes a main.tf that uses Dave’s Terraform module into a DaveAgent-xxxxxxxx folder and runs terraform apply, which shows the plan and waits for you to confirm. It refuses to run against any other account, and it pins the module by its checksum, so Terraform refuses any copy that differs. terraform init downloads the module from Dave’s release bucket (dave-byoc-prod-templates.s3.amazonaws.com) and the AWS provider from registry.terraform.io, so the machine you run it on must reach both.
  7. Dave finishes connecting once the role exists — keep the Dave tab open. If the account already has the integration roles, either way connects at once, with no setup step.

With Dave BYOC, your tenant service assumes the roles, not Dave, so:

  • Install Dave BYOC and wait for its tenant service to connect before you connect AWS. Dave fills the tenant service’s role into both the stack and the Terraform command, and the roles trust only that role.
  • The AWS account can be the one Dave BYOC runs in or any other account you run.

Connect many accounts with your own Terraform

Section titled “Connect many accounts with your own Terraform”

To manage the roles of many accounts in one place, apply Dave’s module once in every account with your own Terraform or Terragrunt, using that account as the provider. Then connecting an account in Dave takes no setup step:

  1. In Add integration → AWS, choose Self-managed, and copy the block under Apply it once in every account. It uses the integration role names (DaveAgent-integration-role) and your tenant’s own external ID, the same for every account. Tick Enable agentic JIT first if you want it: the block then sets enable_elevated_role = true.
  2. Add that block to your Terraform for each account, and apply.
  3. Connect each account in Dave with Self-managed: Dave finds its roles as soon as you enter the account ID, and the connection completes in a few seconds. An account you already started to connect with Self-managed completes too, on Check connection.

With Dave BYOC, the block trusts your tenant service instead of Dave, so install Dave BYOC and wait for its tenant service to connect before you copy it. Everything else is the same.

To remove an account, destroy its roles in your Terraform, then disconnect it here.

Terragrunt or an existing Terraform repository

Section titled “Terragrunt or an existing Terraform repository”

To manage the roles with the rest of your infrastructure, use the module from the Terraform command in your own code instead of running the command. Copy the module "dave" block into your Terraform, or, with Terragrunt, use its source and inputs in a unit:

include "root" {
path = find_in_parent_folders("root.hcl")
}
terraform {
source = "<source from the Terraform command>"
}
inputs = {
stack_name = "DaveAgent-xxxxxxxx"
external_id = "<external_id from the Terraform command>"
enable_elevated_role = false
# The one the Terraform command has: trusted_account_id, or, if you run Dave in your
# own cloud (BYOC), trusted_principal_arn.
trusted_account_id = "<trusted_account_id from the Terraform command>"
}

Keep the source exactly as the command shows it, including its ?checksum=sha256:… part, and the trust input it has: with Dave BYOC, trusted_principal_arn makes the roles trust your tenant service instead of Dave’s account. Your own provider configuration and remote state apply. The module ships in a Dave BYOC release (dave-byoc-<version>.zip, folder modules/dave-byoc/modules/aws-integration-role): a published release never changes, so your roles only change when you move to a newer one. The module outputs role_arn and elevated_role_arn, and takes the optional inputs in Narrow what Dave can do.

The stack (or Terraform folder) is named DaveAgent- followed by eight characters of the connection ID, and the stack is created in the primary region you picked. Both create the same roles: one, plus a second only if you enable agentic JIT. IAM roles are global, so Dave can read every region in the account; the primary region is just where commands run by default.

Role name: DaveAgent-xxxxxxxx-role. Attached AWS managed policy:

arn:aws:iam::aws:policy/ReadOnlyAccess

Inline policy DaveSelfInspection, so Dave can check what its own role is allowed to do:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["iam:SimulatePrincipalPolicy"],
"Resource": "*"
}
]
}

Both roles trust only Dave’s AWS account, and only with the external ID unique to this connection, which protects against the confused-deputy problem:

{
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::<Dave account ID>:root" },
"Action": "sts:AssumeRole",
"Condition": { "StringEquals": { "sts:ExternalId": "<external ID>" } }
}

If you run Dave in your own cloud, both roles instead trust only your Dave tenant service’s IAM role, still with the external ID, and also let that role tag its session (sts:TagSession), which its EKS Pod Identity session needs. Dave’s own account is not trusted at all. Both roles carry the tag dave.io/integration = true, because the tenant service may assume only roles with that tag.

Created only when Enable agentic JIT (advanced) is on. Role name: DaveAgent-xxxxxxxx-elevated-role, maximum session duration one hour. Attached AWS managed policy:

arn:aws:iam::aws:policy/PowerUserAccess

PowerUserAccess is the ceiling, not what Dave gets. Dave assumes this role only after a human approves a specific action, with an inline session policy limited to that action, for 15 minutes. You can replace the managed policy on the role with a narrower one (with Terraform, through elevated_role_policy_arns); the session policy always narrows it further.

Whoever deploys the stack needs rights to create CloudFormation stacks and IAM roles in the account. With Terraform, rights to create IAM roles are enough.

The stack or module creates only the roles above, in your account, and nothing else. Dave stores no AWS access keys: it assumes a role for short-lived credentials when it needs them. If you run Dave in your own cloud, your tenant service assumes the roles and Dave never receives credentials for them.

The defaults match the CloudFormation stack. With Terraform you can narrow them without changing the module:

Input Default What it does
enable_elevated_role false Leave it off and Dave cannot write to the account at all.
read_role_policy_arns ReadOnlyAccess Managed policies on the read role. ReadOnlyAccess reads data, such as S3 objects, as well as configuration; ViewOnlyAccess, for example, lists and describes resources without reading their data. Attach only read-only policies.
elevated_role_policy_arns PowerUserAccess Managed policies on the write role: the ceiling for any approved command.
permissions_boundary_arn none A permissions boundary on both roles: the most Dave can ever do here, whatever their policies. It must allow iam:SimulatePrincipalPolicy, which Dave uses to check its own role.

The module checks its inputs before it plans: account IDs, role and policy ARNs, and the external ID must have the right form.

The Terraform command pins the module by its SHA-256, and Terraform checks it on download. To review the code before you run it, or to keep a copy in your own repository, download the zip from the command’s source (the part before //), check it with shasum -a 256 dave-byoc-<version>.zip against the checksum in that source, and reference its modules/dave-byoc/modules/aws-integration-role folder by path. Terraform state holds the role ARNs and the trust policy with its external ID; it holds no credentials.

Everything Dave can do lives in the stack or the Terraform folder. To review or remove a stack, open CloudFormation → Stacks in the stack’s region and find DaveAgent-xxxxxxxx; its Resources tab lists the roles. Either way, you can also find them under IAM → Roles by searching DaveAgent-.

Disconnect in Dave stops Dave using the role immediately, but does not delete anything in AWS — Dave cannot delete its own role. While the connection is disconnecting, it shows what to remove for the way you set it up:

  • Managed: Open the provider console takes you to the stack; delete it there.
  • Self-managed: run the command shown (terraform destroy in the DaveAgent-xxxxxxxx folder); if that folder is gone, delete the DaveAgent-xxxxxxxx-* roles in IAM.
  • Integration roles: remove the module "dave" block for that account from your Terraform and apply it.

The connection stays Disconnecting until the role is gone, then Dave confirms it is fully disconnected.

Cancelling an unfinished setup works the same way: if the stack or Terraform already deployed, remove it.

Enable agentic JIT (advanced) creates a separate write-capable role. Every elevated action still requires explicit human approval, and leaving the option off keeps the account genuinely read-only — the elevated role is never created. See Elevated role for what it can do.

  • The console does not open — allow popups for Dave, or use Open the provider console on the connection.
  • Stack creation takes long — check the stack in the AWS Console reached CREATE_COMPLETE.
  • AWS rejects the connection — confirm the stack or Terraform deployed in the account you entered, then choose Connect again. If the role still cannot be assumed, Dave offers the same setup step again; it is safe to rerun.
  • Your cloud is unreachable, or Your cloud has not reported its Dave tenant service yet — with Dave BYOC, Dave cannot reach your tenant service, or it has not finished connecting. Check its status in Settings → Bring your own cloud, then connect again.
  • Terraform stops with an account error — your credentials point at a different account than the one you entered. Switch credentials and rerun.