mgmt icon indicating copy to clipboard operation
mgmt copied to clipboard

[LOVE] Support terraform resources with polling

Open purpleidea opened this issue 7 years ago • 2 comments

Welcome:

This is a difficult patch for someone who has experience in golang, and some experience in mgmt or terraform. It is meant to encourage an mgmt hacker to get more deeply involved with mgmt. It will probably take you at least a week or more to complete.

Intro:

Mgmt is a relatively new tool written in golang. It doesn't have as many "cloud" resources as other tools like terraform. It would be helpful for terraform users to be able to get the advantages of the mgmt language with the addition of some of the terraform backends. We'd like to make many of the terraform resources available in mgmt. To implement this, you'll need to either recommend an alternate design, or use the one provided below.

Design:

You'll need to come up with a way of exposing terraform resources in mgmt. If there is a way to generate these via some sort of compatibility layer and/or mapping rather than building each one manually, that might be preferable. Unfortunately terraform doesn't have events, so initially, we'd want to have these resources default to polling. In the worst case scenario, we implement each resource manually.

Read the contributing tips: https://github.com/purpleidea/mgmt/blob/master/.github/PULL_REQUEST_TEMPLATE.md

Happy hacking, and ping me for questions!

Bonus/Future work:

  • Write a few tests.
  • Add some autoedges.
  • Add some autogrouping.
  • Work on the reverse (clean) API and think about how it could work with terraform states here.

purpleidea avatar Feb 10 '18 12:02 purpleidea

I would like to work on this, if no one else already is.

jonathangold avatar May 11 '18 11:05 jonathangold

A few thoughts on design.

Terraform uses a Resource type (https://github.com/hashicorp/terraform/blob/master/helper/resource/resource.go) to define methods for resources, and a Schema type (https://github.com/hashicorp/terraform/blob/master/helper/schema/schema.go) to define the resources' parameters.

Since all terraform resources are represented by those types, afaict, it should be possible to implement a compatibility layer. This would involve figuring out how to represent any terraform schema (map[string]string perhaps ) in mcl, and calling the methods defined in the (terraform) Resource type from Validate() and CheckApply().

jonathangold avatar May 11 '18 12:05 jonathangold