Create dynamic resources using 'for_each' or 'for'
you need to use count, and with it you should be able to access item by index: https://www.terraform.io/docs/configuration/resources.html#the-count-object