terraform-yaml-config icon indicating copy to clipboard operation
terraform-yaml-config copied to clipboard

Improve docs on how to use this module

Open icamys opened this issue 3 years ago • 2 comments

Hi team. I'm new to Terraform and I have been faced with using it with Ansible. It looks like this module may help in useing common configurations between Terraform and Ansible. However, it's quite unclear how exactly should I use this module.

I installed it and copied the example code in my modules.tf inside my project:

module "yaml_config" {
  source = "cloudposse/config/yaml"
  version     = "0.7.0"

  map_config_local_base_path = "./../config"

  map_config_paths = [
    "*.yaml",
  ]

  context = module.this.context
}

But when I plan this configuration I get the error:

│ Error: Reference to undeclared module
│ 
│   on modules.tf line 11, in module "yaml_config":
│   11:   context = module.this.context
│ 
│ No module call named "this" is declared in the root module.

Are there any steps I've missed during the configuration?

icamys avatar Aug 08 '21 12:08 icamys

@icamys Thanks for testing and suggestion. We definitely need to improve the docs, but please take a look at all the examples here https://github.com/cloudposse/terraform-yaml-config/tree/main/examples

These are working examples, we have examples folder in all our modules.

Regarding the error

No module call named "this" is declared in the root module.

you need to add the file context.tf https://github.com/cloudposse/terraform-yaml-config/blob/main/examples/complete/context.tf to your code.

Please watch this video for more details https://www.youtube.com/watch?v=V2b5F6jt6tQ

aknysh avatar Aug 08 '21 22:08 aknysh

If readme examples may get outdated or might not work, it would be better to just have a item list of examples linking to the repo files, instead of embedding them in the readme, IMO.

pataquets avatar Oct 06 '23 10:10 pataquets