{"action":"created","issue":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-google/issues/1644","repository_url":"https://api.github.com/repos/terraform-providers/terraform-provider-google","labels_url":"https://api.github.com/repos/terraform-providers/terraform-provider-google/issues/1644/labels{/name}","comments_url":"https://api.github.com/repos/terraform-providers/terraform-provider-google/issues/1644/comments","events_url":"https://api.github.com/repos/terraform-providers/terraform-provider-google/issues/1644/events","html_url":"https://github.com/terraform-providers/terraform-provider-google/issues/1644","id":331657969,"node_id":"MDU6SXNzdWUzMzE2NTc5Njk=","number":1644,"title":"google_sql_database_instance: dynamic authorized_networks","user":{"login":"Chupaka","id":3432808,"node_id":"MDQ6VXNlcjM0MzI4MDg=","avatar_url":"https://avatars2.githubusercontent.com/u/3432808?v=4","gravatar_id":"","url":"https://api.github.com/users/Chupaka","html_url":"https://github.com/Chupaka","followers_url":"https://api.github.com/users/Chupaka/followers","following_url":"https://api.github.com/users/Chupaka/following{/other_user}","gists_url":"https://api.github.com/users/Chupaka/gists{/gist_id}","starred_url":"https://api.github.com/users/Chupaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chupaka/subscriptions","organizations_url":"https://api.github.com/users/Chupaka/orgs","repos_url":"https://api.github.com/users/Chupaka/repos","events_url":"https://api.github.com/users/Chupaka/events{/privacy}","received_events_url":"https://api.github.com/users/Chupaka/received_events","type":"User","site_admin":false},"labels":[{"id":620326525,"node_id":"MDU6TGFiZWw2MjAzMjY1MjU=","url":"https://api.github.com/repos/terraform-providers/terraform-provider-google/labels/enhancement","name":"enhancement","color":"d4c5f9","default":true},{"id":670571367,"node_id":"MDU6TGFiZWw2NzA1NzEzNjc=","url":"https://api.github.com/repos/terraform-providers/terraform-provider-google/labels/upstream-terraform","name":"upstream-terraform","color":"cccccc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-12T16:14:30Z","updated_at":"2018-06-12T19:32:55Z","closed_at":null,"author_association":"NONE","body":"### Affected Resource(s)\r\n- google_sql_database_instance\r\n\r\n### Terraform Configuration Files\r\nWe're allowing access to Postgres Cloud SQL instance only from our backend servers. If the number of servers is constant, one may use code like\r\n```hcl\r\nresource \"google_sql_database_instance\" \"postgres\" {\r\n  settings {\r\n    ip_configuration {\r\n      authorized_networks = [\r\n        {\r\n          value = \"${google_compute_instance.backend.0.network_interface.0.access_config.0.assigned_nat_ip}\"\r\n        },\r\n        {\r\n          value = \"${google_compute_instance.backend.1.network_interface.0.access_config.0.assigned_nat_ip}\"\r\n        },\r\n      ]\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nBut looks like currently there's no way to create list of maps from dynamic list of strings via interpolation functions. There's a feature request opened in terraform that can manage those situations (https://github.com/hashicorp/terraform/issues/7034), but it's far from finishing.\r\n\r\nCan we have some kind of logic in google-provider so that if it sees **authorized_networks {value=list}** it automatically creates necessary list of maps? Then the above task would look like\r\n```hcl\r\nresource \"google_sql_database_instance\" \"postgres\" {\r\n  settings {\r\n    ip_configuration {\r\n      authorized_networks {\r\n        value = \"${google_compute_instance.backend.*.network_interface.0.access_config.0.assigned_nat_ip}\"\r\n      }\r\n    }\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-google/issues/comments/396707081","html_url":"https://github.com/terraform-providers/terraform-provider-google/issues/1644#issuecomment-396707081","issue_url":"https://api.github.com/repos/terraform-providers/terraform-provider-google/issues/1644","id":396707081,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NjcwNzA4MQ==","user":{"login":"danawillow","id":1130694,"node_id":"MDQ6VXNlcjExMzA2OTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1130694?v=4","gravatar_id":"","url":"https://api.github.com/users/danawillow","html_url":"https://github.com/danawillow","followers_url":"https://api.github.com/users/danawillow/followers","following_url":"https://api.github.com/users/danawillow/following{/other_user}","gists_url":"https://api.github.com/users/danawillow/gists{/gist_id}","starred_url":"https://api.github.com/users/danawillow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danawillow/subscriptions","organizations_url":"https://api.github.com/users/danawillow/orgs","repos_url":"https://api.github.com/users/danawillow/repos","events_url":"https://api.github.com/users/danawillow/events{/privacy}","received_events_url":"https://api.github.com/users/danawillow/received_events","type":"User","site_admin":false},"created_at":"2018-06-12T19:32:54Z","updated_at":"2018-06-12T19:32:54Z","author_association":"COLLABORATOR","body":"Unfortunately, that just isn't possible at the moment given the way that Terraform internals work. Each schema element has a fixed type, so for `authorized_networks` it's a set, and for `value` it's a string.\r\n\r\nHypothetically we could add a new field that accomplishes what you're asking for, but then we have two fields that mean the same thing and that requires some upkeep.\r\n\r\nHowever, there are some changes coming up in Terraform core 0.12 that will likely make what you're hoping for easier. If it's all right, I'd like to hold off on doing anything about this particular issue until it comes out and then we can re-evaluate. Tagging @paddycarver in case there's anything he'd like to add about it as well :)"}}
{"actor":{"display_login":"danawillow"}}