When an external tool needs to get into your AWS account there are two routes. The familiar one: create an IAM user and give it an access key, which is a password that never expires and can end up in a configuration file, a repository or an email. The good one: create a role that the tool assumes from its own AWS account. There is no key to store or leak; AWS hands out temporary credentials that expire on their own, and you can cut off access in a second by deleting the role.
For this the tool has to support it (it will ask you for "role-based access", a "cross-account role" or the "role ARN") and give you two pieces of information: its AWS account number and an external ID. With those, it is done in ten minutes.
Before you start: what each thing means
- IAM
- The AWS service that manages who can do what in your account.
- AWS account
- Every Amazon customer has an account with a twelve-digit number. The external tool has its own; you have yours.
- Access key
- The "username and password" for programs. It never expires, which is why this guide avoids it.
- Role
- A set of permissions that belongs to nobody in particular: whoever is authorised "assumes" it and receives temporary credentials that expire on their own.
- Assume a role
- Ask AWS for those temporary credentials in order to act with the role's permissions for a while.
- Trusted entity
- Who is allowed to assume the role. Here, the external tool's AWS account.
- External ID
- An additional password that goes with the request to assume the role, so that only that tool, acting for you, can use it.
- Policy
- The list of permissions, in JSON format. The guide gives you an example.
- ARN
- The full, unique name of the role (arn:aws:iam::...). It is what you give the tool.
- CloudTrail
- The log of everything that happens in your AWS account: who did what and when. Useful to see what the tool does.
Step by step
Gather the provider's details
Note down the tool's account ID (twelve digits) and the external ID it assigns you, a string that is unique to you. The external ID prevents the so-called "confused deputy problem": another customer of the same tool being able to make it use your role. Do not share it or reuse it.
Create the minimal-permissions policy
In the IAM console, Policies, Create policy, JSON tab. Paste only the actions the tool needs; a serious provider gives you the exact list. For example, to view and manage Lightsail machines:
{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": [ "lightsail:GetInstances", "lightsail:GetInstance", "lightsail:GetInstanceState", "lightsail:StartInstance", "lightsail:StopInstance", "lightsail:RebootInstance", "lightsail:GetInstanceSnapshots", "lightsail:CreateInstanceSnapshot" ], "Resource": "*" }] }Give it a recognisable name, such as
PanelExterno-Maquinas. If they ask you forAdministratorAccess, ask why.Create the role with the other account as the trusted entity
IAM, Roles, Create role. Trusted entity type: AWS account, option Another AWS account, and type the provider's account ID. Tick Require external ID and paste the external ID. Do not tick "Require MFA": the tool is a program, not a person. Next.
Attach the policy and name the role
Search for the policy you created in step 2, tick it and continue. Role name: something that says what it is for and whose it is, for example
PanelExterno-Simplio. Review the summary: the trust policy must show the provider's account and thests:ExternalIdcondition. Create the role.Hand over the role ARN
Open the newly created role and copy its ARN, of the form
arn:aws:iam::123456789012:role/PanelExterno-Simplio. It is the only thing the tool needs; paste it wherever it asks for it. It is not a secret in itself (without the external ID and without being in the trusted account it is of no use), but there is no need to publish it either.Check access and the log
The tool should connect straight away. To see what it does, in CloudTrail, event history, filter by the role name: every action it runs appears with the role as the identity. If one day you want to cut off access, delete the role or change the external ID; the effect is immediate as soon as the temporary credentials in use expire, which last at most one hour unless you have extended it.
What can go wrong
The tool says "not authorized to perform sts:AssumeRole"
Either the trusted account ID is not right, or the external ID does not match, or the tool is trying to assume the role with a different principal from the one you authorised. Check the role's Trust relationships tab and compare it letter by letter with what the provider gave you.
It connects but lacks permission for something
The AWS message says exactly which action is missing. Add it to the policy from step 2; the change applies to the next calls without touching the role.
What if the tool does not support roles?
Then an IAM user with minimal permissions and an access key is plan B (you have the guide in this section). Rotate the key from time to time and keep an eye on its "last used" in IAM.
I created the role in the wrong account
With several accounts it happens. The role must be in the account whose resources you want the tool to see. Delete it and create it in the right one; the ARN will change, so update it in the tool.
In Simplio
Simplio supports connecting by role: in the help it shows you Simplio's account ID and an external ID generated for you, and it generates the trust policy and the permissions policy as you tick boxes for what you want to allow. You paste the role ARN and that is it: there is no key to store, and the credentials Simplio asks AWS for expire in one hour.
The same task, in AWS and in Simplio
| In the AWS console | In Simplio | |
|---|---|---|
| Create the role | Policy, role, trusted entity, external ID, ARN: 6 steps, 15 minutes if you know what you are doing | The help gives you the account, the external ID and both policies already written: paste and copy the ARN, 3 minutes |
| Just the right permissions | Know the name of each action | Tick boxes: view only, no firewall, no terminal, one region |
| Revoke | Delete the role in IAM | Delete the connection in Simplio or the role in IAM; no keys to chase |