• Stars
    star
    737
  • Rank 59,285 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

iam-policy-json-to-terraform

Build Status

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

Web Version

Check out a web version of the tool here.

For command line usage and automation, check out the instructions below.

Installation

OSX

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

asdf

$ asdf plugin add iam-policy-json-to-terraform https://github.com/carlduevel/asdf-iam-policy-json-to-terraform.git

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

If a video demo is more your thing, checkout this nice 2min introduction by the folks at env0.

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

Entry point

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
seccheck                       Run security checks
test                           Run all tests
test-readme                    Run the commands mentioned in the README for sanity-checking
tools                          Install additional required tooling
tools-main                     Install additional required tooling for the main version
tools-web                      Install additional required tooling for the web version
web-build                      Build the web version
web-deploy                     Deploy the web version to GitHub pages
web-e2e                        Run end to end tests for web version (requires web-build)
web-e2e-live                   Run end to end tests for web version in live mode for development (requires web-build)
web-serve                      Serve the web version on a local development server
web-visual-regression-approve  Accept changes in Web UI visuals
web-visual-regression-test     Test for changes in Web UI visuals

Web Development

To develop the web-frontend, you'll need to first compile the JavaScript version of iam-policy-json-to-terraform. make web-build will do that, generating a web.js file. Include it and it'll expose a convert(policyName,jsonString) function in the global namespace.

Currently, the complete web-frontend is plain HTML, JS and CSS, all within web/index.html. Edit or refine as needed.

End-To-End Tests for the web frontend exist as TestCafe tests in web_test.js and can be run using make web-e2e.

More Repositories

1

trailscraper

A command-line tool to get valuable information out of AWS CloudTrail
Python
756
star
2

lambdacd

a library to define a continuous delivery pipeline in code
Clojure
673
star
3

terraform-sqs-lambda-trigger-example

Example on how to create a AWS Lambda triggered by SQS in Terraform
HCL
48
star
4

diy-vpn

Create your own OpenVPN instance hosted on DigitalOcean or Rackspace
Ruby
21
star
5

lambdacd-git

Git support for LambdaCD
Clojure
18
star
6

iamspec

[WIP/PoC] RSpec Tests for AWS IAM using the AWS Policy Simulator - inspired by serverspec.
Ruby
17
star
7

pinboard-chrome-bookmark-sync

A Chrome extension to keep your bookmarks in sync between browser and pinboard.in - Bookmark Folders can be any combination of tags, not just one tag
JavaScript
11
star
8

lambdacd-artifacts

provides a way to access build artifacts generated by a step in LambdaCD
Clojure
5
star
9

lambdacd-value-stream

A library that adds upstream and downstream triggers to LambdaCD
Clojure
4
star
10

lambdacd-cctray

cctray support for lambdacd
Clojure
3
star
11

lambdacd-cookie-cutter-pipeline-example

example on how to use lambdacd to generate several instances of the same pipeline-template
Clojure
3
star
12

ultimate-go-script

This repository contains a template go-script for you to use in your project root to have a common entry-point for your project tooling.
Shell
2
star
13

gascripts-sync

[UNMAINTAINED] tool to synchronize Google App Scripts projects to the local machine to work on them from there
Ruby
2
star
14

lambdacd-demo-pipeline

Complete, deployable LambdaCD demo project with AWS infrastructure
Clojure
2
star
15

flosell.github.io

My blog
SCSS
1
star
16

lambdacd-pipeline-structure-refactoring-example

Example on how to refactor LambdaCD pipelines
Clojure
1
star
17

devops-101-lambdacd

continuous delivery infrastructure in pure code
Clojure
1
star
18

lambdacd-template

leiningen template to generate LambdaCD projects
Clojure
1
star
19

clj-timeframes

A small library to merge overlapping clj-time intervals
Clojure
1
star