
AWS Security Agent Setup
OfficialFreeEasily configure your AWS Security Agent environment.
Free · Opens the source repo
What AWS Security Agent Setup does
The AWS Security Agent Setup skill is designed to streamline the configuration of the AWS Security Agent for your workspace. This skill ensures that you have a functioning agent space, an appropriate IAM service role, and a linked S3 bucket, all necessary components for running security scans and pentests. It is triggered when users request to set up or configure their security agent, making it an essential tool for anyone looking to enhance their AWS security posture.
When you initiate this skill, it first checks for an existing configuration in the .security-agent/config.json file. If no configuration exists, it will guide you through creating a new agent space or reusing an existing one. The skill intelligently handles the creation of the IAM role and S3 bucket, ensuring that all necessary permissions and policies are applied correctly. This minimizes the risk of configuration drift and ensures that your setup is consistent and compliant with best practices.
The skill is particularly useful for developers and security professionals who need to set up or maintain their security scanning environment in AWS. By automating the configuration process, it saves time and reduces the potential for human error. This skill is ideal for first-time users setting up their security agent or for experienced users who need to verify or reconfigure their existing setup.
However, it is important to note that this skill focuses solely on the setup process and does not include the actual scanning or pentesting functionalities. Users will need to utilize additional skills for those tasks once the environment is properly configured. Overall, the AWS Security Agent Setup skill is a practical solution for ensuring that your AWS security environment is correctly established and ready for use.
When to use it
Use this skill when you need to set up or configure the AWS Security Agent for your workspace, particularly before running scans or pentests.
When not to use it
This skill is not suitable for executing security scans or pentests; it only handles the setup of the necessary components.
What you can build with it
First-time Security Agent Setup
Use this skill to configure your AWS Security Agent environment for the first time, ensuring all components are in place.
Reconfiguring Existing Setup
If your security environment needs adjustments, this skill can help verify and update your existing configurations.
Preparing for Security Scans
Before running any security scans or pentests, use this skill to ensure your AWS Security Agent is correctly configured.
How to install AWS Security Agent Setup
View source1. Install with the skills CLI
npx skills add aws/agent-toolkit-for-aws/setup-security-agent --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by awsAWS 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": { "<abs_path>": "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:
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:aws securityagent batch-get-agent-spaces --agent-space-ids <id>If the response shows it doesn't exist, treat as missing.
-
If missing, list existing:
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:
aws securityagent create-agent-space --name security-scansCapture returned
agentSpaceId.
-
-
-
Service role (
SecurityAgentScanRole, ARNarn:aws:iam::$ACCOUNT:role/SecurityAgentScanRole):-
Probe:
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.# Trust policy — includes aws:SourceAccount confused-deputy guard cat > /tmp/sa-trust.json <<EOF {"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"securityagent.amazonaws.com"},"Action":"sts:AssumeRole","Condition":{"StringEquals":{"aws:SourceAccount":"${ACCOUNT}"}}}]} EOF # Permissions policy (S3 + CloudWatch Logs) cat > /tmp/sa-perms.json <<EOF {"Version":"2012-10-17","Statement":[ {"Effect":"Allow","Action":["s3:GetObject","s3:GetObjectVersion","s3:ListBucket"],"Resource":["arn:aws:s3:::security-agent-scans-${ACCOUNT}-${REGION}","arn:aws:s3:::security-agent-scans-${ACCOUNT}-${REGION}/*"]}, {"Effect":"Allow","Action":["logs:CreateLogGroup","logs:CreateLogStream","logs:PutLogEvents"],"Resource":"arn:aws:logs:*:${ACCOUNT}:log-group:/aws/securityagent/*"} ]} EOF aws iam create-role --role-name SecurityAgentScanRole --assume-role-policy-document file:///tmp/sa-trust.json # if EntityAlreadyExists: aws iam update-assume-role-policy --role-name SecurityAgentScanRole --policy-document file:///tmp/sa-trust.json # always (re)apply permissions: aws iam put-role-policy --role-name SecurityAgentScanRole --policy-name SecurityAgentCodeReviewAccess --policy-document file:///tmp/sa-perms.json
-
-
S3 bucket (
security-agent-scans-$ACCOUNT-$REGION):-
Probe:
BUCKET="security-agent-scans-${ACCOUNT}-${REGION}" aws s3api head-bucket --bucket "$BUCKET" -
If 404, create:
# us-east-1: no LocationConstraint aws s3api create-bucket --bucket "$BUCKET" # other regions: aws s3api create-bucket --bucket "$BUCKET" --create-bucket-configuration LocationConstraint="$REGION" -
Always (re)apply public access block + 30-day lifecycle:
aws s3api put-public-access-block --bucket "$BUCKET" \ --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true cat > /tmp/sa-lifecycle.json <<'EOF' {"Rules":[{"ID":"AutoDeleteUploads","Status":"Enabled","Filter":{"Prefix":""},"Expiration":{"Days":30}}]} EOF aws s3api put-bucket-lifecycle-configuration --bucket "$BUCKET" --lifecycle-configuration file:///tmp/sa-lifecycle.json
-
-
Register role + bucket on the agent space (idempotent):
-
Read existing resources:
aws securityagent batch-get-agent-spaces --agent-space-ids <id>Look at
agentSpaces[0].awsResources.iamRolesandawsResources.s3Buckets. -
If the role ARN or the bucket name is missing from those lists, merge and update:
aws securityagent update-agent-space --agent-space-id <id> --name <existing-name> \ --aws-resources iamRoles=[<arn1>,<arn2>...],s3Buckets=[<bucket1>,<bucket2>...]
-
-
Persist to
.security-agent/config.json(minimal — account/role/bucket are derived):{ "agent_space_id": "as-xxxxx", "region": "us-east-1" } -
Create gitignore if missing:
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.
Frequently asked questions about AWS Security Agent Setup
Similar skills
GitHub Actions Hardening
Enhance the security of your GitHub Actions workflows.
Sensitive Logging Audit
Audit and fix sensitive data exposure in Python logging.
Android App Static Analysis
Automate security assessments of Android apps with MobSF.
Integrating DAST with OWASP ZAP
Seamlessly integrate dynamic security testing into CI/CD pipelines.
Implementing Runtime Security with Tetragon
Enhance Kubernetes security with eBPF-based observability.
Implementing Mobile Application Management
Secure enterprise data on mobile devices with app-level controls.
