Giter Club home page Giter Club logo

terraform-provider-deepmerge's Introduction

Terraform Provider Deepmerge

Deepmerge functions for Terraform 1.8+.

Requirements

Using the provider

terraform {
  required_providers {
    deepmerge = {
      source = "registry.terraform.io/isometry/deepmerge"
    }
  }
}

provider "deepmerge" {}

output "example" {
  value = provider::deepmerge::mergo(local.map1, local.map2, local.map3)
}

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).

To compile the provider, run go install. This will build the provider and put the provider binary in the $GOPATH/bin directory.

To generate or update documentation, run go generate.

In order to run the full suite of Acceptance tests, run make testacc.

Note: Acceptance tests create real resources, and often cost money to run.

make testacc

terraform-provider-deepmerge's People

Contributors

isometry avatar dependabot[bot] avatar

Stargazers

Sven Greb avatar SangGyu Lee avatar Miran avatar Ruben Aleman avatar Vincent Flecke avatar Vladimir Kuznichenkov avatar Corey Jack Wilson avatar Alexey Mikhaylov avatar Kalen Arndt avatar Tim Thompson avatar Joao C Costa avatar Artur Taranchiev avatar Shane Ramey avatar

Watchers

 avatar  avatar

terraform-provider-deepmerge's Issues

key with null value causes JSON unmarshal error

terraform v1.8.2
deepmerge v0.1.0

input

locals {
  map1 = {
    bad = null
    good = false
  }
  map2 = {
    bad = "overwrite"
    good = true
  }
}

output "example" {
  value = provider::deepmerge::mergo(local.map1, local.map2)
}

output

$ terraform plan
╷
│ Error: Error in function call
│ 
│   on main.tf line 44, in output "example":
│   44:   value = provider::deepmerge::mergo(local.map1, local.map2)
│     ├────────────────
│     │ while calling provider::deepmerge::mergo(maps...)
│     │ local.map1 is object with 2 attributes
│     │ local.map2 is object with 2 attributes
│ 
│ Call to function "provider::deepmerge::mergo" failed: Error unmarshalling argument 1: invalid character '<' looking for beginning of value.
╵

null values override

I'm not sure this is an issue, but I've faced a situation when I have a defined variable for example:

variable "policies" {
  type = map(map(object({
    name         = optional(string)
    policy_arn   = optional(string)
    })
  ))
}

And I want to merge this with a local map that has a name set, for example:

policies = {
  group1 = {
    policy1 = {
      name = "something"
    }
  }
}

In the input variable, I have policy_arn set, for example:

policies = {
  group1 = {
    policy1 = {
      policy_arn = "arn"
    }
  }
}

The problem is that the resulting structure will have a name set to null:

policies = {
  group1 = {
    policy1 = {
      name        = null
      policy_arn = "arn"
    }
  }
}

This is because the type is defined and terraform sets this value to null and merge overwrites the value with null.

So the question is maybe it is worth skipping any null values during merging?

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.