Created
          June 29, 2018 21:15 
        
      - 
      
- 
        Save robinbowes/20bf2abf8632a6e132400fa4cdd5b084 to your computer and use it in GitHub Desktop. 
    Example code for vpc.id problem
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | module "security_groups" { | |
| source = "./modules/security_groups" | |
| db_port = "${var.db_port}" | |
| identifier = "${local.identifier}" | |
| vpc_id = "${var.vpc_id}" | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | resource "aws_vpc" "vpc" { | |
| cidr_block = "${var.cidr_block}" | |
| tags = { | |
| Name = "${var.name}" | |
| } | |
| } | |
| output "vpc_id" { | |
| value = "${aws_vpc.vpc.id}" | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | data "terraform_remote_state" "vpc" { | |
| backend = "s3" | |
| config { | |
| bucket = "${var.terraform_state_bucket}" | |
| key = "${var.vpc_state_path}" | |
| region = "${var.terraform_state_region}" | |
| } | |
| } | |
| module "netbox" { | |
| source = "[email protected]:acme/terraform.git//modules/services/netbox" | |
| site = "${var.site}" | |
| stage = "${var.stage}" | |
| vpc_id = "${data.terraform_remote_state.vpc.vpc_id}" | |
| db_password = "${var.db_password}" | |
| db_subnet_ids = "${data.terraform_remote_state.vpc.private_subnet_ids}" | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | module "vpc" { | |
| source = "[email protected]:acme/terraform.git//modules/vpc" | |
| cidr_block = "${lookup(local.vpc_data[var.vpc_key], "cidr_block")}" | |
| name = "${lookup(local.vpc_data[var.vpc_key], "name")}" | |
| } | |
| output "vpc_id" { | |
| value = "${module.vpc.vpc_id}" | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment