This is a hands-on demo suite designed to showcase AWS Security Agent capabilities across three complementary scenarios: automated security design review, AI-powered infrastructure generation with security code review, and penetration testing against intentionally vulnerable infrastructure.
- Review security vulnerability patterns and how the agent detects them (Design Review)
- Generate Terraform infrastructure from natural language using Amazon Bedrock, then use AWS Security Agent to review the generated code for security issues via GitHub integration (AI Infra Generator - sample app)
- Deploy an intentionally vulnerable web application and run penetration tests (Pen Test)
- Learn how AWS Security Agent identifies vulnerabilities across 10 security domains
- How AWS Security Agent detects vulnerabilities across 10 security domains
- How to use Amazon Bedrock to generate Terraform code from natural language (defaults to Claude Sonnet 4)
- How AWS Security Agent reviews AI-generated infrastructure code for security issues via GitHub pull requests
- How AWS Security Agent performs penetration testing against web applications
- Common security misconfigurations in AWS environments and how to remediate them
⚠️ Disclaimer: This repository includes intentionally vulnerable infrastructure designed to demonstrate AWS Security Agent capabilities. Do not deploy in production environments or store real data.Intentionally vulnerable directories:
pen-test/terraform/— Deploys a Flask web app (user_data.sh) with OWASP Top 10 vulnerabilities (SQL injection, XSS, SSRF, insecure deserialization, path traversal, hardcoded credentials) and insecure AWS infrastructure (unencrypted S3, RDS, EBS; overly permissive IAM; HTTP-only ALB).design-review/— Design documents (architecture diagram and design document) containing example vulnerable configurations as input for Security Agent design reviews. Not deployable.github-review/generated/— Sample Terraform output from the AI generator. Not applied by the demo.Production-quality directories:
github-review/terraform/andgithub-review/lambda_function.py— The Demo 2 deployment infrastructure (Lambda, API Gateway, S3, IAM). No intentional vulnerabilities.Any AWS access keys in this repository (e.g.,
AKIAIOSFODNN7EXAMPLE) are AWS documentation placeholder keys, not real credentials.
- Prerequisites
- Architecture Overview
- Configuration Reference
- Demo 1: Design Review
- Demo 2: AI Infrastructure Generator
- Demo 3: Penetration Testing
- Cost Estimate
- Cleanup
- Additional Resources
Install these tools before deploying any demo:
| Tool | Version | Installation | Verify |
|---|---|---|---|
| AWS CLI | v2+ | Install Guide | aws --version |
| Terraform | v1.0+ | Install Guide | terraform version |
| Python | 3.12+ | Install Guide | python3 --version |
| pip | Latest | Included with Python | pip3 --version |
- An AWS account with permissions to create IAM roles, Lambda functions, API Gateway, S3 buckets, EC2 instances, RDS databases, VPCs, and ALBs
- AWS CLI configured with credentials:
aws configure
# Enter your AWS Access Key ID, Secret Access Key, and default region (us-east-1)- AWS Security Agent access (Demo 1 and Demo 3): You must have access to the AWS Security Agent console and web application
- Amazon Bedrock model access (Demo 2 only): You must enable model access in the Bedrock console for the model you plan to use before deploying. This applies only to the Demo 2 sample Lambda that generates Terraform code — its default is Anthropic Claude Sonnet 4, and you can point it at any Bedrock-supported model by overriding the
bedrock_model_idvariable. This setting has no effect on AWS Security Agent itself; the model AWS Security Agent uses for design review, code review, and penetration testing is managed by the service and is not user-configurable.
| Prerequisite | Demo 1 | Demo 2 | Demo 3 |
|---|---|---|---|
| AWS Security Agent Agent Space | ✅ Required | — | ✅ Required |
| GitHub account with a repository | — | ✅ Required | — |
| GitHub personal access token | — | ✅ Required | — |
| Route 53 hosted zone | — | — | Optional |
requests Python package |
— | ✅ pip install requests |
— |
GitHub Token Setup (Demo 2)
Create a fine-grained personal access token with these permissions on your target repository:
- Contents: Read and write (branch + commit creation)
- Pull requests: Read and write (PR creation)
- Metadata: Read (auto-granted)
Important: all three must be set to Read and write (not just Read). The Lambda will return
HTTP Error 403: Forbiddenon PR creation if Pull requests: write is missing, or on branch creation if Contents: write is missing.
The repository must already exist and have at least one commit on main (GitHub's "Add a README" option at creation time is the simplest way). Save the token securely — you will need it during Terraform deployment.
AWS Security Agent Setup (Demo 1 and Demo 3)
If you haven't set up AWS Security Agent yet:
- Navigate to AWS Security Agent in the AWS Console
- Click Set up AWS Security Agent
- Enter a name for your Agent Space (e.g.,
security-agent-demo) - Select IAM-only access under User access configuration
- Click Set up AWS Security Agent
This creates your Agent Space and establishes the web application. For SSO access, see the full setup guide.
Sample application for generating non-secure Terraform code to demonstrate AWS Security Agent code review.
| Service | Demo | Purpose |
|---|---|---|
| Amazon Bedrock | Demo 2 | Terraform code generation by the Demo 2 sample Lambda (defaults to Claude Sonnet 4, configurable via bedrock_model_id). Not related to the model AWS Security Agent runs. |
| AWS Lambda | Demo 2 | Request processing and orchestration |
| Amazon API Gateway | Demo 2 | REST API endpoint |
| Amazon S3 | Demo 2, Demo 3 | Context storage, vulnerable bucket |
| Amazon EC2 | Demo 3 | Vulnerable web application host |
| Amazon RDS (MySQL) | Demo 3 | Application database |
| Application Load Balancer | Demo 3 | Public-facing entry point |
| Amazon VPC | Demo 3 | Network isolation |
| Amazon Route 53 | Demo 3 | DNS management (optional) |
| AWS IAM | All | Access management |
Each demo uses Terraform variables for configuration. Variables marked Required have no default and must be provided by the user via terraform.tfvars or environment variables (TF_VAR_<name>).
File: github-review/terraform/terraform.tfvars
(copy from terraform.tfvars.example)
| Variable | Required | Default | Description |
|---|---|---|---|
github_token |
Yes | — | GitHub PAT with Contents and Pull requests write access |
github_owner |
Yes | — | GitHub username or organization |
github_repo |
Yes | — | Target repository name for generated PRs |
aws_region |
No | us-east-1 |
AWS region for deployment |
project_name |
No | bedrock-infra-generator |
Prefix for all resource names |
bedrock_model_id |
No | us.anthropic.claude-sonnet-4-20250514-v1:0 |
Bedrock inference profile ID used only by the Demo 2 sample Lambda to generate Terraform. Does not change the model AWS Security Agent uses. |
context_key |
No | it-operations-tags.json |
S3 key for the organizational tags file |
File: pen-test/terraform/terraform.tfvars
(copy from terraform.tfvars.example)
| Variable | Required | Default | Description |
|---|---|---|---|
db_password |
Yes | — | RDS admin password (min 8 characters) |
domain_name |
No | "" (empty) |
Route 53 hosted zone domain (e.g., example.com). Leave empty to skip DNS and use the raw ALB DNS name from the alb_dns_name output. |
aws_region |
No | us-east-1 |
AWS region for deployment |
project_name |
No | aws-security-agent-pentest |
Prefix for all resource names |
instance_type |
No | t3.micro |
EC2 instance type |
db_username |
No | admin |
RDS admin username |
Two supported paths for the pen test target:
- With a Route 53 hosted zone (you own
yourdomain.comin this AWS account): setdomain_name = "yourdomain.com"and the Terraform will createpentest.yourdomain.compointing to the ALB. AWS Security Agent verifies ownership with a single click.- Without a Route 53 hosted zone: leave
domain_nameempty (the default). Use thealb_dns_nameoutput as your target. In the Security Agent console, choose DNS TXT verification and add the record at your DNS provider, or use HTTP route verification.
The design review demo showcases AWS Security Agent's automated vulnerability detection across 10 security domains with 36 vulnerability scenarios. You upload design documents to the Security Agent web application, and it analyzes them against enabled security requirements.
| Domain | Example Vulnerability |
|---|---|
| Audit Logging | CloudTrail disabled |
| Authentication | IAM user without MFA |
| Authorization | Wildcard IAM policies (*:*) |
| Information Protection | Unencrypted RDS |
| Log Protection | CloudWatch Logs without KMS |
| Privileged Access | Overly broad Lambda roles |
| Secret Protection | Hardcoded credentials in code |
| Secure by Default | Unrestricted security groups |
| Tenant Isolation | Missing tenant boundaries in DynamoDB |
| Custom Rules | Unencrypted log storage in S3 |
Before running a design review, configure which security requirements the agent should evaluate against.
- Navigate to AWS Security Agent in the AWS Console
- In the left sidebar, choose Security requirements
- On the Managed security requirements tab, select the requirements you want to enable:
- Audit Logging Best Practices
- Authentication Best Practices
- Authorization Best Practices
- Information Protection Best Practices
- Log Protection Best Practices
- Privileged Access Best Practices
- Secret Protection Best Practices
- Secure by Default Best Practices
- Tenant Isolation Best Practices
- Click Enable to activate the selected requirements
Tip: You can also create custom security requirements under the Custom security requirements tab. See the demo file for an example custom log protection requirement.
- In the AWS Console, navigate to your Agent Space and click Admin access (or Web app tab) to open the Security Agent web application
- In the left sidebar, click Design reviews
- Click Create Design Review
- Enter a name:
security-agent-demo-review
Upload the design documents from this repository for the agent to analyze.
- In the Files to review section, upload the following files from the
design-review/folder:AnyBank Digital Portal Design Document.docx— the vulnerability scenarios documentAnyBank Digital Portal Architecture.png— the architecture diagram
- Supported formats: DOC, DOCX, JPEG, MD, PDF, PNG, TXT (max 5 files, 2MB each, 6MB total)
Tip: For best results, include architecture diagrams and technical documentation that describe your system's security-relevant components and data flows.
- Review the uploaded files to ensure accuracy
- Click Start design review
- Wait for the analysis to complete (typically a few minutes)
- Once complete, the findings summary shows counts for each status: Compliant, Non-compliant, Insufficient data, and Not applicable
- Filter by Non-compliant to see findings that need attention
- Click on any finding to see:
- The specific security requirement being evaluated
- A detailed explanation of why the finding received its status
- Recommended remediation guidance
- Compare the agent's findings against the expected results in
design-review/AnyBank Digital Portal Design Document.docx
The agent should detect vulnerabilities across all 10 security domains:
| Severity | Expected Count |
|---|---|
| Critical | 6 (authorization, audit logging, information protection, secrets, secure defaults, tenant isolation) |
| High | 3 (authentication, privileged access, custom log test) |
| Medium | 1 (log protection) |
⚠️ Important: This demo is a sample application designed to generate Terraform code that is intentionally not security-hardened. The purpose is to produce pull requests with infrastructure code that AWS Security Agent can then review and flag for security issues. Do not use the generated Terraform code in production — it is meant to showcase the Security Agent's GitHub code review capabilities, not to serve as a reference for secure infrastructure.
An AI-powered system that converts natural language infrastructure requests into Terraform code and creates GitHub pull requests automatically using Amazon Bedrock. Once the PRs are created, you use AWS Security Agent's code review feature to scan the generated code for security misconfigurations — demonstrating how the agent catches issues in AI-generated infrastructure code.
Enable access for the model the Demo 2 sample Lambda will use to generate Terraform. The default is Anthropic Claude Sonnet 4, but you can point the Lambda at any Bedrock-supported model by setting the bedrock_model_id variable in your terraform.tfvars. This variable configures only this sample Lambda — it does not affect the model AWS Security Agent uses for its reviews.
- Navigate to Amazon Bedrock in the AWS Console
- In the left sidebar, click Model access
- Click Modify model access
- Find your chosen model (e.g., Anthropic → Claude Sonnet 4) and check the box
- Click Next → Submit
- Wait for the access status to show Access granted
Navigate to the Terraform directory and create your terraform.tfvars from the example file:
cd github-review/terraform
cp terraform.tfvars.example terraform.tfvarsEdit terraform.tfvars with your GitHub details (see Configuration Reference):
github_token = "github_pat_..."
github_owner = "your-username"
github_repo = "your-repo"# From github-review/terraform/
# Create the Lambda deployment package
zip -j lambda_function.zip ../lambda_function.py
# Deploy infrastructure (~1 minute)
terraform init
terraform plan
terraform applyThe deployment creates:
- ✅ API Gateway REST endpoint
- ✅ Lambda function with Bedrock access
- ✅ S3 bucket for organizational context
- ✅ IAM roles with least-privilege permissions
Upload the organizational tags file that Bedrock uses to tag generated infrastructure:
# From github-review/terraform/
aws s3 cp ../it-operations-tags.json s3://$(terraform output -raw s3_bucket_name)/it-operations-tags.jsonNote: This file contains organizational metadata (environment, cost center, compliance requirements, business unit, etc.) that Bedrock injects into every generated Terraform resource as tags. Without it, the Lambda still works but generated code won't include your org's tagging standards. You can customize
it-operations-tags.jsonto match your own organization's tagging policy.
# From github-review/terraform/
cd ..
export API_URL=$(cd terraform && terraform output -raw api_gateway_url)
export API_KEY=$(cd terraform && terraform output -raw api_key)
# Run a single test (from github-review/)
python3 test_request.py update_tags
# Run all test cases
python3 test_request.py allAvailable test cases:
| Name | Request |
|---|---|
create_vpc |
Create a new VPC with public and private subnets |
update_tags |
Update CostCenter tag on an EC2 file |
create_ec2 |
Create EC2 instance with EBS volume |
A successful response looks like:
{
"terraform_code": "resource \"aws_vpc\" \"main\" { ... }",
"pr_url": "https://github.com/your-user/your-repo/pull/1",
"status": "success"
}Check your GitHub repository for the new pull request with the generated Terraform code.
This is the key part of the demo — use AWS Security Agent to review the generated pull requests for security issues.
- Navigate to AWS Security Agent in the AWS Console
- Set up the GitHub integration by connecting your repository (see Code Review Guide)
- AWS Security Agent will automatically review new pull requests and flag security findings such as:
- Missing encryption configurations
- Overly permissive IAM policies
- Unrestricted security group rules
- Missing logging and monitoring
- Non-compliant tagging
- Review the agent's comments directly on the GitHub pull request
Tip: Try generating multiple types of infrastructure (VPC, EC2, RDS) to see the range of security findings the agent can detect in AI-generated code.
For full details on the Lambda function flow, see github-review/README.md.
Deploys an intentionally vulnerable web application and runs AWS Security Agent penetration testing against it.
✅ Verified run notes & gotchas (tested end-to-end on macOS, us-east-1)
These notes capture the exact path that worked, plus the errors encountered and how to get past them. Replace <AWS_ACCOUNT_ID>, <ALB_DNS_NAME>, and <AWS_PROFILE> with your own values.
Terraform install (Homebrew): brew install terraform fails — the formula was removed from Homebrew core (Error: No available formula with the name "terraform"). Use the HashiCorp tap:
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
terraform version # e.g. Terraform v1.15.8 on darwin_arm64If the tap emits a
vagrant.rbimport warning, ignore it —terraformstill installs and works.
Credentials: terraform apply fails with InvalidClientTokenId / 403 if credentials aren't set. Configure AWS credentials (an IAM user or IAM Identity Center / SSO profile) with permissions to deploy the stack, then verify:
aws configure sso # or: aws configure (for an IAM user)
aws sts get-caller-identity --profile <AWS_PROFILE>
# Arn: arn:aws:sts::<AWS_ACCOUNT_ID>:assumed-role/<role-name>/<session>Token expiry: temporary credentials expire (
ExpiredTokenerror), commonly hit atterraform destroytime. Refresh your credentials (e.g.aws sso login --profile <AWS_PROFILE>), then retry.
Observed deploy timing: ~5.5 min total, 27 resources added. RDS (db.t3.micro) is the long pole at ~5m19s; NAT Gateway ~1m45s; ALB ~3m24s.
curl gotchas during manual testing:
- Keep the whole
curlcommand on one line — a wrapped line makes zsh throwcurl: (2) no URL specified/no such file or directory. - Don't paste example annotations (e.g.
then token=2) onto the command line — zsh treatsthenas a hostname (Could not resolve host: then). - The SQLi payload
?q=' OR '1'='1can trip zsh/curl withURL rejected: Malformed input to a URL function— URL-encode it, or lead with the IDOR / API calls which are the most reliable live demos.
During the pen test run: the run is server-side (in AWS), so your laptop can sleep; it takes ~1–4 hours. A live scan opens many DB connections, so the small db.t3.micro may briefly return pymysql OperationalError (1040, 'Too many connections') — expected, not a failure.
What vulnerabilities are included?
Application-Level:
- SQL Injection (search and login endpoints)
- Cross-Site Scripting (XSS)
- Broken Authentication
- Broken Access Control (IDOR)
- Sensitive Data Exposure
- Insecure Deserialization
- SSRF (Server-Side Request Forgery)
- Path Traversal
Infrastructure-Level (non-exploitable):
- Unencrypted S3 bucket
- Unencrypted RDS storage
- Unencrypted EBS volumes
- Overly permissive IAM roles
- No backup configuration
- Missing CloudWatch logging
Create your terraform.tfvars from the example file:
cd pen-test/terraform
cp terraform.tfvars.example terraform.tfvarsEdit terraform.tfvars with your values, or set environment variables (see Configuration Reference):
export TF_VAR_db_password="YourStrongPassword123!"
# Optional: only if you own a Route 53 hosted zone in this AWS account.
# Leave unset to use the raw ALB DNS name instead.
export TF_VAR_domain_name="yourdomain.com"cd pen-test/terraform
terraform init
terraform plan
terraform applyDeployment time: ~8 minutes (RDS takes longest)
The deployment creates:
- ✅ VPC with public and private subnets
- ✅ EC2 instance running vulnerable Flask app (private subnet)
- ✅ RDS MySQL database (unencrypted, no backups)
- ✅ Application Load Balancer (public-facing)
- ✅ S3 bucket (unencrypted)
- ✅ Overly permissive IAM roles
Wait 5–10 minutes after deployment for the application to initialize:
terraform output pentest_target_urlOpen the URL in your browser. You should see the "
- Navigate to AWS Security Agent in the AWS Console
- In the left sidebar, select Agent Spaces, then select your Agent Space
- Click Enable penetration test in the header
- In the Target domains field, type the target. Nothing is pre-populated — AWS Security Agent does not auto-discover ALBs or Route 53 records.
- Path A (Route 53 hosted zone in this account): type
pentest.<your-domain>(e.g.,pentest.example.com) - Path B (ALB DNS name): type the full ALB DNS name from
terraform output -raw alb_dns_name, for exampleaws-security-agent-pentest-alb-1234567890.us-east-1.elb.amazonaws.com
- Path A (Route 53 hosted zone in this account): type
- Select verification method: DNS_TXT (recommended) or HTTP_ROUTE
- Click Next
- Path A — Route 53 domains (same account): the domain you typed will appear in the verification list. Select it and click One-click verification — AWS Security Agent creates the TXT record automatically.
- Path B — ALB DNS name or external DNS providers: AWS Security Agent cannot write TXT records to AWS-managed ALB DNS, so one-click verification is not available. You must either:
- Use HTTP_ROUTE verification (recommended for ALB targets): the agent gives you a path + token, and verifies by fetching it over HTTP. This "just works" since the ALB is already reachable.
- Or switch to DNS_TXT with a domain you control at any registrar and add the TXT record manually.
- Click Next after verification succeeds.
- VPC settings: If testing the private EC2 instance directly, select the VPC and subnets from the Terraform deployment
- CloudWatch logs: Select or let the agent create a log group
- Service access: Use the default IAM role (recommended)
- Click Save to enable penetration testing
- In the AWS Console, navigate to your Agent Space and click Admin access to open the web application
- In the left sidebar, click Penetration Test
- Click Create your first penetration test
- Configure the test:
- Select the verified domain as the target
- Select the IAM role and log group
- (Optional) Enable automatic code remediation to have the agent create PRs with fixes
- Click Next
- (Optional) If the app requires login, provide credentials in the Agent Space login prompt:
- Username:
admin, Password:admin123(from the demo app's sample data)
- Username:
- (Optional) Upload additional context files (e.g., the
design-review/AnyBank Digital Portal Design Document.docx) - Click Create and execute
Note: The penetration test can take up to several hours to complete. You can monitor progress in real-time on the test detail screen.
Once the penetration test completes:
- Navigate to the penetration test detail screen
- Review findings organized by severity
| Severity | Expected Findings |
|---|---|
| Critical | SQL Injection in search and login endpoints, hardcoded credentials, SSRF, insecure deserialization |
| High | XSS in search, IDOR in profile access, path traversal in file upload, unencrypted storage |
| Medium | Weak session management, verbose error messages, missing security headers, debug mode enabled |
You can also test vulnerabilities manually before running the Security Agent. Set TARGET to either pentest.<your-domain> (if you used Route 53) or the raw ALB DNS name:
export TARGET="$(cd pen-test/terraform && terraform output -raw alb_dns_name)"
# SQL Injection
curl "http://$TARGET/search?q=' OR '1'='1"
# IDOR - Access another user's profile
curl "http://$TARGET/profile?token=1"
curl "http://$TARGET/profile?token=2"
# Unauthenticated API - Exposes sensitive data
curl "http://$TARGET/api/users"For full details, see pen-test/README.md.
| Resource | Demo | Approximate Cost |
|---|---|---|
| NAT Gateway | Demo 3 | ~$32/month |
| ALB | Demo 3 | ~$16/month |
| RDS db.t3.micro | Demo 3 | ~$15/month |
| EC2 t3.micro | Demo 3 | ~$7/month |
| Lambda | Demo 2 | Pay per invocation |
| API Gateway | Demo 2 | Pay per request |
| S3 | Demo 2 | < $1/month |
| Total (all running) | ~$70/month |
Recommendation: Destroy infrastructure immediately after demos.
Note: The above values are indicative only, real values may differ based on usage.
cd github-review/terraform
terraform destroycd pen-test/terraform
terraform destroyNote: Verify all resources are destroyed by checking the AWS Console. NAT Gateways and Elastic IPs may take a few minutes to release.
- Navigate to AWS Security Agent in the AWS Console
- Delete any penetration test configurations
- Optionally delete the Agent Space if no longer needed
| Resource | Link |
|---|---|
| Testing & Verification Guide | TESTING.md |
| AWS Security Agent Documentation | User Guide |
| AWS Security Agent Setup | Setup Guide |
| Design Review Guide | Create a Design Review |
| Penetration Testing Quickstart | Quickstart Guide |
| Amazon Bedrock Documentation | User Guide |
| Amazon Bedrock Model Access | Enable Models |
| Terraform AWS Provider | Documentation |
| OWASP Top 10 | Project Page |
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.





