Locked-Down AWS and GCP Starter Environments for a Few Dollars a Month

awsgcpsecurityopentofucost

Most personal cloud accounts look the same: one account, root user with an access key from 2019, everything in it, and the first security alert you ever get is the bill.

Enterprises solve this with landing zones, Control Tower, Security Hub, a SIEM, and a team. I wanted the same shape for my own projects without the price tag. The target:

  • Locked down by default. No long-lived keys, no root use, no surprise regions or services.
  • Alerts on the things that matter. If someone (including me) does something risky, I get an email.
  • A few dollars a month. Free tier where possible, and every paid line justified.
  • All of it in code. OpenTofu, small stacks, plan on pull requests, apply from main.

Here’s what I built for AWS and Google Cloud, what it costs, and the gotchas that bit me along the way.

The principles

Same rules on both clouds:

  1. Nobody uses the all-powerful identity day to day. AWS root and the Google break-glass admin get a hardware key and a drawer.
  2. No long-lived credentials. People sign in through SSO. CI signs in through OIDC. No IAM users, no service account key files.
  3. Workloads live somewhere separate. The account or project that holds the guardrails doesn’t run apps.
  4. Deny what you don’t use. Regions, services, key creation. If I need it later, I open it on purpose.
  5. Alert on changes to the guardrails themselves. A disabled trail at 2 a.m. should wake someone up.

AWS: the organization

Lock down root first (by hand, about 10 minutes)

This part can’t be done in code. Sign in as root once:

  1. Add MFA (a passkey or hardware key).
  2. Delete any root access keys.
  3. Set the billing, operations, and security alternate contacts.
  4. In Identity Center, require MFA on every sign-in.
  5. Sign out of root. From here on it’s Identity Center only.

One management account, separate workload accounts

The management account runs the Organization, SSO, the state bucket, and security tooling. Nothing else. Apps live in workload-dev and workload-prod under a workloads OU.

The reason is simple: Service Control Policies never apply to the management account. If workloads ran there, none of the guardrails below would touch them.

SCPs: the guardrails

On the workloads OU:

  • No leaving the Organization
  • No root user
  • No IAM users or access keys
  • Security tooling can’t be turned off or modified
  • One region only (us-east-1)
  • A service allow-list. Only the services the workloads use. EC2 is limited to Describe/Get, so nobody can launch an instance in an account that has no reason to run one.

I built the allow-list from the app’s infrastructure code, then checked it against IAM last-accessed data for every role in both accounts before applying it. Deny-by-default SCPs are great until they break production, so check first.

People get SSO, CI gets OIDC

  • Identity Center for humans. Admin access only through an Admins group. Locally it’s aws sso login and short-lived credentials.
  • GitHub Actions OIDC for CI. Each role trusts one repo and one branch. Pull requests get a read-only plan role. Only runs on main can assume the apply role, so branch protection on main is part of the security model, not a nice-to-have.

The security baseline

  • An org-wide CloudTrail for management events (the first trail is free)
  • GuardDuty across the Organization
  • IAM Access Analyzer for anything shared outside the org (free)
  • EventBridge rules to SNS email for: root use, console logins without MFA, IAM user or key creation, trust policy changes, OIDC provider changes, Organization and Identity Center changes, anyone touching CloudTrail, GuardDuty, or Access Analyzer, GuardDuty findings of medium or higher, and new Access Analyzer findings

One thing that isn’t obvious: root sign-ins, IAM, and Organizations events only reach EventBridge in us-east-1, whatever your home region is. If your home region is elsewhere, you need the alert rules in both.

And test the alerts. Creating and deleting a throwaway IAM user should send an email within a few minutes. GuardDuty can generate sample findings. An alert path you’ve never seen fire is a hope, not a control.

Cost guardrails

  • An org-wide monthly budget with email alerts
  • Daily cost anomaly emails

These are the cheapest controls in the whole setup and the ones most likely to save you real money.

Google Cloud: the project

The GCP side is smaller because it only hosts what one app needs (APIs, Firebase, push notifications), but it follows the same rules.

Get an Organization (it’s free)

A project owned by a Gmail account has no Organization, which means no org policies. With a domain you own, Cloud Identity Free gives you an Organization for $0, and Google applies a set of secure defaults when you create one:

  • IAM grants only to identities in your domain (a Gmail account can’t be granted anything)
  • No new or uploaded service account keys
  • Uniform bucket-level access
  • Security contacts only on your domain

I imported those into code and added one of my own: resources in US locations only. Same idea as the single-region SCP on AWS.

Keyless CI with Workload Identity Federation

GitHub Actions signs in to Google with Workload Identity Federation, the GCP version of OIDC roles. Separate plan and apply service accounts, and apply is bound to the repository and main.

The security baseline

  • Restricted API keys. The Android key only works for my app, signed with my certificates, calling the two APIs push notifications need. Firebase also created an unrestricted browser key nothing used. I deleted it.
  • Data Access audit logs for IAM and token exchange
  • Log-based email alerts on new service account keys, project IAM changes, and API key changes
  • A $5 monthly budget that emails at 50%, 90%, and 100%

State lives in AWS

The GCP stacks keep their state in the AWS state bucket under a gcp/ prefix, reached by an AWS role scoped to that prefix. One state backend to secure and back up instead of two.

What it costs

Estimates for a quiet account, not a bill:

ItemMonthly cost
CloudTrail (first trail) + S3 logsfree + cents
OpenTofu state bucketcents
IAM Access Analyzer (external access)free
EventBridge rules, SNS emailfree at this volume
GuardDuty30-day free trial, then usually $1 to $5
GCP Organization (Cloud Identity Free)free
GCP audit logs and alertsexpected $0

What I left out on purpose: AWS Security Hub and AWS Config. Each runs roughly $5 to $15 a month even for a small account. They’re worth it once there are real workloads to watch. Until then, the alerts above cover the changes I care about.

Gotchas that bit me

These are the ones that cost me time, so they don’t have to cost you any.

  1. New AWS accounts get 10 concurrent Lambda executions. Not 1,000. Three scheduled jobs started at the same moment someone opened the app, prod throttled 21 calls, and API Gateway returned 5xx errors. The quota increase is free. Request it when you create the account, not after your first outage.
  2. GuardDuty org auto-enable only covers new accounts. My dev and prod accounts existed before I turned it on, so they had no detector at all. I had to enroll them as members explicitly. Check every account, don’t assume.
  3. Root alerts are noisy if you alert on everything. One root session on the billing pages sent 37 alerts in a day, nearly all read-only lookups, half made by the billing console itself. Alert on root sign-in and on root calls that aren’t read-only. If the read-only flag is missing, alert anyway.
  4. Archive the findings you expect. Access Analyzer flagged all 14 of my roles federated to GitHub OIDC and Identity Center. All expected. Archiving them means the next finding is one that actually matters.
  5. Google’s log-based alerts don’t run on projects without billing. My GCP security alerts were configured, green, and never fired. Linking a billing account (with a $5 budget, expected spend $0) fixed it.
  6. Check your OIDC subject format. Newer GitHub setups can use an immutable subject with owner and repository IDs. My GCP binding expected the old format and could never match. My AWS roles had to trust the immutable form too. Run gh api repos/OWNER/REPO/actions/oidc/customization/sub before writing trust policies.
  7. Make your scanner blocking. Checkov ran in soft-fail mode at first, which means it was decoration. Now it blocks the PR, and every deliberate exception has an inline skip with a reason. Future me will want to know why the alert topic isn’t KMS-encrypted.

Where it’s at

Both foundations are running: one AWS Organization with dev and prod accounts, one Google Cloud project inside its own Organization, all in OpenTofu, planned on pull requests and applied from main.

If you take one thing from this: you don’t need an enterprise budget to get enterprise-shaped guardrails. Lock down root, kill long-lived keys, deny what you don’t use, and make sure you hear about it when someone changes the rules.

← All posts · Subscribe via RSS