Install
$ agentstack add skill-aws-agent-toolkit-for-aws-setup-security-agent ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
AWS Security Agent — Setup
This skill handles ONE thing: making sure the workspace has a working agent space, IAM service role, and S3 bucket linked together. Scans and pentests live in separate skills and assume this is done.
Local state convention
All Security Agent skills share workspace-local state at .security-agent/:
config.json—{ "agent_space_id": "as-...", "region": "us-east-1", "code_reviews": { "": "cr-..." } }. Account ID, role ARN, and bucket name are derived by convention. Thecode_reviewsmap lets scans reuse the same CodeReview for a workspace.scans.json— array of{ scan_id, code_review_id, job_id, agent_space_id, scan_type, title, started_at, status, path }(keep last 50)pentests.json— same shape, for pentest jobs.gitignore— contents*so this directory stays untrackedfindings-{scan_id}.md— written by the scan skill after each scan completes
This skill's job is to populate config.json and create .gitignore.
Derived values (convention over config)
Other skills compute these on each invocation rather than reading them from config.json:
| Value | Convention | |-------|------------| | ACCOUNT | aws sts get-caller-identity --query Account --output text | | REGION | config.region (default us-east-1) | | service_role_arn | arn:aws:iam::${ACCOUNT}:role/SecurityAgentScanRole | | s3_bucket | security-agent-scans-${ACCOUNT}-${REGION} |
Why minimal config: the role name and bucket name are deterministic, so storing them adds drift risk (a user re-creating a role manually would silently use a stale path). Only agent_space_id is stored because users may have multiple agent spaces and we don't want to ask which one every session.
Workflow
- Check existing state: read
.security-agent/config.jsonif it exists. - Caller identity + region:
``bash export ACCOUNT=$(aws sts get-caller-identity --query Account --output text) export REGION="${AWS_REGION:-us-east-1}" ``
- Agent space:
- If
config.agent_space_idis set, verify with:
``bash aws securityagent batch-get-agent-spaces --agent-space-ids ``
If the response shows it doesn't exist, treat as missing.
- If missing, list existing:
``bash aws securityagent list-agent-spaces ``
- If any exist → show them to the user with name + id and ask: "Would you like to reuse one of these, or should I create a new one?" Wait for the answer. Do not auto-select.
- If user picks one, use that
agentSpaceId. - If user wants new, or none exist:
``bash aws securityagent create-agent-space --name security-scans ``
Capture returned agentSpaceId.
- Service role (
SecurityAgentScanRole, ARNarn:aws:iam::$ACCOUNT:role/SecurityAgentScanRole):
- Probe:
``bash aws iam get-role --role-name SecurityAgentScanRole ``
- If
NoSuchEntityis returned, create the role. Idempotency note:create-rolewill fail withEntityAlreadyExistsif the role already exists. If that happens, fall through toupdate-assume-role-policyto ensure the trust policy is correct.
``bash # Trust policy — includes aws:SourceAccount confused-deputy guard cat > /tmp/sa-trust.json /tmp/sa-perms.json /tmp/sa-lifecycle.json ``
Look at agentSpaces[0].awsResources.iamRoles and awsResources.s3Buckets.
- If the role ARN or the bucket name is missing from those lists, merge and update:
``bash aws securityagent update-agent-space --agent-space-id --name \ --aws-resources iamRoles=[,...],s3Buckets=[,...] ``
- Persist to
.security-agent/config.json(minimal — account/role/bucket are derived):
``json { "agent_space_id": "as-xxxxx", "region": "us-east-1" } ``
- Create gitignore if missing:
``bash mkdir -p .security-agent echo '*' > .security-agent/.gitignore ``
- Confirm to user: "Setup complete. You can run security scans or pentests now."
Rules
- Never auto-select an agent space when multiple exist — always ask the user
- Never disable safety protections (the public-access-block stays on)
- Trust policy must allow
securityagent.amazonaws.com(production service principal) and include theaws:SourceAccountconfused-deputy guard - If the user provides their own role name or bucket name (different from the conventional defaults), tell them: this plugin uses convention-based defaults (
SecurityAgentScanRole/security-agent-scans-${ACCOUNT}-${REGION}). Either accept those defaults or extend the skill — the other skills derive these names rather than reading them from config. - The scan and pentest skills can call this skill inline if
config.jsonis missing — first-time users don't need to run setup separately.
Troubleshooting
AccessDeniedcallingiam:CreateRole→ user lacks IAM permissions. Ask them to run setup with their own role ARN, or to grantiam:CreateRole+iam:PutRolePolicy.AccessDeniedons3api create-bucket→ either the bucket name is taken globally, or the user lackss3:CreateBucket. Suggest using an existing bucket they own and pass it explicitly.- Role exists but trust policy is wrong →
update-assume-role-policy(step 4 fallback). If they don't want that role updated, ask them for a different role ARN. - Agent space exists but in a different region → tell the user; suggest using the right region or creating a new space in the current region.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: aws
- Source: aws/agent-toolkit-for-aws
- License: Apache-2.0
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.