All Tools View Categories About Contact Privacy

Resource-Based Policy Generator

Build a Lambda, SNS or SQS resource policy — service or account principal, correct default action, and Source ARN/Account scoping.

Runs entirely in your browser — resource ARNs and account IDs never leave this page.
This grants any resource of this AWS service, in any account, the permission — no Source ARN or Source Account restricts it. Add one unless that is intentional.
0
statements
0
allow
-
scoped
-
structurally valid

  

About Resource-Based Policy Generator

Lambda, SNS and SQS all support attaching a policy directly to the resource itself, so some other principal — an AWS service reacting to an event, or another AWS account — can invoke, publish to, or send to it without that principal needing an identity-based policy of its own. The three services use the same JSON shape for this, differing only in which action goes in the statement. Resource-Based Policy Generator builds that shared shape for whichever of the three you pick, with the one check that matters most for this kind of policy built in: whether a service-principal grant is actually scoped to your resource, or left open to any account’s matching resource.

You choose the service (Lambda, SNS, or SQS), enter the ARN of the resource the policy will attach to, and pick a principal: either an AWS service principal — s3.amazonaws.com triggering a Lambda function, events.amazonaws.com for an EventBridge rule, or any other service principal you type in — or a specific AWS account/role ARN for cross-account access. The action defaults to the one thing each service’s resource policy is almost always used for (lambda:InvokeFunction, sns:Publish, sqs:SendMessage), with room to override it if you need a different action.

The real logic in this tool is the scoping check. Granting a broad service principal like s3.amazonaws.com permission with no further restriction does not just allow your own S3 bucket to invoke your Lambda function — taken literally, it allows any S3 bucket in any AWS account to do so, because the principal is the S3 service as a whole, not a specific bucket. This is a documented, well-known pitfall with Lambda and SNS/SQS resource policies, sometimes called the confused-deputy problem. The tool offers two optional conditions to close it: a Source ARN field (rendered as an ArnLike condition on aws:SourceArn) that restricts the grant to one specific triggering resource, and a Source Account field (rendered as StringEquals on aws:SourceAccount) that restricts it to one specific account. After you build a statement, the tool inspects the resolved principal and condition block and shows a warning — computed from what you actually built, not a static disclaimer — whenever the principal is a service principal and neither scoping condition is present. Adding either condition, or switching to a specific account/role principal instead of a service principal, clears the warning because the underlying condition genuinely changes.

Once assembled, the statement is wrapped in a policy document and run through the same structural validator used across these tools: Version present, Statement non-empty, each statement carrying a recognized Effect, an Action, and a Resource or Principal. That, together with the scoping check, is the complete scope of what is verified — nothing here calls the AWS API, confirms the resource ARN you entered actually exists, or accounts for other statements already attached to the resource.

The output is a ready-to-attach resource policy JSON document with stat cards summarizing the statement, a clear warning when a service-principal grant is left unscoped, and Copy/Download actions — built entirely in your browser, with resource ARNs and account IDs never leaving the page.

Features

  • One form for Lambda, SNS and SQS resource policies — pick the service, get the right default action.
  • Service-principal or cross-account principal support.
  • Real unscoped-principal warning — computed from whether a Source ARN/Account condition is actually present.
  • Source ARN (aws:SourceArn) and Source Account (aws:SourceAccount) condition builder.
  • Per-service default action (InvokeFunction / Publish / SendMessage) with override.
  • Structural validation on the assembled statement and document.
  • Pretty-printed JSON output with Copy and Download .json.
  • Realistic sample (S3-triggers-Lambda, properly scoped) pre-fills the form.
  • One-click clear.
  • 100% client-side — resource ARNs and account IDs never leave the page.

How to Use

  1. Pick the service — Lambda, SNS, or SQS.
  2. Enter the resource ARN the policy attaches to (the function, topic, or queue).
  3. Choose a principal type — AWS service or a specific account/role ARN — and enter its value.
  4. Review or override the action (a sensible default is pre-filled per service).
  5. Optionally add Source ARN and/or Source Account to scope a service-principal grant.
  6. Click Build resource policy and read the unscoped-principal warning if it appears.
  7. Copy or download the resulting JSON to attach to your resource.

Examples

Example 1 — S3 triggers Lambda, properly scoped. Service Lambda, principal s3.amazonaws.com, resource arn:aws:lambda:us-east-1:123456789012:function:thumbnail-generator, Source ARN arn:aws:s3:::uploads-bucket, Source Account 123456789012 — no warning, since both conditions scope the grant.

Example 2 — same trigger, left unscoped. Same as above with Source ARN and Source Account both blank — the unscoped-principal warning appears, correctly flagging that any bucket in any account could invoke the function.

Example 3 — cross-account SNS publish. Service SNS, principal type account, value arn:aws:iam::222222222222:root, resource arn:aws:sns:us-east-1:123456789012:orders-topic — account principals are never flagged by the service-principal check, since they already name a specific account.

Example 4 — EventBridge invokes SQS. Service SQS, principal events.amazonaws.com, resource arn:aws:sqs:us-east-1:123456789012:alerts-queue, Source ARN arn:aws:events:us-east-1:123456789012:rule/nightly-check — scoped to one specific rule.

Example 5 — overriding the default action. Service SQS with the action field changed from the default sqs:SendMessage to sqs:SendMessage,sqs:GetQueueAttributes for a principal that also needs to read queue attributes.

Benefits

  • One consistent form for three different services’ resource policies.
  • Catches the confused-deputy pitfall with a real, computed warning instead of relying on memory.
  • Correct default action per service, no guessing action names.
  • Structural validation before you attach the policy.
  • Copy or download straight into the console or IaC.
  • Private — resource ARNs and account IDs never leave your browser.

Frequently Asked Questions

What is a resource-based policy, and how is it different from an IAM policy?
An IAM (identity-based) policy is attached to a user or role and says what that identity can do. A resource-based policy is attached directly to the resource — a Lambda function, an SNS topic, an SQS queue — and says who (the <code>Principal</code>) is allowed to act on it. This tool builds the second kind, in the shape Lambda, SNS and SQS all share: one statement naming a principal, an action, and (implicitly) the resource it is attached to.
Why does the tool warn about "unscoped service principal"?
When the principal is a broad AWS service principal like <code>s3.amazonaws.com</code> or <code>events.amazonaws.com</code> with no <code>aws:SourceArn</code> or <code>aws:SourceAccount</code> condition, the statement allows a matching event from <em>any</em> account’s resource of that service to invoke yours — not just your own bucket or rule. This is a well-known AWS resource-policy pitfall (the confused-deputy problem), and the check is computed from the actual statement: adding a source ARN or source account condition clears it immediately.
What are Source ARN and Source Account for?
They scope a service-principal grant to one specific triggering resource. Source ARN (rendered as an <code>ArnLike</code> condition on <code>aws:SourceArn</code>) restricts it to a specific bucket, rule, or topic ARN. Source Account (rendered as <code>StringEquals</code> on <code>aws:SourceAccount</code>) restricts it to a specific AWS account. Either narrows the grant; using both is the tightest and is what AWS itself recommends for S3-to-Lambda and EventBridge-to-target triggers.
How are the default actions chosen per service?
Lambda defaults to <code>lambda:InvokeFunction</code>, SNS to <code>sns:Publish</code>, SQS to <code>sqs:SendMessage</code> — the single action each service actually needs a resource policy for in the overwhelming majority of cases. You can override the action list with your own comma-separated values if a less common action is needed.
Can the principal be another AWS account instead of a service?
Yes — switch principal type to "AWS account or role ARN" and enter the ARN. This is the shape used for cross-account access, such as letting a partner account’s role publish to your SNS topic or send to your SQS queue.
Does this tool know the actual account ID or ARN of my Lambda function/topic/queue?
No — you supply the resource ARN yourself. Nothing here looks up or verifies that the resource exists; it only assembles and validates the policy document you would attach to it.
Does it validate against AWS's live resource-policy size limits or grammar?
No. It runs the same structural check as the other policy tools here (Version present, Statement non-empty, each statement has a valid Effect, an Action, and a Resource or Principal) plus the unscoped-service-principal check described above — it does not call any AWS API.
Can I build more than one statement?
This tool builds one statement per submission, matching how Lambda/SNS/SQS resource policies are usually built incrementally (one trigger, one statement). For multiple statements, build each here and combine the <code>Statement</code> arrays by hand, or use the general-purpose IAM Policy JSON Generator.
Is anything I enter uploaded?
No. Principal assembly, condition building, and validation all run locally in your browser — resource ARNs and account IDs never leave the page.
Can I export the result?
Yes — Copy as JSON and Download .json buttons appear once a policy is built.