Search code examples
amazon-web-servicesterraformprivate-subnetaws-databricks

AWS subnet’s using terraform


I have a set of subnet’s how do i assign the subnets which are available automatically using terraform? Ex : [“subnet-a”,”subnet-b”,”subnet-c”, “subnet-d”]

I want to pick the two available subnets from given set for module A and module B?


Solution

  • Use random_shuffle:

    resource "random_shuffle" "az" {
      input        = [“subnet-a”,”subnet-b”,”subnet-c”]
      result_count = 2
    }
    

    then to get the actual result:

    random_shuffle.az.result