{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/1604","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/1604/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/1604/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/1604/events","html_url":"https://github.com/hashicorp/terraform/issues/1604","id":69687698,"number":1604,"title":"Support use cases with conditional logic","user":{"login":"phinze","id":37534,"avatar_url":"https://avatars.githubusercontent.com/u/37534?v=3","gravatar_id":"","url":"https://api.github.com/users/phinze","html_url":"https://github.com/phinze","followers_url":"https://api.github.com/users/phinze/followers","following_url":"https://api.github.com/users/phinze/following{/other_user}","gists_url":"https://api.github.com/users/phinze/gists{/gist_id}","starred_url":"https://api.github.com/users/phinze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phinze/subscriptions","organizations_url":"https://api.github.com/users/phinze/orgs","repos_url":"https://api.github.com/users/phinze/repos","events_url":"https://api.github.com/users/phinze/events{/privacy}","received_events_url":"https://api.github.com/users/phinze/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/core","name":"core","color":"cccccc"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/enhancement","name":"enhancement","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":26,"created_at":"2015-04-20T21:38:59Z","updated_at":"2015-09-07T05:47:28Z","closed_at":null,"body":"It's been important from the beginning that Terraform's configuration language is declarative, which has meant that the core team has intentionally avoided adding flow-control statements like conditionals and loops to the language.\r\n\r\nBut in the real world, there are still plenty of perfectly reasonable scenarios that are difficult to express in the current version of Terraform without copious amounts of duplication because of the lack of conditionals. We'd like Terraform to support these use cases one way or another.\r\n\r\nI'm opening this issue to collect some real-world example where, as a config author, it seems like an `if` statement would really make things easier.\r\n\r\nUsing these examples, we'll play around with different ideas to improve the tools Terraform provides to the config author in these scenarios.\r\n\r\nSo please feel free to chime in with some specific examples - ideally with with blocks of Terraform configuration included. If you've got ideas for syntax or config language features that could form a solution, those are welcome here too.\r\n\r\n(No need to respond with just \"+1\" / :+1: on this thread, since it's an issue we're already aware is important.)"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/138193039","html_url":"https://github.com/hashicorp/terraform/issues/1604#issuecomment-138193039","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/1604","id":138193039,"user":{"login":"aavileli","id":9123144,"avatar_url":"https://avatars.githubusercontent.com/u/9123144?v=3","gravatar_id":"","url":"https://api.github.com/users/aavileli","html_url":"https://github.com/aavileli","followers_url":"https://api.github.com/users/aavileli/followers","following_url":"https://api.github.com/users/aavileli/following{/other_user}","gists_url":"https://api.github.com/users/aavileli/gists{/gist_id}","starred_url":"https://api.github.com/users/aavileli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aavileli/subscriptions","organizations_url":"https://api.github.com/users/aavileli/orgs","repos_url":"https://api.github.com/users/aavileli/repos","events_url":"https://api.github.com/users/aavileli/events{/privacy}","received_events_url":"https://api.github.com/users/aavileli/received_events","type":"User","site_admin":false},"created_at":"2015-09-07T05:47:28Z","updated_at":"2015-09-07T05:47:28Z","body":"If you are building a module for any resource like RDS or any resource that change behaviour when additional attributes have been set then a evaluating function is required like the following which is available in cloudformation\r\n\r\n\"MyDB\" : {\r\n  \"Type\" : \"AWS::RDS::DBInstance\",\r\n  \"Properties\" : {\r\n    \"AllocatedStorage\" : \"5\",\r\n    \"DBInstanceClass\" : \"db.m1.small\",\r\n    \"Engine\" : \"MySQL\",\r\n    \"EngineVersion\" : \"5.5\",\r\n    \"MasterUsername\" : { \"Ref\" : \"DBUser\" },\r\n    \"MasterUserPassword\" : { \"Ref\" : \"DBPassword\" },\r\n    \"DBParameterGroupName\" : { \"Ref\" : \"MyRDSParamGroup\" },\r\n    \"DBSnapshotIdentifier\" : {\r\n      \"Fn::If\" : [\r\n        \"UseDBSnapshot\",\r\n        {\"Ref\" : \"DBSnapshotName\"},\r\n        {\"Ref\" : \"AWS::NoValue\"}\r\n      ]\r\n    }\r\n  }\r\n}\r\n\r\n"}}