{"id":35119097,"url":"https://github.com/cloud-copilot/iam-simulate","last_synced_at":"2026-05-10T21:23:21.223Z","repository":{"id":269477732,"uuid":"869253404","full_name":"cloud-copilot/iam-simulate","owner":"cloud-copilot","description":"An IAM Simulator that outputs detailed explains of how a request was evaluated.","archived":false,"fork":false,"pushed_at":"2025-12-22T00:52:15.000Z","size":871,"stargazers_count":95,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-23T00:48:32.620Z","etag":null,"topics":["aws","iam"],"latest_commit_sha":null,"homepage":"https://iam.cloudcopilot.io/tools/policy-tester","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloud-copilot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-08T01:41:12.000Z","updated_at":"2025-12-22T00:52:18.000Z","dependencies_parsed_at":"2024-12-23T21:24:30.214Z","dependency_job_id":"6aea3610-3a32-4c96-aae7-7b71fe904a11","html_url":"https://github.com/cloud-copilot/iam-simulate","commit_stats":null,"previous_names":["cloud-copilot/iam-simulate"],"tags_count":69,"template":false,"template_full_name":null,"purl":"pkg:github/cloud-copilot/iam-simulate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud-copilot%2Fiam-simulate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud-copilot%2Fiam-simulate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud-copilot%2Fiam-simulate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud-copilot%2Fiam-simulate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloud-copilot","download_url":"https://codeload.github.com/cloud-copilot/iam-simulate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud-copilot%2Fiam-simulate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28002250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","iam"],"created_at":"2025-12-27T23:00:27.662Z","updated_at":"2026-02-22T16:36:15.759Z","avatar_url":"https://github.com/cloud-copilot.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IAM Simulate\n\n[![NPM Version](https://img.shields.io/npm/v/@cloud-copilot/iam-simulate.svg?logo=nodedotjs)](https://www.npmjs.com/package/@cloud-copilot/iam-simulate) [![License: AGPL v3](https://img.shields.io/github/license/cloud-copilot/iam-simulate)](LICENSE.txt) [![GuardDog](https://github.com/cloud-copilot/iam-simulate/actions/workflows/guarddog.yml/badge.svg)](https://github.com/cloud-copilot/iam-simulate/actions/workflows/guarddog.yml) [![Known Vulnerabilities](https://snyk.io/test/github/cloud-copilot/iam-simulate/badge.svg?targetFile=package.json\u0026style=flat-square)](https://snyk.io/test/github/cloud-copilot/iam-simulate?targetFile=package.json)\n\nAn AWS IAM Simulator and Policy Tester built as a Node/Typescript library.\n\nThe simulator currently supports these features of AWS IAM\n\n### IAM Feature Support\n\n- Identity Policies\n- Resource Policies\n- Service Control Policies\n- Resource Control Policies\n- Permission Boundaries\n- All [AWS Condition Operators](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html)\n- Same Account and Cross Account Requests\n- Custom trust behavior for IAM Trust Policies and KMS Key Policies\n\n### Request Validation\n\niam-simulate will automatically validate inputs including\n\n- IAM policies using [iam-policy](https://github.com/cloud-copilot/iam-policy)\n- IAM Actions using [iam-data](https://github.com/cloud-copilot/iam-data)\n- The resource ARN against allowed resource types for the action\n- The context keys allowed for the action/resource and their types.\n\nCurrently all [global condition keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html) are allowed for all requests which is not strictly true. More validation will be added in the future.\n\n### Explanation\n\niam-simulate will detail which statements were decisive in the final decision to allow or deny a request.\n\nIt will also return \"explains\" for each statement that was evaluated, detailing why that statement applied to the request or not.\n\n### Features Coming Soon\n\n- Session Policies\n- Validation of Global Condition Keys for each action\n- Automatically populating context keys from the request such as `aws:PrincipalServiceName`\n- Support for anonymous requests\n\n## Installation\n\n```bash\nnpm install @cloud-copilot/iam-simulate\n```\n\n## Usage\n\n```typescript\nimport { runSimulation, type Simulation } from '@cloud-copilot/iam-simulate'\n\nconst simulation: Simulation = {\n  identityPolicies: [\n    {\n      name: 'userpolicy',\n      policy: {\n        Version: '2012-10-17',\n        Statement: [\n          {\n            Effect: 'Allow',\n            Action: ['s3:GetObject'],\n            Resource: ['arn:aws:s3:::mybucket/*']\n          }\n        ]\n      }\n    }\n  ],\n  serviceControlPolicies: [\n    {\n      orgIdentifier: 'ou-12345',\n      policies: [\n        {\n          name: 'AllowAll',\n          policy: {\n            Version: '2012-10-17',\n            Statement: [\n              {\n                Effect: 'Allow',\n                Action: '*',\n                Resource: '*'\n              }\n            ]\n          }\n        }\n      ]\n    }\n  ],\n  /*\n    The default RCP `RCPFullAWSAccess` is always applied implicitly and you do not need to include it here. https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps_examples.html#example-rcp-full-aws-access\n  */\n  resourceControlPolicies: [\n    {\n      orgIdentifier: 'o-123456789012',\n      policies: [\n        {\n          name: 'EnforceSecureTransport',\n          policy: {\n            Version: '2012-10-17',\n            Statement: [\n              {\n                Sid: 'EnforceSecureTransport',\n                Effect: 'Deny',\n                Principal: '*',\n                Action: ['sts:*', 's3:*', 'sqs:*', 'secretsmanager:*', 'kms:*'],\n                Resource: '*',\n                Condition: {\n                  BoolIfExists: {\n                    'aws:SecureTransport': 'false'\n                  }\n                }\n              }\n            ]\n          }\n        }\n      ]\n    }\n  ],\n  resourcePolicy: {\n    Version: '2012-10-17',\n    Statement: [\n      {\n        Effect: 'Allow',\n        Action: ['s3:GetObject'],\n        Resource: ['arn:aws:s3:::mybucket/*'],\n        Principal: 'aws:arn:iam::123456789012:root',\n        Condition: {\n          StringEquals: {\n            'aws:PrincipalOrgID': 'o-123456789012'\n          }\n        }\n      }\n    ]\n  },\n  request: {\n    action: 's3:GetObject',\n    principal: 'arn:aws:iam::123456789012:user/username',\n    resource: {\n      accountId: '123456789012',\n      resource: 'arn:aws:s3:::mybucket/file.txt'\n    },\n    contextVariables: {\n      'aws:PrincipalOrgID': 'o-123456789012'\n    }\n  }\n}\n\n`runSimulation` returns a discriminated union with `resultType`:\n\n- `resultType: 'error'` includes `errors` and no simulation results.\n- `resultType: 'single'` includes `overallResult` and a single `result`.\n- `resultType: 'wildcard'` includes `overallResult` and `results` for each matching pattern.\n\nconst response = await runSimulation(simulation, {})\n//Check for validation errors (errors are returned at the response level):\nif (response.resultType === 'error') {\n  console.log(response.errors.message)\n  console.log(JSON.stringify(response.errors, null, 2))\n}\n\n//The simulation ran successfully\nif (response.resultType === 'single') {\n  const result = response.result\n  console.log(response.overallResult) // 'Allowed', 'ExplicitlyDenied', or 'ImplicitlyDenied'\n  console.log(result.analysis?.result)\n\n  //Output the identity statements that allowed the request\n  const identityAllowExplains =\n    result?.analysis?.identityAnalysis?.allowStatements.map((s) =\u003e s.explain) || []\n  //Show which statements applied and exactly how.\n  for (const explain of identityAllowExplains) {\n    console.log(explain)\n  }\n}\n\nif (response.resultType === 'wildcard') {\n  console.log(response.overallResult)\n  for (const result of response.results) {\n    console.log(result.resourcePattern, result.analysis?.result)\n  }\n}\n```\n\nThis would output an explain that shows how the identity statement was evaluated:\n\n```javascript\n{\n  effect: 'Allow',\n  identifier: '1',\n  matches: true,\n  actionMatch: true,\n  principalMatch: 'Match',\n  resourceMatch: true,\n  conditionMatch: true,\n  resources: [\n    {\n      resource: 'arn:aws:s3:::mybucket/*',\n      matches: true,\n    }\n  ],\n  actions: [ { action: 's3:GetObject', matches: true } ],\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud-copilot%2Fiam-simulate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloud-copilot%2Fiam-simulate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud-copilot%2Fiam-simulate/lists"}