Awesome Open Source
Awesome Open Source

iam-policy-json-to-terraform

Build StatusRelease

Small tool to convert an IAM Policy in JSON format into a Terraform aws_iam_policy_document

Installation

OSX

$ brew install iam-policy-json-to-terraform

Other

Download the latest binary from the releases page and put it into your PATH under the name iam-policy-json-to-terraform

Developer

If you're a go developer and have your GOPATH defined and have added your $GOPATH/bin directory to your path, you can simply run this command.

$ go get github.com/flosell/iam-policy-json-to-terraform

Usage

From raw JSON

$ echo '{"Statement":[{"Effect":"Allow","Action":["ec2:Describe*"],"Resource":"*"}]}' | iam-policy-json-to-terraform
data "aws_iam_policy_document" "policy" {
  statement {
    sid       = ""
    effect    = "Allow"
    resources = ["*"]
    actions   = ["ec2:Describe*"]
  }
}

From a JSON policy file

$ iam-policy-json-to-terraform < some-policy.json

Local development

Prerequisites

  • Clone the repository to a location of your choosing:

    $ git clone [email protected]:flosell/iam-policy-json-to-terraform.git
    
  • Install dependencies and tools:

    $ cd iam-policy-json-to-terraform
    $ make tools
    

Development

make is your primary point of entry for any development activity. Call it without arguments to learn more:

$ make
build                          Test and build the whole application
clean                          Remove build artifacts
fmt                            Format code
fmtcheck                       Run linter
test-readme                    Run the commands mentioned in the README for sanity-checking
test                           Run all tests
tools                          Install additional required tooling

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
go (15,341
hacktoberfest (4,274
aws (1,122
terraform (412
hcl (397
infrastructure-as-code (90
iam (48