All Projects → antonbabenko → tfvars-annotations

antonbabenko / tfvars-annotations

Licence: MIT license
[not-WIP] Update values in terraform.tfvars using annotations

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
ruby
36898 projects - #4 most used programming language
HCL
1544 projects

Projects that are alternatives of or similar to tfvars-annotations

annotate-pull-request-from-checkstyle
cs2pr - Annotate a GitHub Pull Request based on a Checkstyle XML-report within your GitHub Action
Stars: ✭ 146 (+630%)
Mutual labels:  annotations
MangoServer
A MongoDB implementation of the W3C Web Annotation Protocol
Stars: ✭ 16 (-20%)
Mutual labels:  annotations
Rails-4-ElasticSearch-dynamic-facets
Rails 4 ElasticSearch integration with dynamic facets
Stars: ✭ 16 (-20%)
Mutual labels:  dynamic
github-readme-streak-stats
🔥 Stay motivated and show off your contribution streak! 🌟 Display your total contributions, current streak, and longest streak on your GitHub profile README
Stars: ✭ 1,395 (+6875%)
Mutual labels:  dynamic
simple json
Simple way to dynamically convert from and to JSON using build-time generators given a type.
Stars: ✭ 15 (-25%)
Mutual labels:  dynamic
DynamicComponents-AI2
An App Inventor extension to add full support for creating any type of component at runtime, in your app.
Stars: ✭ 47 (+135%)
Mutual labels:  dynamic
godot-InventorySystem
Easily modifiable Inventory System ready for use. If you need anything further, you can add it.
Stars: ✭ 27 (+35%)
Mutual labels:  dynamic
Dynamic ORB SLAM2
Visual SLAM system that can identify and exclude dynamic objects.
Stars: ✭ 89 (+345%)
Mutual labels:  dynamic
ODYM
Open Dynamic Material Systems Model
Stars: ✭ 36 (+80%)
Mutual labels:  dynamic
ColdStorage
Lightweight data loading and caching library for android
Stars: ✭ 39 (+95%)
Mutual labels:  annotations
dynamic-input-fields-reactjs
Example of the dynamic input fields in ReactJS
Stars: ✭ 31 (+55%)
Mutual labels:  dynamic
AnnotationProcessorStarter
Project to set up basics of a Java annotation processor
Stars: ✭ 19 (-5%)
Mutual labels:  annotations
dynamic-datasource-starter
springboot 动态切换数据的基本思想与实现方法
Stars: ✭ 12 (-40%)
Mutual labels:  dynamic
AnnotationProcessing
✔️ㅤ[ARTICLE] Writing your own Annotation Processors in Android
Stars: ✭ 47 (+135%)
Mutual labels:  annotations
youtube-copy-annotations
💻 Copy YouTube annotations like a pro!
Stars: ✭ 13 (-35%)
Mutual labels:  annotations
Form-Labeller
Use this tool to label forms, bounding boxes, and assigning types to annotations
Stars: ✭ 17 (-15%)
Mutual labels:  annotations
spectree
API spec validator and OpenAPI document generator for Python web frameworks.
Stars: ✭ 190 (+850%)
Mutual labels:  annotations
better-serializer
General serializer for PHP. An alternative to JmsSerializer.
Stars: ✭ 27 (+35%)
Mutual labels:  annotations
grpc-jwt-spring-boot-starter
Spring boot starter for gRPC framework with JWT authorization
Stars: ✭ 24 (+20%)
Mutual labels:  annotations
DuktapeJava
Tiny Powerfull JavaScript Engine On Android Platform integrating with java
Stars: ✭ 74 (+270%)
Mutual labels:  dynamic

Update values in terraform.tfvars using annotations

This project has become redundant (yay!)

The same functionality is available natively in Terragrunt since version 0.19.20 (released 15th of August 2019).

See PR #3 for the explanation and some extra unreleased code if you want to continue developing this for Terraform.


Terraform is awesome!

As of today, Terraform 0.11 and 0.12 support only static (known, fixed, already computed) values in tfvars files. There is no way to use Terraform interpolation functions, or data-sources inside tfvars files in Terraform to update values.

While working on modules.tf (a tool which converts visual diagrams created with Cloudcraft.co into Terraform configurations), I had a need to generate code which would chain invocations of Terraform AWS modules and pass arguments between them without requiring any extra Terraform code as a glue. Terragrunt is a great fit for this, it allows to reduce amount of Terraform configurations by reusing Terraform modules and providing arguments as values in tfvars files.

Some languages I know have concepts like annotations and decorators, so at first I made a shell script which replaced values in tfvars based on annotations and was called by Terragrunt hooks. tfvars-annotations shares the same goal and it has no external dependencies (except terraform or terragrunt).

Use cases

  1. modules.tf and Terragrunt (recommended)
  2. Terraform (not implemented yet)
  3. General example - AMI ID, AWS region

Features

  1. Supported annotations:
  • terragrunt_output:
    • @tfvars:terragrunt_output.vpc.vpc_id
    • @tfvars:terragrunt_output.security-group.this_security_group_id
  • terraform_output
  • data-sources generic
  1. Type wrapping:
  • to_list: Wrap original value with [] to make it it as a list

How to use

Run tfvars-annotations before terraform plan, apply, refresh.

It will process tfvars file in the current directory and set updated values.

E.g.:

$ tfvars-annotations examples/project1-terragrunt/eu-west-1/app
$ terraform plan

How to disable processing entirely

Put @tfvars:disable_annotations anywhere in the terraform.tfvars to not process the file.

Examples

See examples for some basics.

To-do

  1. Get values from other sources:
  • data sources generic
  • aws_account_id or aws_region data sources
  1. terragrunt_outputs from stacks:
  • in any folder
  • in current region
  1. cache values unless stack is changed/updated
  2. functions (limit(2), to_list)
  3. rewrite in go (invoke like this => update_dynamic_values_in_tfvars ${get_parent_tfvars_dir()}/${path_relative_to_include()})
  4. make it much faster, less verbose
  5. add dry-run flag
  6. Proposed syntax:
  • @tfvars:terragrunt_output.security-group_5.this_security_group_id.to_list

  • @tfvars:terragrunt_output.["eu-west-1/security-group_5"].this_security_group_id.to_list

  • @tfvars:terragrunt_output.["global/route53-zones"].zone_id

  • @tfvars:terragrunt_data.aws_region.zone_id

  • @tfvars:terragrunt_data.aws_region[{current=true}].zone_id

Bugs

  1. Add support for maps (and lists of maps). Strange bugs with rendering comments in wrong places.

Installation

On OSX, install it with Homebrew (not enough github stars to get it to the official repo):

brew install -s HomebrewFormula/tfvars-annotations.rb

Alternatively, you can download a release suitable for your platform and unzip it. Make sure the tfvars-annotations binary is executable, and you're ready to go.

You can also install it like this:

go get github.com/antonbabenko/tfvars-annotations

Or run it from source:

go run . -debug examples/project1-terragrunt/eu-west-1/app
go run . examples/project1-terragrunt/eu-west-1/app

Release

  1. Make GitHub Release: hub release create v0.0.3. Then Github Actions will build binaries and attach them to Github release.
  2. Update Homebrew version in HomebrewFormula/tfvars-annotations.rb. Install locally - brew install -s HomebrewFormula/tfvars-annotations.rb

Authors

This project is created and maintained by Anton Babenko with the help from different contributors.

@antonbabenko

License

This work is licensed under MIT License. See LICENSE for full details.

Copyright (c) 2019 Anton Babenko

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].