terrawrap

command module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

README

Terrawrap

Generate Terraform modules for Hashicorp-maintained providers/resources.

Currently only supporting hashicorp/terraform-provider-aws provider resources.

Install

  1. Build it
    1. Clone this repository bin/terrawrap
    2. Build go build .
    3. Add the binary to the path (e.g. mv bin/terrawrap /usr/local/bin/terrawrap)
  2. via go install:
    # Note: This isn't working at the moment due to git LFS
    # see https://github.com/git-lfs/lfs-test-server/issues/98
    go install github.com/infracasts/terrawrap@latest
    

Usage

Terrawrap will append or create new files (main.tf, variables.tf, outputs.tf) in your specified output directory, depending on whether or not they exist already.

Terrawrap will only append data; never truncate or overwrite your existing data.

To get started, just specify a resource type to wrap:

momer:~/projects/terraform-modules/my-module$ bin/terrawrap generate -a "Mo Omer <mo@infracasts.com>" -o . aws_secretsmanager_secret
2022/09/05 12:04:11 appending to  /home/momer/projects/terraform-modules/my-module/main.tf
2022/09/05 12:04:11 appending to  /home/momer/projects/terraform-modules/my-module/variables.tf
2022/09/05 12:04:11 appending to  /home/momer/projects/terraform-modules/my-module/outputs.tf
Your new module is ready at 
/home/momer/projects/terraform-modules/my-module/

Support/caveats

  1. This project is specifically tailored currently to support the aws provider, and is a bit of a proof-of-concept/fun project.
    • As a result, individual resources' schemas are extracted via a fork of the hashicorp/terraform-provider-aws implementation. As the provider itself is not meant to be consumed externally (all schemas/provider details are in the internal package), a fork was necessary to expose required details.
  2. The AWS provider doesn't provide descriptions as part of its schema, so I walked the AST of the markdown documentation that Hashicorp provides as part of the hashicorp/terraform-provider-aws repo, and parsed it out via regexp.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL