Created
December 14, 2019 00:25
-
-
Save turgay/6aacd4fa50ee2ab6c97b37b36b9f8be2 to your computer and use it in GitHub Desktop.
Terraform: Get a VPC by name
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
| //file: provider.tf | |
| provider "aws" { | |
| region = "us-east-1" | |
| } | |
| //file: vpc.tf | |
| variable "vpc_name" {} | |
| data "aws_vpc" "selected" { | |
| tags = { | |
| Name = var.my_vpc_name | |
| } | |
| } | |
| //file: variables.tf | |
| variable "my_vpc_name" {} | |
| //file: output.tf | |
| output "select_vpc_id" { | |
| value = data.aws_vpc.selected.id | |
| } | |
| //file: terraform.tfvars | |
| my_vpc_name = "..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment