{"action":"created","issue":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/4367","repository_url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws","labels_url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/4367/labels{/name}","comments_url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/4367/comments","events_url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/4367/events","html_url":"https://github.com/terraform-providers/terraform-provider-aws/pull/4367","id":318066071,"number":4367,"title":"r/aws_launch_template: some more fixes","user":{"login":"stefansundin","id":1991151,"avatar_url":"https://avatars3.githubusercontent.com/u/1991151?v=4","gravatar_id":"","url":"https://api.github.com/users/stefansundin","html_url":"https://github.com/stefansundin","followers_url":"https://api.github.com/users/stefansundin/followers","following_url":"https://api.github.com/users/stefansundin/following{/other_user}","gists_url":"https://api.github.com/users/stefansundin/gists{/gist_id}","starred_url":"https://api.github.com/users/stefansundin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefansundin/subscriptions","organizations_url":"https://api.github.com/users/stefansundin/orgs","repos_url":"https://api.github.com/users/stefansundin/repos","events_url":"https://api.github.com/users/stefansundin/events{/privacy}","received_events_url":"https://api.github.com/users/stefansundin/received_events","type":"User","site_admin":false},"labels":[{"id":620316239,"url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/labels/bug","name":"bug","color":"f7c6c7","default":true},{"id":801363986,"url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/labels/service/elbv2","name":"service/elbv2","color":"bfd4f2","default":false},{"id":737832199,"url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/labels/size/S","name":"size/S","color":"ffffff","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-26T14:53:41Z","updated_at":"2018-04-26T20:15:27Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/pulls/4367","html_url":"https://github.com/terraform-providers/terraform-provider-aws/pull/4367","diff_url":"https://github.com/terraform-providers/terraform-provider-aws/pull/4367.diff","patch_url":"https://github.com/terraform-providers/terraform-provider-aws/pull/4367.patch"},"body":"The first fix is trivial: `device_index` can be 0. I don't know if it's even desirable to keep it optional, since the console defaults the value to 0 if you do not fill in the field. If you add multiple devices and leave the index empty, the console will also increment them automatically, i.e. \"eth0\", \"eth1\", etc. Maybe we should do the same? I haven't tried launching an instance with a network interface without an index, so if that breaks then this is probably desirable.\r\n\r\nThe second fix is very incomplete. The thing is that almost all of the boolean values are really optional, but terraform defaults them to false. There is no way to leave them undefined. So terraform is not able to fully configure those properties. I tried making it a string, that way we can have the values `\"\"`, `\"true\"`, and `\"false\"`. But then we lose the ability to just use `true` or `false` without quotes in the terraform code, which is kind of confusing for users.\r\n\r\nI first tried this to only set it if it was defined as either true or false, but it did not work.\r\n```\r\nif v, ok := ni[\"associate_public_ip_address\"]; ok {\r\n\tnetworkInterface.AssociatePublicIpAddress = aws.Bool(v.(bool))\r\n}\r\n```\r\n\r\nI tried to use `Default: nil` like this, but it did not work. Perhaps the schema could be enhanced to allow this to make the code above work?\r\n```\r\n\"associate_public_ip_address\": {\r\n\tType:     schema.TypeBool,\r\n\tOptional: true,\r\n\tDefault:  nil,\r\n},\r\n```\r\n\r\nBut it still defaulted to `false`.\r\n\r\nI then tried this, which did work, but there must be a better way.\r\n\r\n```\r\n\"associate_public_ip_address\": {\r\n\tType:     schema.TypeString,\r\n\tOptional: true,\r\n\tValidateFunc: validation.StringInSlice([]string{\r\n\t\t\"true\",\r\n\t\t\"false\",\r\n\t}, false),\r\n},\r\n```\r\n\r\nSo this affects any property that can be true, false, or undefined (\"Do not include in template\"). See screenshot:\r\n<img width=\"1657\" alt=\"screen shot 2018-04-26 at 07 45 27\" src=\"https://user-images.githubusercontent.com/1991151/39313293-7f3e24f6-4926-11e8-8a36-1409b2a77dfa.png\">\r\n\r\nI was going to fix the network interface security groups, but thankfully @kl4w opened his PR first which is much better than my fix. https://github.com/terraform-providers/terraform-provider-aws/pull/4364"},"comment":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/comments/384774962","html_url":"https://github.com/terraform-providers/terraform-provider-aws/pull/4367#issuecomment-384774962","issue_url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/4367","id":384774962,"user":{"login":"bflad","id":189114,"avatar_url":"https://avatars3.githubusercontent.com/u/189114?v=4","gravatar_id":"","url":"https://api.github.com/users/bflad","html_url":"https://github.com/bflad","followers_url":"https://api.github.com/users/bflad/followers","following_url":"https://api.github.com/users/bflad/following{/other_user}","gists_url":"https://api.github.com/users/bflad/gists{/gist_id}","starred_url":"https://api.github.com/users/bflad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bflad/subscriptions","organizations_url":"https://api.github.com/users/bflad/orgs","repos_url":"https://api.github.com/users/bflad/repos","events_url":"https://api.github.com/users/bflad/events{/privacy}","received_events_url":"https://api.github.com/users/bflad/received_events","type":"User","site_admin":false},"created_at":"2018-04-26T20:15:27Z","updated_at":"2018-04-26T20:15:27Z","author_association":"CONTRIBUTOR","body":"I think we might want to making each fix/enhancement individual PRs. Starting to see lots of overlapping work in this resource. See also #4344"}}
{"actor":{"display_login":"bflad"}}