{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/17462","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/17462/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/17462/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/17462/events","html_url":"https://github.com/hashicorp/terraform/issues/17462","id":301008951,"node_id":"MDU6SXNzdWUzMDEwMDg5NTE=","number":17462,"title":"resource/module/count interaction breaks \"plan\": \"cannot parse <count expression> as an integer\"","user":{"login":"handlerbot","id":90347,"node_id":"MDQ6VXNlcjkwMzQ3","avatar_url":"https://avatars2.githubusercontent.com/u/90347?v=4","gravatar_id":"","url":"https://api.github.com/users/handlerbot","html_url":"https://github.com/handlerbot","followers_url":"https://api.github.com/users/handlerbot/followers","following_url":"https://api.github.com/users/handlerbot/following{/other_user}","gists_url":"https://api.github.com/users/handlerbot/gists{/gist_id}","starred_url":"https://api.github.com/users/handlerbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/handlerbot/subscriptions","organizations_url":"https://api.github.com/users/handlerbot/orgs","repos_url":"https://api.github.com/users/handlerbot/repos","events_url":"https://api.github.com/users/handlerbot/events{/privacy}","received_events_url":"https://api.github.com/users/handlerbot/received_events","type":"User","site_admin":false},"labels":[{"id":85946957,"node_id":"MDU6TGFiZWw4NTk0Njk1Nw==","url":"https://api.github.com/repos/hashicorp/terraform/labels/bug","name":"bug","color":"f7c6c7","default":true},{"id":127939292,"node_id":"MDU6TGFiZWwxMjc5MzkyOTI=","url":"https://api.github.com/repos/hashicorp/terraform/labels/core","name":"core","color":"cccccc","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2018-02-28T12:40:04Z","updated_at":"2018-08-05T06:04:48Z","closed_at":"2018-03-20T15:11:55Z","author_association":"CONTRIBUTOR","body":"### Terraform Version\r\n```\r\n$ terraform -v\r\nTerraform v0.11.3\r\n+ provider.aws v1.10.0\r\n```\r\n\r\n### Terraform Configuration Files\r\n\r\n#### main.tf\r\n```hcl\r\nmodule \"s3\" {\r\n  source = \"./s3\"\r\n}\r\n\r\nmodule \"iam\" {\r\n  source = \"./iam\"\r\n\r\n  s3_bucket_arn = \"${module.s3.primary_arn}\"\r\n}\r\n```\r\n\r\n#### s3/main.tf\r\n```hcl\r\nvariable \"switch\" {\r\n  type    = \"string\"\r\n  default = \"1\"\r\n}\r\n\r\nresource \"aws_s3_bucket\" \"a\" {\r\n  count = \"${var.switch ? \"1\" : \"0\"}\"\r\n}\r\n\r\nresource \"aws_s3_bucket\" \"b\" {\r\n  count = \"${!var.switch ? \"1\" : \"0\"}\"\r\n}\r\n\r\noutput \"primary_arn\" {\r\n  value = \"${join(\"\", coalescelist(aws_s3_bucket.a.*.arn, aws_s3_bucket.b.*.arn))}\"\r\n}\r\n```\r\n\r\n#### iam/main.tf\r\n```hcl\r\nvariable \"s3_bucket_arn\" {\r\n  type = \"string\"\r\n}\r\n\r\ndata \"aws_iam_policy_document\" \"singleton\" {\r\n  statement {\r\n    effect = \"Allow\"\r\n\r\n    actions = [\r\n      \"s3:ListBucket\",\r\n    ]\r\n\r\n    resources = [\r\n      \"${var.s3_bucket_arn}\",\r\n    ]\r\n  }\r\n}\r\n```\r\nAttached as [tf-plan-error.zip](https://github.com/hashicorp/terraform/files/1767077/tf-plan-error.zip)\r\n\r\n### Expected Behavior\r\n`terraform plan -target=module.s3.aws_s3_bucket.a` works as expected on any other resource.\r\n\r\n### Actual Behavior\r\n```\r\n$ terraform plan -target=module.s3.aws_s3_bucket.a\r\nRefreshing Terraform state in-memory prior to plan...\r\nThe refreshed state will be used to calculate this plan, but will not be\r\npersisted to local or remote state storage.\r\n\r\naws_s3_bucket.a: Refreshing state... (ID: terraform-20180228121635846800000001)\r\n\r\nError: Error refreshing state: 1 error(s) occurred:\r\n\r\n* module.s3.output.primary_arn: cannot parse \"${!var.switch ? \\\"1\\\" : \\\"0\\\"}\" as an integer\r\n```\r\n\r\n### Steps to Reproduce\r\n`terraform plan -target=module.s3.aws_s3_bucket.a`\r\n\r\n`terraform plan` (and `apply` and `destroy`) without `-target` work fine.\r\n\r\nI made my repro case with AWS S3 and IAM resources, as that's how I found this behavior, and I reduced my running config down to the simplest thing I could find that still expressed the behavior. I don't _think_ it's specific to the AWS provider, but rather a Terraform core issue, hence filing it in this GitHub project, but I could be wrong, of course.\r\n\r\nThanks for reading!"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/410498213","html_url":"https://github.com/hashicorp/terraform/issues/17462#issuecomment-410498213","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/17462","id":410498213,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDQ5ODIxMw==","user":{"login":"tdmalone","id":900469,"node_id":"MDQ6VXNlcjkwMDQ2OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/900469?v=4","gravatar_id":"","url":"https://api.github.com/users/tdmalone","html_url":"https://github.com/tdmalone","followers_url":"https://api.github.com/users/tdmalone/followers","following_url":"https://api.github.com/users/tdmalone/following{/other_user}","gists_url":"https://api.github.com/users/tdmalone/gists{/gist_id}","starred_url":"https://api.github.com/users/tdmalone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdmalone/subscriptions","organizations_url":"https://api.github.com/users/tdmalone/orgs","repos_url":"https://api.github.com/users/tdmalone/repos","events_url":"https://api.github.com/users/tdmalone/events{/privacy}","received_events_url":"https://api.github.com/users/tdmalone/received_events","type":"User","site_admin":false},"created_at":"2018-08-05T06:04:48Z","updated_at":"2018-08-05T06:04:48Z","author_association":"NONE","body":"I'm experiencing this too - but I'm not sure if it is the same issue or a separate one. Happy to create a new issue (and/or provide logs) if that's best?\r\n\r\n```bash\r\n$ terraform apply -target=module.cloudwatch_dashboard\r\nAcquiring state lock. This may take a few moments...\r\n...\r\nReleasing state lock. This may take a few moments...\r\n\r\nError: Error refreshing state: 2 error(s) occurred:\r\n\r\n* module.bastion.module.main.output.public_ip: cannot parse \"${var.eip ? var.public_ip : 0}\" as an integer\r\n* module.bastion.module.main.output.private_ip: cannot parse \"${var.eip ? var.public_ip : 0}\" as an integer\r\n```\r\n\r\nApplying without a target works fine.\r\n\r\n```\r\nTerraform v0.11.7\r\n+ provider.aws v1.30.0\r\n+ provider.dns v2.0.0\r\n+ provider.null v1.0.0\r\n+ provider.pagerduty v1.1.1\r\n+ provider.statuscake v0.2.0\r\n```"}}
{"actor":{"display_login":"tdmalone"}}