How flosell/iam-policy-json-to-terraform works
Project type and purpose
• This is a hybrid open-source tool combining:
– A command-line interface (CLI) utility (iam-policy-json-to-terraform) written in Go
– A static web frontend (HTML/JS/CSS) that uses the same conversion logic compiled to JavaScript
– A minimal Go HTTP server (web/web.go) to serve the web UI locally
• The core purpose is to convert AWS IAM Policy documents in JSON into Terraform aws_iam_policy_document blocks.
File structure
• Top-level files
– iam-policy-json-to-terraform.go: CLI entrypoint
– converter/: Go package containing decode.go, convert.go, encode.go + unit tests
– web/: static frontend assets (HTML, CSS, JavaScript), TestCafe e2e tests, and web.go server
– scripts/: deployment and release automation (GitHub Pages, releases, README sanity tests)
– .github/workflows: CI pipelines (build, test, security scans)
– go script and go.mod: central build/test tool
• Patterns
– Library-core (converter) is reused by both CLI and web
– Separation of concerns:
• Core conversion logic (Go package)
• CLI wrapper
• Web UI (static assets + compiled JS)
• Deployment artifacts
– CLI binary for multiple platforms (built via CI, released to GitHub)
– Static site published to GitHub Pages
Review README insights
• Describes both CLI usage (stdin/stdout) and web deployment
• Defines development workflow via ./go commands for building, testing, linting, web build, and deploy
• Mentions TestCafe e2e tests in web_test.js and browser automation for visual regression
Elements
• CLI application
• Web UI (static assets + JS converter)
• Conversion library (converter package)
• Local HTTP server (web/web.go)
• CI/CD pipeline (GitHub Actions)
• Hosting (GitHub Pages, GitHub Releases)
• Data flow from user input → converter → output
• Build flow from source code → binaries/JS → deployment targets
• Test flows (unit tests, e2e tests)
• Core logic (e.g., blue)
• Interfaces (e.g., green)
• Infrastructure/CI (e.g., orange)
– Annotations for key scripts and workflows (e.g., ./go web-build, scripts/deploy-github-pages.sh)
Detail
– Capture every layer: source code, build steps, interfaces, and deployments
– Reflect the reuse of the converter package in both CLI and web contexts
– Show how GitHub Actions automate testing and publishing