Generate AWS IAM policies via chat interface with GPT-4 assistant
Workflow preview
$20/month : Unlimited workflows
2500 executions/month
THE #1 IN WEB SCRAPING
Scrape any website without limits
HOSTINGER
Early Deal
DISCOUNT 20% Try free
DISCOUNT 20%
Self-hosted n8n
Unlimited workflows - from $4.99/mo
#1 hub for scraping, AI & automation
6000+ actors - $5 credits/mo
Important notice
This workflow is provided as-is. Please review and test before using in production.
Overview
Chat-Based AWS IAM Policy Generator with OpenAI Agent
> Chat-driven workflow that lets IT and DevOps teams generate custom AWS IAM policies via AI, automatically apply them to AWS, and send an email notification with policy details.
π€ Whoβs it for
This workflow is designed for:
- Cloud Engineers / DevOps who need to quickly generate and apply custom IAM policies in AWS.
- IT Support / Security teams who want to create IAM policies through a chat-based interface without manually writing JSON.
- Teams that want automatic notifications (via email) once new policies are created.
βοΈ How it works / What it does
- Trigger β Workflow starts when a chat message is received.
- IAM Policy Creator Agent β Uses OpenAI to:
- Interpret user requirements (e.g., service, actions, region).
- Generate a valid IAM policy JSON following AWS best practices.
- IAM Policy HTTP Request β Sends the generated policy to AWS IAM CreatePolicy API.
- Email Notification β Once AWS responds with a
CreatePolicyResponse, an email is sent with policy details (name, ARN, ID, timestamps, etc.) using n8n mapping.
Result: The user can chat with the AI agent, create a policy, and receive an email confirmation with full details.
π How to set up
Chat Trigger Node
- Configure the
When chat message receivednode to connect your preferred chat channel (Slack, MS Teams, Telegram, etc.).
- Configure the
IAM Policy Creator Agent
- Add OpenAI Chat Model as the LLM.
- Use a system prompt that enforces AWS IAM JSON best practices (least privilege, correct JSON structure).
- Connect Memory (Simple Memory) and Structured Output Parser to ensure consistent JSON output.
IAM Policy HTTP Request
- Set method:
POST - URL:
https://iam.amazonaws.com/ - Add authentication using AWS Signature v4 (Access Key + Secret Key).
- Body:
Action=CreatePolicyPolicyName={{ $json.CreatePolicyResponse.CreatePolicyResult.Policy.PolicyName }}PolicyDocument={{ $json.policyDocument }}Version=2010-05-08
- Set method:
Email for tracking
π Requirements
- n8n instance (self-hosted or cloud).
- AWS IAM user/role with permission to
iam:CreatePolicy. - AWS Access Key + Secret Key (for SigV4 signing in HTTP request).
- OpenAI API key (for the Chat Model).
- Email server credentials (SMTP or provider integration).
π¨ How to customize the workflow
- Restrict services/actions β Adjust the IAM Policy Creator Agent system prompt to limit what services/policies can be generated.
- Notification channels β Replace the email node with Slack, MS Teams, or PagerDuty to alert other teams.
- Tagging policies β Modify the HTTP request to include
Tagswhen creating policies in AWS. - Human-readable timestamps β Add a Function or Set node to convert
CreateDateandUpdateDatefrom Unix epoch to ISO datetime before sending emails. - Approval step β Insert a manual approval node before sending the policy to AWS for compliance workflows.