All Tools View Categories About Contact Privacy

AWS SAM Template IAM Policy Generator

Generate a SAM Policies: block — from a curated policy template, or a custom IAM policy.

Generates a starting-point Resources.MyFunction snippet — merge the Policies: block into your real function before deploying. Runs entirely in your browser.

SAM Policy Templates are the AWS-recommended simpler approach for common access patterns. Use custom mode when you need full control.


  

About AWS SAM Template IAM Policy Generator

AWS SAM Template IAM Policy Generator produces the Policies: section of an AWS::Serverless::Function resource in two modes. SAM Policy Templates mode lets you pick from a curated list of real, published SAM policy templates — S3ReadPolicy, S3CrudPolicy, DynamoDBReadPolicy, DynamoDBCrudPolicy, SQSPollerPolicy, CloudWatchPutMetricPolicy, and more — fill in the one or two parameters each requires (like a bucket or table name), and get the correct YAML with zero hand-written IAM JSON. This is the AWS-recommended approach for common access patterns.

Custom policy mode takes a full IAM policy document you paste and embeds its Statement array as inline JSON directly under Policies:, alongside a Version line — SAM accepts a complete IAM policy document object as a Policies list entry, not only a template name or managed policy ARN. This gives full control for anything a template does not cover: multiple resources, explicit Denies, custom Conditions, or actions no template exposes.

Both modes produce a starting-point Resources.MyFunction snippet with placeholder Handler/Runtime values — merge the Policies: block into your real function's properties.

Features

  • SAM Policy Templates mode — curated, name-verified templates with their required parameters.
  • Custom policy mode — paste any IAM policy JSON, embedded inline under Policies:.
  • One toggle switches between the two modes without losing your input.
  • Parameter placeholders so you always get valid YAML even before filling every field.
  • Works on any valid JSON in custom mode, with a structural warning if it does not look like a complete IAM policy.
  • One-click copy of the generated YAML.
  • 100% client-side — nothing is uploaded.

How to Use

  1. Choose a mode — SAM Policy Templates or Custom policy.
  2. Templates mode: pick a template from the dropdown and fill in its parameter(s).
  3. Custom mode: paste your policy JSON, or click the sample.
  4. Click Generate.
  5. Copy the YAML and merge the Policies: block into your real function.

Examples

Example 1 — template mode. Picking S3ReadPolicy with bucket name my-bucket produces Policies: - S3ReadPolicy: BucketName: my-bucket.

Example 2 — custom mode. Pasting a policy with an S3 read statement produces Policies: - Version: '2012-10-17' Statement: [{"Effect":"Allow","Action":"s3:GetObject","Resource":"*"}].

Benefits

  • Points you to the simpler AWS-recommended approach first, with custom JSON as a fallback.
  • Correct SAM template names and parameters, not guessed.
  • Preserves custom policies exactly via inline JSON.
  • Private — generation runs entirely in your browser.

Frequently Asked Questions

Should I use a SAM Policy Template or a custom inline policy?
SAM Policy Templates are the AWS-recommended approach for common access patterns (read-only S3 access, CRUD on a DynamoDB table, polling an SQS queue, and similar) — they need no hand-written IAM JSON, just the resource name. Reach for a custom inline policy when you need something a template does not cover: multiple resources in one statement, a Deny, custom Conditions, or actions no template exposes.
Are the listed SAM Policy Template names real?
Yes — <code>S3ReadPolicy</code>, <code>S3CrudPolicy</code>, <code>S3WritePolicy</code>, <code>DynamoDBReadPolicy</code>, <code>DynamoDBCrudPolicy</code>, <code>SQSPollerPolicy</code>, and <code>CloudWatchPutMetricPolicy</code> are all published AWS SAM Policy Templates. This tool only lists templates it is confident are real, rather than guessing at plausible-sounding names — so it is not an exhaustive list of every SAM policy template that exists.
What does the custom policy mode generate?
It embeds your full pasted IAM policy document's <code>Statement</code> array as inline JSON directly under <code>Policies:</code>, alongside a <code>Version</code> line — SAM accepts a full IAM policy document object as a <code>Policies</code> list entry, not just a template name or managed policy ARN string. JSON is valid YAML, so this reproduces your policy exactly.
Is this generated SAM template ready to deploy as-is?
It is a starting-point <code>Resources.MyFunction</code> snippet, not a complete deployable template — <code>MyFunction</code>, the <code>Handler</code>, and the <code>Runtime</code> are placeholders. Merge the <code>Policies:</code> block into your actual function's properties and adjust the handler/runtime to match your project.
Does it validate that my custom-mode JSON is a well-formed IAM policy first?
It only requires valid JSON to generate the snippet. If the parsed JSON does not look like a complete IAM policy it still converts, but shows a structural warning above the output.
Is my policy JSON uploaded anywhere?
No — parsing and YAML generation both run entirely in your browser.