A Datadog AWS IAM role is the identity the monitoring integration assumes, with an external ID in the trust policy, so the AWS access key stored in the Datadog account can be deleted. The buyer pain is that key. It was created so a product could read CloudWatch, and it is still active. It shows up on the credential report. It has no expiry that anyone owns. The person who pasted it into the integration page has often left the company. The auditor asks who can use it. The honest answer, before this cutover, is anyone who can open that integration screen, plus anyone who copied the key into a note.
Rutagon replaces that key with a role delegation. Datadog's manual setup generates an external ID in the Datadog account and shows the AWS account ID for the Datadog site you are on. We put both values into the role trust. We attach the permissions the integration actually needs. After the integration validates, we delete the stored key. The role is the ongoing path. The key is the thing that has to be gone.
What the Datadog AWS IAM role trust allows
Each AWS account in scope gets its own role. The role name we create is the role name we type into Datadog. A trailing space, or a name that matches a CloudFormation default from an older stack, is the usual reason AssumeRole fails while the policy looks right. We store the role ARN, the Datadog site, and the external ID fingerprint beside the account id. The external ID itself stays in the trust policy and in Datadog. Our ledger stores a hash and the time we copied it, so a later edit is visible.
The principal is the Datadog account ID shown on that site's setup page. Commercial sites and other Datadog sites publish different account IDs. We copy the ID from the page for the site the client actually uses. We do not reuse an ID from a blog or from a different site. The condition is sts:ExternalId, StringEquals, set to the external ID Datadog issued for this AWS account. Datadog keeps that value stable for a window unless someone regenerates it or adds another account during the window. We finish the trust and the Datadog form in the same sitting, then we read the trust back and compare.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::DATADOG_ACCOUNT_ID:root"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "EXTERNAL_ID_FROM_THIS_DATADOG_ACCOUNT"
}
}
}
]
} The external ID is what makes a confused-deputy assumption fail. Without it, any customer of that Datadog site who learned the role name could ask Datadog to assume it. With it, the assume must present the value bound to this integration. AWS documents that pattern for third-party access. We treat a trust that allows the Datadog principal with no external ID as an open finding, even when the integration happens to work.
Permissions are the second half of the role. The AWS managed policy SecurityAudit covers the read-only inventory the integration expects for resource collection. Features the client turned on, such as a specific log read, get an additional policy taken from the permission list on the integration page for those features. AdministratorAccess is not that list. A role that can change the account is a second standing credential, wider than the key it replaced. We record the policy ARNs attached to the role. A later click of a "repair permissions" action in the product UI can attach more policies. The next morning's read diffs the attachment list and reopens the row when the set changed without a matching change in our table.
Proving the stored key is gone
Role delegation can succeed while the old key is still saved on the integration. The product will keep using a key if one is present. The cutover check is two-sided. On the Datadog side, the account's access type is role delegation, the role name matches, and the access key fields are empty. On the AWS side, the IAM user that held the key has no active access keys. Eliminating IAM user access keys is the same end state we require here. A key left "just in case" is the credential the next audit still finds.
We disable the key first, wait through one collection interval, and confirm the integration still reports the account healthy through the role. Then we delete the key. CloudTrail should show AssumeRole from the Datadog principal, with the external ID condition satisfied, and it should stop showing calls authenticated by the old access key id. If AssumeRole fails, we stop. The key stays disabled, not deleted, until the trust is fixed. Deleting the only working credential before the role validates is how a monitoring gap gets blamed on the migration.
account_id: 4812
datadog_site: client-site
role_name: monitoring-reader
auth_mode: role
access_key_fields_empty: true
iam_user_active_keys: 0
assume_role_seen: true A service control policy that denies sts:AssumeRole to principals outside the organization will block this role. The Datadog principal lives in Datadog's account, so an SCP written as "deny assume from outside our org" denies the integration. We read that deny before cutover. The exception is specific: this role, this principal, this external ID. A blanket allow for the foreign account is wider than the integration needs.
Non-human identity inventory is where this key shows up before the cutover and where it must be absent after. The inventory row for the IAM user moves to removed, with the delete time and the role ARN that replaced it. A new key created on that user the next week reopens the row. The integration role is the allowed non-human path for this product. A fresh access key is drift.
What we leave attached, and what we review
The role is standing in a narrow sense: Datadog can assume it whenever collection runs. The session is short-lived. The trust is pinned. That is a different object from a key that can be copied out of the UI and used from anywhere. We still review the role. The reviewer sees the account, the role ARN, the policy ARNs, the external ID fingerprint, and the last successful assume time. A role that has not been assumed inside the collection window is a broken integration or an account that should be removed from Datadog. Both are findings. A quiet role is not proof that the key is gone. The key check is the empty field and the IAM user.
Multi-account organizations repeat the same shape. One Datadog account, many AWS accounts, one role each, each trust using the external ID Datadog shows for that account. We do not assume one external ID covers every account unless the setup page shows the same value. The ledger is one row per AWS account. A missing row is an account that still has a key, or an account the product is reading with a role we did not build.
Security automation runs the inventory, the trust deploy, the validation, and the key delete. The GRC platform records the closed credential item. This ledger is the proof underneath it: role name, empty key fields, no active IAM keys, and an assume in CloudTrail.
Rutagon delivers the role, the external ID condition, the permission boundary of SecurityAudit plus the feature policies actually in use, and the deletion of the stored key. The Datadog account remains the place collection is configured. Our store is the proof that collection no longer depends on a long-lived AWS key.
Frequently Asked Questions
Why does AssumeRole fail when the role policy looks correct?
The failure is usually the trust, not the permissions policy. The role name, the principal account ID for that Datadog site, and the external ID all have to match the integration. A permissions policy never gets evaluated if the assume itself is denied.
Can one IAM user key stay as a backup after the role works?
The cutover treats a remaining key as an open item. We disable it, confirm one collection interval succeeds through the role, then delete it. A backup key is another copy of the credential this migration exists to remove. Rollback, if the role fails, is re-enabling that key before deletion, not keeping both paths forever.
What policy belongs on the role?
SecurityAudit is the managed policy we attach for resource collection. Extra actions come from the permission list for the integration features the client enabled. The attached policy ARNs are part of the evidence row. A later change in the product UI that adds policies shows up as drift on the next read.
Does this cover every AWS account in the organization?
Each account that Datadog collects from gets its own role and its own ledger row. An account with no row is either unmonitored or still on a key. The external ID is copied from the setup page for that account. A service control policy that blocks foreign assume has to allow this principal and this role, or the integration cannot read the account.
Ask for a credential diagnostic that finds AWS keys stored in the Datadog integration and replaces them with a role. Contact Rutagon at https://rutagon.com/contact, 907-841-8407, or contact@rutagon.com.