Skip to content

Add tooling to manage AWS IAM access keys#6872

Open
dannyroberts wants to merge 4 commits intomasterfrom
dmr/manage-iam-keys
Open

Add tooling to manage AWS IAM access keys#6872
dannyroberts wants to merge 4 commits intomasterfrom
dmr/manage-iam-keys

Conversation

@dannyroberts
Copy link
Copy Markdown
Member

@dannyroberts dannyroberts commented May 7, 2026

SAAS-19726

  • Adds scripts/aws/manage-iam-keys.py for inspecting and rotating IAM access keys, building blocks for SES SMTP credential rotation
  • Subcommands: list (JSON), create (CSV in the AWS console download format consumed by derive_ses_smtp_password.py), deactivate, reactivate, remove
  • remove refuses without --force unless the key is Inactive and either never used or last used 24h+ ago

Note for this to work you need an aws profile (e.g. in your ~/.aws/config) that has access to the IAM keys you're interested in—it'll need to have the correct account number and role.

Environments Affected

None — this adds a new standalone script under scripts/aws/ and does not modify any environment files.

Test plan

  • ./scripts/aws/manage-iam-keys.py ses-iam ses-staging list outputs a JSON array with AccessKeyId, Status, CreateDate, LastUsedDate, LastUsedService, LastUsedRegion
  • ./scripts/aws/manage-iam-keys.py ses-iam ses-swiss create returns CSV that derive_ses_smtp_password.py can consume (extract field 2 as the secret)
  • ./scripts/aws/manage-iam-keys.py ses-iam ses-swiss list shows a key
  • ./scripts/aws/manage-iam-keys.py ses-iam ses-swiss remove <key-id> --force succeeds, even while it's active. (Recreate the key, this time with > /dev/null since we don't need to see the output, for the next tests.)
  • ./scripts/aws/manage-iam-keys.py ses-iam ses-swiss remove <key-id> refuses while the key is Active
  • ./scripts/aws/manage-iam-keys.py ses-iam ses-swiss deactivate <key-id> flips status to Inactive; reactivate <key-id> flips it back to Active (the deactivate again for the next test)
  • ./scripts/aws/manage-iam-keys.py ses-iam ses-swiss remove <key-id> succeeds for an Inactive key that is never-used or last used 24h+ ago

@dannyroberts dannyroberts force-pushed the dmr/manage-iam-keys branch from 99360b7 to 11f2dc7 Compare May 7, 2026 22:07
@dannyroberts dannyroberts marked this pull request as draft May 7, 2026 22:08
dannyroberts and others added 4 commits May 8, 2026 09:47
Implements the list subcommand of the IAM key management tool described
in SAAS-19726. Outputs a JSON list of a user's access keys, including
last-used date, service, and region.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
These set the AWS IAM access key status to Inactive or Active
respectively and print the updated key info as JSON.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Creates a new access key for the given IAM user and prints the
credentials as CSV in the same format as the AWS console download,
making the output directly consumable by derive_ses_smtp_password.py
and the rest of the SES rotation tooling.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Removes the given access key and prints the removed key's info as JSON.
Without --force, refuses to remove a key that is still Active or that
has been used within the last 24 hours, so callers must deactivate
first and let any in-flight usage drain before deletion.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dannyroberts dannyroberts force-pushed the dmr/manage-iam-keys branch from 11f2dc7 to c759854 Compare May 8, 2026 15:00
@dannyroberts dannyroberts marked this pull request as ready for review May 8, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant