MitocGroup / terraform-aws-landing-zone

Terraform Module for AWS Landing Zone
https://registry.terraform.io/modules/MitocGroup/landing-zone/aws
Mozilla Public License 2.0
174 stars 112 forks source link

how do you use this? #158

Closed jurgenweber closed 4 years ago

jurgenweber commented 4 years ago

Describe the Bug

the module doesn't validate nor plan.

To Reproduce

  1. I have an empty dir.
  2. create a AWS account, setup s3 backend and state table requirements. main.tf:

    
    terraform {
    backend "s3" {
    bucket         = "${var.bucket}"
    key            = "master/${var.key}"
    region         = "${var.region}"
    dynamodb_table = "${var.dynamodb_table}"
    encrypt        = true
    
    profile                 = "${var.profile}"
    shared_credentials_file = "$HOME/.aws/credentials"
    skip_metadata_api_check = true
    }
    }

module "landing_zone" { source = "MitocGroup/landing-zone/aws" version = "0.2.2" root_path = path.module landing_zone_providers = var.landing_zone_providers landing_zone_components = var.landing_zone_components terraform_backend = var.terraform_backend }

terraform.tfvars

bucket = "bucketname" # Needs to be globally unique dynamodb_table = "TerraformStatelock" key = "terraform.tfstate" profile = "master-terraform-init" region = "us-east-2"

landing_zone_providers = { default = { account_id = "121212121212121212" region = "us-east-2" } } landing_zone_components = { landing_zone_vpc = "s3://terraform-aws-landing-zone/components/landing_zone_vpc/default.tfvars" } terraform_backend = { backend = "s3" path = "master/terraform.tfstate" }

3. terraform init (works)
4. terraform validate

Warning: External references from destroy provisioners are deprecated

on .terraform/modules/landing_zone/MitocGroup-terraform-aws-landing-zone-22b8584/modules/landing_zone/main.tf line 24, in resource "null_resource" "landing_zone_config": 24: command = "node ${path.module}/scripts/remove-config.js"

Destroy-time provisioners and their connection configurations may only reference attributes of the related resource, via 'self', 'count.index', or 'each.key'.

References to other resources during the destroy phase can cause dependency cycles and interact poorly with create_before_destroy.

(and 5 more similar warnings elsewhere)

Error: Unsupported argument

on main.tf line 19, in module "landing_zone": 19: root_path = path.module

An argument named "root_path" is not expected here.


## Expected Behavior
I expect it to validate, I expect it to plan.

## Additional context

$ tf version Terraform v0.12.18

*edit: added node + terrahub versions

eistrati commented 4 years ago

@jurgenweber Thank you for reaching out. You are creating 2 conflicting terraform backends, so let's sort this out:

  1. We just realized that there was a mistake in our documentation. The issue is that root_path was NOT supposed to be there, therefore we are removing it now and your main.tf should look now like this:

    module "landing_zone" {
    source    = "MitocGroup/landing-zone/aws"
    version   = "0.2.2"
    landing_zone_providers  = var.landing_zone_providers
    landing_zone_components = var.landing_zone_components
    terraform_backend       = var.terraform_backend
    }
  2. I would update terraform.tfvars like this:

    landing_zone_providers = {
    default = {
    account_id = "121212121212121212"
    region     = "us-east-2"
    }
    }
    landing_zone_components = {
    landing_zone_vpc = "s3://terraform-aws-landing-zone/components/landing_zone_vpc/default.tfvars"
    }
    terraform_backend = {
    backend = "s3"
    region         = "us-east-2"
    bucket         = "bucketname" # Needs to be globally unique
    key            = "terraform.tfstate"
    dynamodb_table = "TerraformStatelock"
    encrypt        = true
    profile        = "master-terraform-init"
    shared_credentials_file = "$HOME/.aws/credentials"
    skip_metadata_api_check = true
    }

    NOTE: Make sure to include in landing_zone_components the list of all required components that you need for your AWS Landing Zone. And replace s3://terraform-aws-landing-zone/components/landing_zone_vpc/default.tfvars with your s3 bucket and path where each .tfvars file will be stored for each component. If you prefer to use local path, replace it with ./default.tfvars or something like that relative to each component's root folder...

Please let us know if it works with above described changes.

eistrati commented 4 years ago

Sorry, this issue was closed automatically. Reopening and waiting for your feedback...

eistrati commented 4 years ago

@jurgenweber fyi, this pull request should resolve deprecation warning - https://github.com/MitocGroup/terraform-aws-landing-zone/pull/163

eistrati commented 4 years ago

All reported issues have been fixed and published in v0.2.3 release: https://github.com/MitocGroup/terraform-aws-landing-zone/releases/tag/v0.2.3