opensite-ai/opensite-skills / aws-compute
aws-compute
VerifiedProvisions, scales, and operates Amazon EC2 virtual-machine workloads: instance-type selection (Graviton/Arm64, burstable T credits, GPU, instance store vs EBS), launch templates, Auto Scaling groups (scaling policies, instance refresh, mixed instances, Spot, warm pools, lifecycle hooks), IMDSv2, placement groups, Elastic IPs, AMI lifecycle, and Systems Manager fleet operations (Session Manager, Run Command, Patch Manager). Applies to EC2 instance and fleet questions, InsufficientInstanceCapacity, CPU-credit/surplus charges, IMDSv2 401s, instances stuck in Pending:Wait, ASG not replacing unhealthy instances, status-check failures, SSH refused/timed out, or instances missing as SSM managed nodes. For a single secure instance launch, the launching-ec2-instance-with-best-practices skill is more appropriate; for instance profiles, see setting-up-ec2-instance-profiles; for Image Builder, see amazon-ec2-image-builder. Does NOT cover Lambda, ECS/Fargate, EKS, VPC/ALB/NLB design, or IAM policy authoring.
| File | Kind | Size |
|---|---|---|
| .aws-skill-metadata | other | 18 B |
| SKILL.md | skill md | 8.7 KB |
| references/ami-management.md | markdown | 5.9 KB |
| references/auto-scaling.md | markdown | 10.1 KB |
| references/instance-selection.md | markdown | 5.7 KB |
| references/provisioning.md | markdown | 9.2 KB |
| references/systems-manager.md | markdown | 7.4 KB |
| references/troubleshooting.md | markdown | 5.7 KB |
references/ami-management.md
View on GitHub# AMI Management
## Overview
Creating, sharing, and retiring Amazon Machine Images. For building AMIs with an automated pipeline (recipes, components, distribution), use the `amazon-ec2-image-builder` skill — this reference covers the AMI lifecycle and sharing that a domain skill owns.
## Create a custom AMI
```bash
aws ec2 create-image --instance-id <id> --name "my-app-v1" --description "..."
```
`NoReboot` defaults to `false`, so EC2 reboots the instance to guarantee a consistent file system. **Setting `--no-reboot` skips that, and AWS cannot guarantee file-system integrity** — only use it if you've quiesced/flushed the disk yourself.
The AMI's snapshots inherit the source volumes' encryption. Image from encrypted EBS volumes so the AMI is encrypted at rest; if the source is unencrypted, `copy-image --encrypted --kms-key-id <customer-managed-key>` produces an encrypted copy (also the prerequisite for cross-account sharing — see below).
## Retire an AMI: deprecate vs disable vs deregister
These are three distinct actions with different reversibility — choosing the wrong one either fails to block launches or destroys the image.
| Action | Effect | Still launchable? | Reversible? |
|--------|--------|-------------------|-------------|
| **Deprecate** (`enable-image-deprecation`) | Hides the AMI from `describe-images` listings and the console wizard for other accounts after a date | **Yes** — anyone with the AMI ID can still launch; ASGs/launch templates keep using it | Yes (`disable-image-deprecation`) |
| **Disable** (`disable-image`) | Sets state to `disabled`, **blocks all new launches**, and revokes launch permissions/sharing | No | **Partially** — `enable-image` restores launchability, visibility, and shareability, but accounts/orgs/OUs that lost access when the AMI was disabled do NOT regain it automatically; you must re-grant launch permissions (re-share) via `modify-image-attribute`. (AMI tags are unaffected by disable/enable.) |
| **Deregister** (`deregister-image`) | Permanently removes the AMI | No | Only if a Recycle Bin retention rule was set beforehand |
**To block new launches while keeping the ability to restore, use `disable-image`** — deprecate does not actually stop launch-by-ID, and deregister is effectively permanent.
## Share an AMI cross-account / cross-region
Grant launch permission with `modify-image-attribute` (specific account IDs, an Organization/OU, or public).
**Encrypted AMIs have a KMS catch:** an AMI whose snapshots are encrypted with the **default AWS-managed EBS key (`aws/ebs`) cannot be shared across accounts** — the default service key is usable only within the owning account, so grantees can't decrypt the snapshots even with launch permission. To share an encrypted AMI:
1. Re-encrypt the snapshots under a **customer-managed KMS key** (e.g., copy the AMI/snapshot specifying that key).
2. Grant the target account permission on that customer-managed KMS key via the key policy: `kms:DescribeKey`, `kms:Decrypt`, `kms:CreateGrant`, `kms:ReEncrypt*`, `kms:GenerateDataKey*`.
3. Add the account to the AMI's launch permissions.
KMS keys are Region-scoped, so copying/sharing an encrypted AMI to a different Region or account needs a customer-managed KMS key in each Region. To prevent accidental public exposure, enable **AMI block public access** at the account level (per Region; it doesn't retroactively unshare existing public AMIs).
## Common Errors
| Error/Symptom | Cause | Fix |
|---------------|-------|-----|
| Target account can't launch a shared encrypted AMI | Snapshots use the default `aws/ebs` key | Re-encrypt under a customer-managed key and grant the account key access |
| Users still launch an AMI you "removed" | Deprecation only hides; still launchable by ID | Use `disable-image` to block launches (or deregister to delete) |
| Deregistered AMI can't be recovered | Deregister is permanent without Recycle Bin | Prefer `disable-image` to block reversibly; set Recycle Bin rules for critical AMIs |
| New AMI has a corrupt filesystem | `--no-reboot` skipped the consistency reboot | Recreate without `--no-reboot`, or flush/quiesce before imaging |
## Security Considerations
- **Cross-account sharing requires a customer-managed KMS key** — snapshots under the default `aws/ebs` key can't be shared. Re-encrypt under a customer-managed key and grant the target account access to it in the key policy. See the "Share an AMI cross-account" section above for the full set of required KMS actions (`kms:DescribeKey`, `kms:Decrypt`, `kms:CreateGrant`, `kms:ReEncrypt*`, `kms:GenerateDataKey*`).
- **Enable AMI block public access** at the account/Region level to prevent accidental public exposure of an image.
- **Scrub secrets before imaging** — an AMI captures the source instance's disk, so remove anything sensitive first: shell history (`~/.bash_history`), long-lived credentials/API keys, SSH host keys and `authorized_keys`, and any secrets injected via user data or configuration management. Otherwise they are baked into every instance launched from the AMI (and into anyone you share it with).
- **Prefer reversible retirement** — `disable-image` blocks launches and revokes sharing but is reversible; `deregister-image` is effectively permanent (only recoverable via a pre-set Recycle Bin rule). Reversible retirement matters for security investigations: if an image is later implicated in a discovered security event, a disabled AMI can be retained and restored for forensic analysis, whereas a deregistered one may be gone.
- **Audit AMI operations with CloudTrail** — enable CloudTrail in all Regions and alarm on sensitive AMI actions (`ModifyImageAttribute` for sharing changes, `DeregisterImage`, `DisableImage`) to detect unauthorized cross-account sharing or destructive deregistration.
## Related
- The `amazon-ec2-image-builder` skill for automated AMI build pipelines
- [provisioning.md](provisioning.md) to reference the AMI in a launch template
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |