After responding to a compromise that began with one leaked administrator key, we rebuilt how we set up AWS for ourselves and for clients. This is that baseline. It suits a company with one to twenty engineers and no dedicated security staff. It takes about a day and costs very little to run.
1. Split into accounts under an organisation
One account for everything means one blast radius. Use AWS Organizations with at least:
- a management account that holds billing and sign-in settings and runs no applications
- a production account
- a staging account
Group the workload accounts in organisational units so policies can be attached to all of them at once.
2. Sign in through single sign-on
Set up IAM Identity Center. Each person gets one identity and is granted a permission set per account. The credentials they receive expire, in our setup after eight hours.
A new engineer can be given administrator rights in staging and read-only in production with two clicks. When someone leaves, removing one identity removes everything.
3. Delete the access keys
Long-lived access keys are the thing that leaks. With single sign-on in place they are no longer needed for people: the command line can use the same sign-in.
Find every existing key. For each one, establish what uses it, move that use to a role, then delete the key. Backend services running on AWS should use the role attached to the service, not a key in an environment file.
This step takes the longest, because it means finding out what your keys are actually for. That discovery is the most valuable part of the day.
4. Attach guardrails that administrators cannot bypass
Service control policies apply to every identity in an account, including administrators and including an attacker holding an administrator’s credentials. Ours do four things.
Keep the account in the organisation and the audit log running. Deny leaving the organisation. Deny stopping, deleting or altering CloudTrail.
Restrict regions. Deny activity outside the regions the business uses. Global services such as IAM, CloudFront and Route 53 need to be exempted or they stop working.
Deny Amazon Bedrock where it is not used. Stolen credentials are routinely used to run AI models at the victim’s expense. Do not assume the region policy covers this. In one organisation, the AWS-generated region policy exempted Bedrock.
Deny AWS Marketplace. It closes another route to unexpected charges.
Two cautions. Service control policies do not apply to the management account, so add an equivalent deny directly to the administrator permission set. And after attaching each policy, test both ways: confirm your applications still respond, and confirm the denied actions really are denied.
5. One audit trail, stored out of reach
Create an organisation trail in CloudTrail covering all accounts and all regions, with log file validation enabled. Write it to a bucket in the management account that workload accounts cannot modify.
Set a lifecycle rule so old logs move to cheaper storage and are eventually deleted. We keep ours a little over a year.
If something does happen, this is the difference between knowing what the attacker did and guessing.
6. Budgets and anomaly alerts that reach a person
Create a monthly budget per account, with alerts at 80% and 100% of actual spend and at 100% of forecast. Add cost anomaly detection per account with a low threshold and a daily email.
Be clear about what these do. Budgets alert. They do not stop spending. The hard stops are the guardrails in step 4. The alerts shorten the time to notice.
Send them to an address someone reads at the weekend.
7. Make the database private
A production database should not have a public address. The question is how engineers reach it when they need to.
We use an EC2 Instance Connect Endpoint and a small bridge instance. A script checks the engineer’s single sign-on session, pushes a freshly generated key that the instance accepts for sixty seconds, opens a tunnel, and deletes the key afterwards. The bridge is stopped when nobody is using it.
There is no stored SSH key and nothing exposed to the internet. Access is tied to the same identity as everything else, and it appears in the audit trail.
Also: write down the break-glass path
Single sign-on can break. Decide now how you would get into production if it did, test it once, and document it. Ours is a role in the production account that trusts the management account. Keep root user credentials for emergencies only, with multi-factor authentication.
What this buys you
Run the scenario. An engineer’s laptop is compromised and their cloud credentials are taken.
- The credentials expire within hours.
- They cannot be used outside your regions.
- They cannot start Bedrock or buy from Marketplace.
- They cannot switch off the log that records what they did.
- A spend spike emails a person the next morning.
That is an inconvenience. Compare it with what one leaked administrator key did to a client who had none of this.
A note on who should own the account
The AWS account should belong to your company, not to your developer or agency. Every system we build runs in an account the client owns. If your supplier holds the root credentials to your production environment, fix that first.