https://github.com/cloud-copilot/iam-convert
Convert JSON IAM Policies to other formats
https://github.com/cloud-copilot/iam-convert
Last synced: about 1 month ago
JSON representation
Convert JSON IAM Policies to other formats
- Host: GitHub
- URL: https://github.com/cloud-copilot/iam-convert
- Owner: cloud-copilot
- License: agpl-3.0
- Created: 2025-01-25T22:22:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-02-14T18:01:11.000Z (4 months ago)
- Last Synced: 2026-02-15T01:47:04.665Z (4 months ago)
- Language: TypeScript
- Homepage: https://iam.cloudcopilot.io/tools/iam-convert
- Size: 835 KB
- Stars: 25
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# iam-convert: Convert JSON Policy Documents to Infrastructure as Code
[](https://www.npmjs.com/package/@cloud-copilot/iam-convert) [](LICENSE.txt) [](https://github.com/cloud-copilot/iam-convert/actions/workflows/guarddog.yml) [](https://snyk.io/test/github/cloud-copilot/iam-convert?targetFile=package.json)
CLI and Node Library to convert JSON IAM Policy Documents to other formats for Infrastructure as Code.
## Available Formats
- Terraform (tf) - an [aws_iam_policy_document](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) data source
- CloudFormation (cf) - a [PolicyDocument](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-policy.html) resource in yaml
- Typescript CDK (cdk-ts) - an [iam.PolicyDocument](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.PolicyDocument.html) from AWS CDK V2 aws-cdk-lib/aws-iam
- Python CDK (cdk-py) - a [PolicyDocument](https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_iam/PolicyDocument.html) using AWS CDK V2 aws_cdk.aws_iam
## Use in Browser
[https://iam.cloudcopilot.io/tools/iam-convert](https://iam.cloudcopilot.io/tools/iam-convert)
## Installation
```bash
# Install the CLI
npm install -g @cloud-copilot/iam-convert
## Install the Node Library
npm install @cloud-copilot/iam-convert
```
## CLI Usage
```bash
# Convert a JSON policy document to terraform and send to stdout
iam-convert --file path/to/policy.json
# Download a policy and convert it to terraform
curl "https://government-secrets.s3.amazonaws.com/secret-policy.json" | iam-convert > secret-policy.tf
# View all options
iam-convert --help
```
## Typescript/Javascript Usage
```typescript
import { convert } from '@cloud-copilot/iam-convert'
import { loadPolicy } from '@cloud-copilot/iam-policy'
const policy = {
Version: '2012-10-17',
Statement: [
{
Effect: 'Allow',
Action: 's3:GetObject',
Resource: 'arn:aws:s3:::my-bucket/*'
}
]
}
const terraformDataSource = convert(policy, 'tf')
console.log(terraformDataSource)
```