{"action":"opened","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/7583","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/7583/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/7583/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/7583/events","html_url":"https://github.com/hashicorp/terraform/issues/7583","id":164901396,"number":7583,"title":"Certain CloudStack resources not added to tfstate","user":{"login":"keith471","id":9021017,"avatar_url":"https://avatars.githubusercontent.com/u/9021017?v=3","gravatar_id":"","url":"https://api.github.com/users/keith471","html_url":"https://github.com/keith471","followers_url":"https://api.github.com/users/keith471/followers","following_url":"https://api.github.com/users/keith471/following{/other_user}","gists_url":"https://api.github.com/users/keith471/gists{/gist_id}","starred_url":"https://api.github.com/users/keith471/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keith471/subscriptions","organizations_url":"https://api.github.com/users/keith471/orgs","repos_url":"https://api.github.com/users/keith471/repos","events_url":"https://api.github.com/users/keith471/events{/privacy}","received_events_url":"https://api.github.com/users/keith471/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-11T18:20:59Z","updated_at":"2016-07-11T18:20:59Z","closed_at":null,"body":"### Terraform Version\r\n`0.6.16`\r\n\r\n### Affected Resource(s)\r\nOf the many resources in my configuration, the only two I've encountered with this issue are:\r\n- `cloudstack_static_nat`\r\n- `cloudstack_loadbalancer_rule`\r\n\r\n### Terraform Configuration Files\r\n```hcl\r\nprovider \"cloudstack\" {\r\n  api_url           = \"${var.api_url}\"\r\n  api_key           = \"${var.api_key}\"\r\n  secret_key        = \"${var.secret_key}\"\r\n}\r\n\r\nresource \"cloudstack_template\" \"template\" {\r\n  name              = \"tf-template\"\r\n  format            = \"VHD\"\r\n  hypervisor        = \"XenServer\"\r\n  os_type           = \"${var.os_type_id}\"\r\n  url               = \"http://url/of/template\"\r\n  zone              = \"-1\"\r\n  project           =\"${var.project}\"\r\n}\r\n\r\nresource \"cloudstack_vpc\" \"main_vpc\" {\r\n  name              = \"tf-default\"\r\n  cidr              = \"${var.vpc_cidr}\"\r\n  vpc_offering      = \"${var.vpc_offering}\"\r\n  zone              = \"${var.zone}\"\r\n  project           = \"${var.project}\"\r\n}\r\n\r\nresource \"cloudstack_network\" \"tier\" {\r\n  name              = \"tf-tier\"\r\n  cidr              = \"${cidrsubnet(\"${var.vpc_cidr}\", 2, 1)}\"\r\n  network_offering  = \"${var.network_offering}\"\r\n  vpc_id            = \"${cloudstack_vpc.main_vpc.id}\"\r\n  zone              = \"${var.zone}\"\r\n  acl_id            = \"9ba3ec65-2e1d-11e4-8e05-42a29a39fc92\"\r\n  project           = \"${var.project}\"\r\n}\r\n\r\nresource \"cloudstack_instance\" \"instance\" {\r\n  name              =\"tf-instance\"\r\n  zone              =\"${var.zone}\"\r\n  template          =\"${cloudstack_template.template.id}\"\r\n  service_offering  =\"${var.service_offering}\"\r\n  network_id        =\"${cloudstack_network.tier.id}\"\r\n  project           = \"${var.project}\"\r\n  keypair           = \"${cloudstack_ssh_keypair.sshkey.id}\"\r\n  expunge           =false\r\n}\r\n\r\nresource \"cloudstack_ipaddress\" \"static_nat_ip\" {\r\n  vpc_id            = \"${cloudstack_vpc.main_vpc.id}\"\r\n  project           = \"${var.project}\"\r\n}\r\n\r\nresource \"cloudstack_static_nat\" \"static_nat\" {\r\n  ip_address_id         = \"${cloudstack_ipaddress.static_nat_ip.id}\"\r\n  virtual_machine_id    = \"${cloudstack_instance.instance.id}\"\r\n  network_id            = \"${cloudstack_network.tier.id}\"\r\n}\r\n\r\nresource \"cloudstack_ipaddress\" \"lb_ip\" {\r\n    vpc_id          = \"${cloudstack_vpc.main_vpc.id}\"\r\n    project         = \"${var.project}\"\r\n}\r\n\r\nresource \"cloudstack_loadbalancer_rule\" \"lbr\" {\r\n  name              = \"tf-lbr\"\r\n  description       = \"App load balancer rule\"\r\n  ip_address_id     = \"${cloudstack_ipaddress.lb_ip.id}\"\r\n  algorithm         = \"roundrobin\"\r\n  network_id        = \"${cloudstack_network.tier.id}\"\r\n  private_port      = \"33\"\r\n  public_port       = \"33\"\r\n  member_ids        = [\"${cloudstack_instance.instance.id}\"]\r\n}\r\n\r\nresource \"cloudstack_ssh_keypair\" \"sshkey\" {\r\n  name              = \"tf-ssh-key\"\r\n  public_key        = \"${file(\"~/.ssh/id_rsa.pub\")}\"\r\n  project           = \"${var.project}\"\r\n}\r\n```\r\n\r\n### Debug Output\r\n1. Run `terraform apply` to spin up all the infrastructure\r\n2. Run `terraform apply` again.\r\nThe debug output [here](https://gist.github.com/keith471/74f036f1d48f486f6d6b62d5ff01786b) was produced by the **second** step.\r\n\r\n### Expected Behavior\r\nShould not have attempted to create the load balancer rule nor the static NAT as they already exist.\r\n\r\n### Actual Behavior\r\nAttempts to create them, producing the following error output:\r\n```\r\n2 error(s) occurred:\r\n\r\n* cloudstack_static_nat.static_nat: Error enabling static NAT: CloudStack API error 431 (CSExceptionErrorCode: 4350): Failed to enable static nat on the  ip 192.155.69.46 with Id 4102679d-f75d-4e9d-a885-d26f7912f7fd as the vm i-2649-12835-VM with Id cc5fb8b6-3d9c-4917-91b6-9b25733b7520 is already associated with another public ip 192.155.69.46 with id 4102679d-f75d-4e9d-a885-d26f7912f7fd\r\n* cloudstack_loadbalancer_rule.lbr: CloudStack API error 537 (CSExceptionErrorCode: 9999): The range specified, 33-33, conflicts with rule 12294 which has 33-33\r\n```\r\n\r\n### Steps to Reproduce\r\n1. `terraform apply`\r\n2. `terraform plan` - you will see that the load balancer rule and static NAT are staged for creation\r\n3. `terraform apply`\r\n\r\n### References\r\nIt could be completely unrelated, but a similar-sounding past problem is [#2584](https://github.com/hashicorp/terraform/issues/2584).\r\n"}}
{"actor":{"display_login":"keith471"}}