Small tool to convert an IAM Policy in JSON format into a Terraform aws_iam_policy_document
$ brew install iam-policy-json-to-terraform
Download the latest binary from the releases page and put it into your PATH
under the name iam-policy-json-to-terraform
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
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
-
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
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