Giter VIP home page Giter VIP logo

terraform-provider-yaml's Introduction

Terraform YAML Data Source (OBSOLETE)

As of Terraform v0.12.2 there is a native function yamldecode that obsoletes the plugin. No further development and/or support is planned for this repo. Feel free to open an issue if you have development ideas related to YAML processing that were not included into Terraform core.

Overview

This provider defines a Terraform data sources that can consume YAML input [as a string] and covert it into another format that can be used with Terraform.

Please note that JSON is subset of YAML and therefore this data source can be used to parse arbitrary JSON as well.

As of Terraform 0.12 it's trivial to process YAML documents of arbitrary complexity with data "yaml_to_json" and jsondecode.

Data Sources:

Installation

Terraform automatically discovers the Providers when it parses configuration files. This only occurs when the init command is executed.

Currently Terraform is able to automatically download only official plugins distributed by HashiCorp.

All other plugins should be installed manually.

Terraform will search for matching Providers via a Discovery process, including the current local directory.

This means that the plugin should either be placed into current working directory where Terraform will be executed from or it can be installed system-wide.

The simplest way to get started is:

wget "https://github.com/ashald/terraform-provider-yaml/releases/download/v2.1.0/terraform-provider-yaml_v2.1.0-$(uname -s | tr '[:upper:]' '[:lower:]')-amd64"
chmod +x ./terraform-provider-yaml*

Development

Provider is written and maintained by Borys Pierov. Contributions are welcome and should follow development guidelines. All contributors are honored in CONTRIBUTORS.md.

License

This is free and unencumbered software released into the public domain. See LICENSE

terraform-provider-yaml's People

Contributors

anton-dessiatov avatar ashald avatar ravi-mrk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-yaml's Issues

Provider "yaml" not available for installation

The terraform can't install YAML provider after download link was changed (here)

Error: Provider "yaml" not available for installation.

How to reproduce:

main.tf:

terraform {
required_version = "0.11.14"
}
data "yaml_map_of_strings" "rhs_values" {
input = "${file("<path_to_yaml_file")}"
}

bash:

wget "https://github.com/ashald/terraform-provider-yaml/releases/download/v2.1.0/terraform-provider-yaml_v2.1.0_$(uname -s | tr '[:upper:]' '[:lower:]')_amd64"
chmod +x ./terraform-provider-yaml*
terraform init

panic reading ansible inventory

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.yaml_map_of_strings.normal: Refreshing state...

Error: Error refreshing state: 1 error(s) occurred:

* data.yaml_map_of_strings.normal: 1 error(s) occurred:

* data.yaml_map_of_strings.normal: data.yaml_map_of_strings.normal: unexpected EOF


panic: reflect: call of reflect.Value.Interface on zero Value
2019-04-23T09:02:46.531-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 
2019-04-23T09:02:46.531-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: goroutine 82 [running]:
2019-04-23T09:02:46.531-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: reflect.valueInterface(0x0, 0x0, 0x0, 0xc42035e501, 0xc42044b600, 0xc42044b600)
2019-04-23T09:02:46.531-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/.goenv/versions/1.10.3/src/reflect/value.go:953 +0x1a3
2019-04-23T09:02:46.531-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: reflect.Value.Interface(0x0, 0x0, 0x0, 0x0, 0x0)
2019-04-23T09:02:46.531-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/.goenv/versions/1.10.3/src/reflect/value.go:948 +0x44
2019-04-23T09:02:46.531-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: github.com/ashald/terraform-provider-yaml/yaml.serializeToFlowStyleYaml(0x0, 0x0, 0xc420362af0, 0xf, 0xc4203fb608, 0x0)
2019-04-23T09:02:46.531-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/workspace/go/src/github.com/ashald/terraform-provider-yaml/yaml/common.go:32 +0x126
2019-04-23T09:02:46.531-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: github.com/ashald/terraform-provider-yaml/yaml.readYamlMap(0xc4200ea230, 0x0, 0x0, 0xc4200ea230, 0x0)
2019-04-23T09:02:46.531-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/workspace/go/src/github.com/ashald/terraform-provider-yaml/yaml/data_source_yaml_map_of_strings.go:56 +0x424
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: github.com/ashald/terraform-provider-yaml/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).ReadDataApply(0xc420430310, 0xc42015cca0, 0x0, 0x0, 0xc420452b18, 0x10bce01, 0x1883060)
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/workspace/go/src/github.com/ashald/terraform-provider-yaml/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:290 +0x88
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: github.com/ashald/terraform-provider-yaml/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).ReadDataApply(0xc4204303f0, 0xc42035c140, 0xc42015cca0, 0x18, 0x18, 0xc42015cce0)
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/workspace/go/src/github.com/ashald/terraform-provider-yaml/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:426 +0x9a
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: github.com/ashald/terraform-provider-yaml/vendor/github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).ReadDataApply(0xc42042c4e0, 0xc4200c62d0, 0xc4200c71b0, 0x0, 0x0)
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/workspace/go/src/github.com/ashald/terraform-provider-yaml/vendor/github.com/hashicorp/terraform/plugin/resource_provider.go:604 +0x4e
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: reflect.Value.call(0xc420350b40, 0xc42035e398, 0x13, 0x1a2627a, 0x4, 0xc4203a6f18, 0x3, 0x3, 0xc4200d2080, 0x0, ...)
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/.goenv/versions/1.10.3/src/reflect/value.go:447 +0x969
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: reflect.Value.Call(0xc420350b40, 0xc42035e398, 0x13, 0xc4204de718, 0x3, 0x3, 0x0, 0x0, 0x0)
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/.goenv/versions/1.10.3/src/reflect/value.go:308 +0xa4
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: net/rpc.(*service).call(0xc420368700, 0xc42035c2d0, 0xc420362368, 0xc420362380, 0xc420364e00, 0xc420360ba0, 0x1883020, 0xc4200c62d0, 0x16, 0x1883060, ...)
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/.goenv/versions/1.10.3/src/net/rpc/server.go:384 +0x14e
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: created by net/rpc.(*Server).ServeCodec
2019-04-23T09:02:46.532-0600 [DEBUG] plugin.terraform-provider-yaml_v2.0.0-darwin-amd64: 	/Users/ashald/.goenv/versions/1.10.3/src/net/rpc/server.go:480 +0x43a
2019/04/23 09:02:46 [ERROR] root: eval: *terraform.EvalReadDataApply, err: data.yaml_map_of_strings.normal: unexpected EOF
2019/04/23 09:02:46 [ERROR] root: eval: *terraform.EvalSequence, err: data.yaml_map_of_strings.normal: unexpected EOF
2019/04/23 09:02:46 [TRACE] [walkRefresh] Exiting eval tree: data.yaml_map_of_strings.normal
2019/04/23 09:02:46 [TRACE] dag/walk: upstream errored, not walking "output.normal"
2019/04/23 09:02:46 [TRACE] dag/walk: upstream errored, not walking "provider.yaml (close)"
2019/04/23 09:02:46 [TRACE] dag/walk: upstream errored, not walking "root"
2019-04-23T09:02:46.535-0600 [DEBUG] plugin: plugin process exited: path=/Users/markbordas/.terraform.d/plugins/terraform-provider-yaml_v2.0.0-darwin-amd64
2019/04/23 09:02:46 [DEBUG] plugin: waiting for all plugin processes to complete...
2019-04-23T09:02:46.535-0600 [WARN ] plugin: error closing client during Kill: err="connection is shut down"



!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Working with nested structures

Hi!

I'm trying to work with a nested structure that looks like this:

---
name: samples
dependencies:
  - type: database
    name: mongo
    version: 3.2
    test: true
  - type: database
    name: mysql
    schema: core
    test: true
  - type: database
    name: cassandra
    test: true
  - type: database
    name: zookeeper
    version: 3.4
  - type: database
    name: rabbitmq
  - type: database
    name: memcached
capabilities:
  - api
  - worker
  - consumer

Here is my terraform plan:

variable "stashusr" {
}

variable "stashpw" {
}

data "http" "service_spec" {
  url = "https://${var.stashusr}:${var.stashpw}@example.com/config.yml"
}

data "yaml_map_of_strings" "service_spec" {
  input = "${data.http.service_spec.body}"

  depends_on = ["data.http.service_spec"]
}

data "yaml_list_of_strings" "service_spec" {
  input = "${data.yaml_map_of_strings.service_spec.output["dependencies"]}"

  depends_on = ["data.yaml_map_of_strings.service_spec"]
}

output "service_spec" {
  value = "${data.yaml_map_of_strings.service_spec.output}"
}

output "capabilities" {
  value = "${data.yaml_map_of_strings.service_spec.output["capabilities"]}"
}

output "dependencies" {
  value = "${data.yaml_map_of_strings.service_spec.output["dependencies"]}"
}

output "name" {
  value = "${data.yaml_map_of_strings.service_spec.output["name"]}"
}

But I'm getting errors:

Error: Error applying plan:

1 error(s) occurred:

* data.yaml_list_of_strings.service_spec: data.yaml_list_of_strings.service_spec: yaml: unmarshal errors:
  line 1: cannot unmarshal !!map into string
  line 1: cannot unmarshal !!map into string
  line 1: cannot unmarshal !!map into string
  line 1: cannot unmarshal !!map into string
  line 1: cannot unmarshal !!map into string
  line 1: cannot unmarshal !!map into string

Am I doing something wrong or is the provider not able to handle this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.