Sooner or later a client asks: what exactly can your tool see in our AWS account, and how do we take that away? This guide covers the pattern AWS recommends for third-party access, the choices that matter, and what to check before anyone clicks Create stack.
Use a role, never access keys
An IAM user’s access keys are long-term credentials: someone has to store them, rotate them and remember to delete them. AWS’s guidance for third parties is to create a role in your account that the third party assumes, so no credentials are ever shared. The tool calls AWS STS AssumeRole and gets temporary credentials that last from 15 minutes up to the role’s maximum session duration, which is one hour unless you raise it, to at most 12 hours.
Write a tight trust policy
A role’s trust policy says who may assume it. For a monitoring tool, it should name the vendor’s AWS account or, better, the one role the vendor uses, and require an External ID:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::111122223333:role/VendorConnector" },
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": { "sts:ExternalId": "the-unique-id-the-vendor-gave-you" }
}
}
]
}Naming one role rather than the whole account narrows who on the vendor’s side can use it. One thing to know: when you save the policy, AWS stores that role by its unique ID, so if the vendor deletes and recreates its role, your trust policy stops working until someone edits it.
Require an External ID, generated by the vendor
The External ID guards against what AWS calls the confused deputy problem. A monitoring vendor serves many customers. If another customer learned or guessed your role’s ARN, they could give it to the vendor as if it were theirs, and the vendor would read your account on their behalf: the vendor is the confused deputy.
The fix: the vendor creates a unique External ID for each customer and always sends it when it assumes that customer’s role, and your trust policy requires it. Another customer can’t change the ID the vendor sends for them, so their request fails. From AWS’s guidance:
- the vendor generates the ID, not the customer, so that it’s unique across the vendor’s customers;
- AWS doesn’t treat the ID as a secret, but it shouldn’t be guessable;
- a careful vendor checks that it can’t assume your role without the right ID before it saves the role.
Grant read access that stops short of your data
“Read-only” covers more than people expect. AWS’s managed ReadOnlyAccess policy can list, get and describe nearly everything, and AWS warns that it “will also have access to read data in storage services like Amazon S3 buckets and Amazon DynamoDB tables”. For a monitoring tool, that’s usually too much. Narrower starting points, from the same page:
- ViewOnlyAccess lets the holder “view a list of AWS resources and basic metadata”, and it “cannot read resource content”. Listing a bucket still shows the names of its objects, though not what’s in them.
- SecurityAudit grants access “to view configuration data for many AWS services and to review their logs”.
Start from one of these and add only the specific read actions the tool needs and can explain, such as ce:GetCostAndUsage for costs or cloudwatch:GetMetricData for metrics. Ask the vendor for the complete list and the reason for each. AWS keeps its managed policies up to date as services change, so a role built on one gains new read actions over time: review it once a year.
Create it with CloudFormation, so it can be reviewed and removed
A CloudFormation template turns the role into something you can read before it exists and delete in one step. CloudFormation asks you to acknowledge a template that creates IAM resources (CAPABILITY_NAMED_IAM when they have custom names), and deleting the stack deletes the role.
For a client that runs AWS Organizations, a StackSet with service-managed permissions puts the same template in every member account, and can deploy automatically to accounts added later. A delegated administrator can manage it too. StackSets don’t deploy to the management account itself, so that account needs its own stack.
Check what the role is doing
Access you can’t see is access you can’t trust. Three places to look:
- IAM’s last activity for the role shows when and in which Region it was last used, over the last 400 days.
- AWS CloudTrail logs each AssumeRole call in the calling account and the account that owns the role, so the client sees every time the vendor comes in.
- IAM Access Analyzer reports resources, roles included, that grant access to principals outside your zone of trust. A vendor’s role should show up there, and you should recognise every role that does.
Remove access cleanly
When the engagement ends, delete the stack, or the role. Requests made with credentials already issued fail too, because AWS evaluates a session’s permissions each time it’s used, though a change can take a few minutes to apply. To cut off existing sessions but keep the role, IAM’s Revoke active sessions attaches a policy that denies sessions issued before that moment. Ask the vendor to delete its record of the role and the External ID as well.
How YugmaLink does it
YugmaLink follows this pattern:
- one CloudFormation stack per account creates a role named
YugmaLink-<connection ID>; - its trust policy names one role in YugmaLink’s AWS account and requires your connection’s External ID, a random 64-character value YugmaLink creates for each account you connect with its own stack (the member accounts of an AWS Organization, connected through one StackSet, share their management account’s);
- its permissions are AWS’s ViewOnlyAccess plus a short list of read actions for costs, metrics, bucket settings, security findings and audit checks: nothing that writes, and nothing that reads your files, database rows, Secrets Manager or Parameter Store values or log events (values that can hold secrets in an AWS answer, such as a function’s environment variables, are dropped as it arrives);
- YugmaLink stores no access keys, and each session it takes lasts 15 minutes;
- deleting the stack removes the role; deleting the connection in YugmaLink deletes its External ID, so YugmaLink can’t use a role left behind. The exception is a member account of an AWS Organization, which shares its management account’s External ID: that stays while the management account is connected, so remove a member’s access by deleting its stack from the StackSet.
The template is public, so you or your client can read every permission before creating the stack. How YugmaLink connects, and what it reads, stores and never does.
AWS documentation used
- Access to AWS accounts owned by third parties
- The confused deputy problem
- AWS JSON policy elements: Principal
- AssumeRole (AWS STS API reference)
- Update the maximum session duration for a role
- AWS managed policies for job functions
- ListObjectsV2 (Amazon S3 API reference)
- CreateStack (CloudFormation API reference)
- StackSets: automatic deployments to an organization
- StackSets: a delegated administrator
- StackSets with service-managed permissions
- RoleLastUsed (IAM API reference)
- Logging IAM and AWS STS API calls with AWS CloudTrail
- What is IAM Access Analyzer?
- Disabling permissions for temporary security credentials
- Revoke IAM role temporary security credentials