Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching Data from Maps and List Variable Video #35

Open
iparksisutech opened this issue Nov 28, 2023 · 1 comment
Open

Fetching Data from Maps and List Variable Video #35

iparksisutech opened this issue Nov 28, 2023 · 1 comment

Comments

@iparksisutech
Copy link

On the "Fetching Data from Maps and List Variable" Video. With the variables. tf file you only have the List Example. Might be helpful if you also add the Map code as well which is aligned with the video:

resource "aws_instance" "myec2" {
ami = "ami-082b5a644766e0e6f"
instance_type = var.types["ap-south-1"]

@pranjal779
Copy link

this is my code,
I hope this helps

provider "aws" {
  region     = "us-west-2"
  access_key = "YOUR-KEY"
  secret_key = "YOUR-KEY"
}

resource "aws_instance" "myec2" {
  ami           = "ami-082b5a644766e0e6f"
  instance_type = var.list[1] # for list
  # instance_type = "t2.micro"
  # instance_type = var.types["us-west-2"]
  # to try
  # instance_type = var.types["ap-south-1"]
}

variable "list" {
  type    = list(any)
  default = ["m5.large", "m5.xlarge", "t2.medium"]
}

variable "types" {
  type = map(any)
  default = {
    us-east-1  = "t2.micro"
    us-west-2  = "t2.nano"
    ap-south-1 = "t2.small"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants