Package: pterradactyl
PterradactylPterradactyl is a library developed to abstract TF configuration from the TF environment setup. Pterradactyl allows to create a hierarchy of TF environments/stacks, hallows an unconstrained number of cloud accounts and stacks to share inherited configuration.Currently, multiple TF stacks are managed through different TF environments and var files. But this becomes especially tricky to manage when the stacks are vastly different from one another, or even in the case of slightly different stacks, one could question the DRY principal looking at all the repeat vars in the var file! When stacks deviate from one another, by using just the var files, the TF code quickly becomes unreadable with all the conditionals. Using just environments based TF, there is always room of accidental apply of one stack to the other. You can use bash files to safegaurd against that but then there is always the old faithful way of doing by just completely skipping the bash file ! (#fun-stuff)Pterradactyl takes care of all the pain points described above.Table of contentSome of the Pterradactyl featuresInstallationUsageUnit TestsExamples of creating new projects/prodcutsPterradactyl Directory StructureComparison of other well-known Terraform wrappers:Some of the Pterradactyl features:Programatically generated Terraform code using hierarchical YAML files structure. Override only what you have to in your stack file and keep the rest in common YAML.Because Pterradactyl uses hierarchy, it becomes simple to provide standard structure to common attributes liketagsin a uniform manner.Secrets support usingsopsandAWS KMS.Keeps Terraform versions consistent between stacks.As the Terraform file is generated through Pterradactyl, there is no room for the funoverride:)Pterradactyl usesPhiera, to manage the YAML hierarchy configuration for a terraform code base.Integration of terraform with Phiera is achieved through Pterradactyl.A primer onHiera.Installation:From PyPi:pipinstallpterradactylFrom GitHub:pipinstallgit+https://github.com/Nike-Inc/pterradactyl#egg=pterradactylFrom sourceYou can always install it from wheel, by running the following commands:Build package and wheel.poetryinstallpoetrybuildInstallpython3-mpipinstalldist/*.whlOf course, you can always deploy the package to your corporate Artifactory.Usage:Pterradyctal supports all of the terraform commands.basic cliapply`ptapply<stack-name>`plan`ptplan<stack-name>`destroy`ptdestroy<stack-name>`graph`ptgraph<stack-name>`show`ptshow<stack-name>`Manipulating statePterradyctal supports all state commands and they follow the same argument patter as in TF, here are some examplesstatelist`ptstatelist<stack-name>`stateshow`ptstateshow<stack-name>-state<target>`staterm`ptstaterm<stack-name>-state<statefile>`Tests:Run unit testspoetryrunpytestRun unit tests with coverage report in HTML format.poetryrunpytest--cov-report=html--cov=pterradactyl--cov-fail-under=80tests/Examples of creating new projects/prodcuts:Basic ExamplehereModule setupAttribute overridingAdvanced ExamplehereCreate infrastructure for a new AWS accountCommon tag setupKMS encryptionRemote backendModule setupAttribute overridingPterradactyl Directory Structure:After runningpt applypterradactyl will create below directory structure,
containing downloaded given Terraform version with all required plugins, and workspace containing all metadata for your stack, e.g.:.pterradactyl
├── terraform
│     └── 0.13.1
│         ├── terraform
│         └── terraform-provider-kubectl_v1.13.1
└── workspace
    └── bt-projectc0-na-useast1
        ├── facts.json
        └── main.tf.jsonterraform - directory containing downloaded Terraform given version with downloaded plugins defined in pterra.yaml file.workspace - directory containing metadata information for you stack. Each stack has a separate workspace.facts.json - JSON file with facts generated by Pterradactyl (e.g. deploy_user, state_prefix, aws_account_alias)main.tf.json - metadata information file regarding providers (e.g. aws, kubernetes, helm), moduls (e.g. vpc, kms, eks)and terraform backend information.Comparison of other well-known Terraform wrappers:Terragrunt:Some of the key Terragrunt features:Execute Terraform commands on multiple modules at onceKeep your Terraform configuration DRYInputs set as env variables.Call custom actions using Before and After HooksWork with multiple AWS accountsLock File HandlingAWS Auth supportCaching folder where commands are being executed.Auto-retry e.g. when installing provider failed due to connection error.More infohereTerraspace:Some of the key Terraspace features:Build-in generatorsMultiple environmentsDeploy Multiple Stacks with a single commandBuild-in secrets support for AWS Secret Manager, AWS SSM Parameter Store, Azure KeyConfigurable CLI Hooks and CLI Args.Allows you to create test harness.Terraform Cloud and Terraform Enterprise support.More infohereComparison between Pterradactyl vs Terragrunt vs TerraspaceFeaturePterradactylTerragruntTerraspaceCommentOrganized Structure✓✓✓Multiple environments✓✓✓Execute Terraform commands on multiple modules at once✓✓✓Secrets support✓✓✓CLI Hooks✓✓✓More detailsAutomated Backend Creation✓✓✓Built-in Test Framework✗✗✓More detailsNative Terraform HCL✗✗✓More detailsSummaryIt's hard to compare Pterradactyl, Terragrunt and Terraspace on the same level.Overall all those tools have some major differences. However above gives you a gist of what you can expect in each tool.If you are thinking what is more proper for you, simply deep into the details of each tool.
Terragrut and Pterradactyl are rather thin wrappers for Terraform, whereas Terraspace is rather a huge framework.