Coder Social home page Coder Social logo

terraform-nested-module's Introduction

terraform-flat-module

Configuration structure:

๐Ÿ“‚ terraform-flat-module
โ”œโ”€โ”€ ๐Ÿ“„ main.tf
โ”œโ”€โ”€ ๐Ÿ“„ README.md
โ”œโ”€โ”€ ๐Ÿ“„ file.dummy
โ””โ”€โ”€ ๐Ÿ“‚ temp
    โ”œโ”€โ”€ ๐Ÿ“„ main.tf
    โ””โ”€โ”€ ๐Ÿ“„ README.md

Top level README.md contains information about the top-level configuration.

Configuration

Top-level main.tf has the following code:

resource "null_resource" "show_scalr_env_vars" {
  triggers = {
    time = timestamp()
  }  
  provisioner "local-exec" {
    command = "printenv | grep SCALR"
  }
}

resource "random_string" "strings" {
  count = 4
  length = 8
  keepers = {
    time = timestamp()
  }
  depends_on = [ null_resource.show_scalr_env_vars ]
}

data "null_data_source" "some_values" {
  inputs = {
    first_pair = concat(
      random_string.strings[0],
      random_string.strings[1],
    )
    second_pair = concat(
      random_string.strings[2],
      random_string.strings[3],
    )
  }
}

data "archive_file" "dummy" {
  type        = "zip"
  source_file = "file.dummy"
  output_path = "file_dummy.zip"
  depends_on = [ data.null_data_source.some_values ]
}

resource "null_resource" "show_files_after_packing" {
  triggers = {
    archive = data.archive_file.dummy.id
  }
  provisioner "local-exec" {
    command = "ls -la"
  }
}

module "temp" {
  source = "./temp"
  custom_trigger = var.top-level-trigger
}

variable "top-level-trigger" {
  default = "lol"
}

output "all_strings_from_data" {
  value = jsonencode({
    first_pair = null_data_source.some_values.outputs["first_pair"]
    second_pair = null_data_source.some_values.outputs["second_pair"]
  })
}

As seen in the template, child temp module is called inside the top one.

terraform-nested-module's People

Contributors

aleatoricmbnt avatar

Watchers

 avatar

Forkers

kozliuk

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.