This project deploys a secure, serverless incident response chatbot using AWS infrastructure managed via modular Terraform. The chatbot responds to commands like logs
, guardduty
, and help
by querying CloudWatch and GuardDuty from a Lambda function running in a private subnet.
- Serverless chatbot with AWS Lambda
- Secure HTTPS API using API Gateway (no key required)
- Lambda runs inside a private subnet (no public IP)
- NAT Gateway routes outbound requests
- Retrieves CloudWatch logs (last 10 min)
- GuardDuty integration (returns threat status)
- Easy to extend (
login
,status
, etc.) - Infrastructure-as-Code using modular Terraform
- A user sends a POST request to API Gateway.
- API Gateway invokes the Lambda function in a private subnet.
- Lambda uses the NAT Gateway to securely reach CloudWatch and GuardDuty.
- Lambda responds with real-time system and security insights.
secure-incident-response-chatbot/
βββ main.tf
βββ variables.tf
βββ outputs.tf
βββ README.md
βββ LICENSE
βββ .gitignore
βββ modules/
β βββ lambda/
β β βββ main.tf
β β βββ variables.tf
β β βββ outputs.tf
β βββ iam/
β β βββ main.tf
β β βββ outputs.tf
β βββ api-gateway/
β β βββ main.tf
β β βββ variables.tf
β β βββ outputs.tf
β βββ vpc/
β βββ main.tf
β βββ variables.tf
β βββ outputs.tf
βββ src/
β βββ handler.py
β βββ lambda.zip
βββ assets/
βββ incident-bot-success.png
βββ lambda-curl-logs.png
βββ guardduty-success.png
βββ secure-architecture-diagram.png
βββ final-network-diagram.png
**Command-line test (Windows CMD or PowerShell):**
curl -X POST https://<your-api-url>/incident -H "Content-Type: application/json" -d "{"query": "logs"}"
curl -X POST https://<your-api-url>/incident -H "Content-Type: application/json" -d "{"query": "guardduty"}"
curl -X POST https://<your-api-url>/incident -H "Content-Type: application/json" -d "{"query": "help"}"
Example output:
π Recent logs:
INIT_START Runtime Version: python:3.11.v76
START RequestId: ...
Event received: { ... }
- Lambda timeouts Fixed by adjusting timeout + narrowing CloudWatch query window
- IAM permission errors Resolved by refining trust and execution policies
- GuardDuty not enabled Activated manually in
us-east-1
- Module input issues Declared
subnet_ids
andvpc_id
inlambda
module - Security Group conflict Fixed by destroying and recreating stale SG
These challenges helped reinforce advanced Terraform troubleshooting, VPC networking, and AWS service integration.
This project is licensed under the MIT License
Roberto A Cardenas
Cloud Engineer β’ IaC Builder β’ AWS Infrastructure Developer
Feature | Screenshot |
---|---|
Curl Commands | ![]() |
CloudWatch Logs | ![]() |
GuardDuty Status | ![]() |
Built for security. Powered by AWS. Managed with Terraform.