Setup Security Agent logo

Setup Security Agent

OrganizationPopular
aws
setup-security-agent

Configure AWS Security Agent for the current workspace — provision or reuse an agent space, IAM service role, and S3 bucket. Use when the user asks to "set up security agent", "configure security scanner", "is security agent configured", or on first-time use before any scan or pentest.

Overview

Publisheraws
Repositoryagent-toolkit-for-aws
Skill namesetup-security-agent
Stars
2.7K
Forks
311
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by aws on GitHub. Read the source before you install it.

Installation

Install the Setup Security Agent AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/aws/agent-toolkit-for-aws.git /tmp/agent-toolkit-for-aws
mkdir -p .claude/skills
cp -r /tmp/agent-toolkit-for-aws/plugins/aws-agents-for-devsecops/skills/setup-security-agent .claude/skills/setup-security-agent
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Setup Security Agent in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Setup Security Agent on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Setup Security Agent is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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": { "<abs_path>": "cr-..." } }. Account ID, role ARN, and bucket name are derived by convention. The code_reviews map 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 untracked
  • findings-{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:

ValueConvention
ACCOUNTaws sts get-caller-identity --query Account --output text
REGIONconfig.region (default us-east-1)
service_role_arnarn:aws:iam::${ACCOUNT}:role/SecurityAgentScanRole
s3_bucketsecurity-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

  1. Check existing state: read .security-agent/config.json if it exists.

  2. Caller identity + region:

    bash
    export ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
    export REGION="${AWS_REGION:-us-east-1}"
  3. Agent space:

    • If config.agent_space_id is set, verify with:

      bash
      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:

      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.

  4. Service role (SecurityAgentScanRole, ARN arn:aws:iam::$ACCOUNT:role/SecurityAgentScanRole):

    • Probe:

      bash
      aws iam get-role --role-name SecurityAgentScanRole
    • If NoSuchEntity is returned, create the role. Idempotency note: create-role will fail with EntityAlreadyExists if the role already exists. If that happens, fall through to update-assume-role-policy to ensure the trust policy is correct.

      bash
      # 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
  5. S3 bucket (security-agent-scans-$ACCOUNT-$REGION):

    Bucket-ownership enforcement (required). The bucket name is derived from the caller's AWS account ID and region — both non-secret and publicly derivable from ARNs / ECR URIs — so any third party can pre-register ("squat") the predictable name in their own account. Every S3 call MUST pass --expected-bucket-owner "$ACCOUNT" so the operation fails closed if the bucket is owned by someone else. A 403 Forbidden on a bucket that exists but is foreign-owned is fatal — abort setup and never upload.

    • Probe (asserts ownership):

      bash
      BUCKET="security-agent-scans-${ACCOUNT}-${REGION}"
      NEED_CREATE=0
      if aws s3api head-bucket --bucket "$BUCKET" --expected-bucket-owner "$ACCOUNT" 2>/tmp/sa-head.err; then
        : # bucket exists and is owned by this account — safe to reuse
      elif grep -q '404' /tmp/sa-head.err; then
        NEED_CREATE=1
      elif grep -Eq '403|Forbidden' /tmp/sa-head.err; then
        echo "FATAL: bucket $BUCKET exists but is owned by another account (403). Possible bucket-squatting — aborting. Nothing was uploaded." >&2
        exit 1
      else
        cat /tmp/sa-head.err >&2; exit 1
      fi
    • If not found, create it. A BucketAlreadyExists error means another account already holds the global name — treat it as fatal and distinct from BucketAlreadyOwnedByYou (which is a safe no-op). Re-assert ownership after creation before any further use:

      bash
      if [ "$NEED_CREATE" = "1" ]; then
        if [ "$REGION" = "us-east-1" ]; then
          # us-east-1: no LocationConstraint
          aws s3api create-bucket --bucket "$BUCKET" 2>/tmp/sa-create.err || true
        else
          # other regions:
          aws s3api create-bucket --bucket "$BUCKET" \
            --create-bucket-configuration LocationConstraint="$REGION" 2>/tmp/sa-create.err || true
        fi
        if grep -q 'BucketAlreadyExists' /tmp/sa-create.err; then
          echo "FATAL: bucket name $BUCKET is already owned by another account (BucketAlreadyExists). Possible bucket-squatting — aborting." >&2
          exit 1
        elif [ -s /tmp/sa-create.err ] && ! grep -q 'BucketAlreadyOwnedByYou' /tmp/sa-create.err; then
          cat /tmp/sa-create.err >&2; exit 1
        fi
        # Confirm ownership of the freshly created bucket before using it.
        aws s3api head-bucket --bucket "$BUCKET" --expected-bucket-owner "$ACCOUNT"
      fi
    • Always (re)apply public access block + 30-day lifecycle:

      bash
      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
  6. Register role + bucket on the agent space (idempotent):

    • Read existing resources:

      bash
      aws securityagent batch-get-agent-spaces --agent-space-ids <id>

      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 <id> --name <existing-name> \
        --aws-resources iamRoles=[<arn1>,<arn2>...],s3Buckets=[<bucket1>,<bucket2>...]
  7. Persist to .security-agent/config.json (minimal — account/role/bucket are derived):

    json
    {
      "agent_space_id": "as-xxxxx",
      "region": "us-east-1"
    }
  8. Create gitignore if missing:

    bash
    mkdir -p .security-agent
    echo '*' > .security-agent/.gitignore
  9. 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)
  • Every S3 call against the derived bucket MUST pass --expected-bucket-owner "$ACCOUNT". The bucket name is derived from a non-secret account ID, so a third party can pre-register it; a 403/BucketAlreadyExists on a foreign-owned bucket is fatal — abort and never upload.
  • Trust policy must allow securityagent.amazonaws.com (production service principal) and include the aws:SourceAccount confused-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.json is missing — first-time users don't need to run setup separately.

Troubleshooting

  • AccessDenied calling iam:CreateRole → user lacks IAM permissions. Ask them to run setup with their own role ARN, or to grant iam:CreateRole + iam:PutRolePolicy.
  • AccessDenied on s3api create-bucket → either the bucket name is taken globally, or the user lacks s3:CreateBucket. Suggest using an existing bucket they own and pass it explicitly.
  • 403 Forbidden / BucketAlreadyExists on the derived bucket → the predictable name is owned by a different account (bucket-squatting). This is fatal by design — do not upload. Have the user pick a bucket name they own (or run from the expected account/region) and re-run setup.
  • Role exists but trust policy is wrongupdate-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

What does the Setup Security Agent AI skill do?

Configure AWS Security Agent for the current workspace — provision or reuse an agent space, IAM service role, and S3 bucket. Use when the user asks to "set up security agent", "configure security scanner", "is security agent configured", or on first-time use before any scan or pentest.

Why use Setup Security Agent on TypingMind?

Because you install it once and use it with any model. Setup Security Agent is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Setup Security Agent in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/aws/agent-toolkit-for-aws/tree/main/plugins/aws-agents-for-devsecops/skills/setup-security-agent. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Setup Security Agent?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Setup Security Agent?

As many as you like. As long as a model supports skills, you can use Setup Security Agent with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Setup Security Agent AI skill free?

Yes. It is published on GitHub by aws under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇