{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/4725","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/4725/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/4725/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/4725/events","html_url":"https://github.com/hashicorp/terraform/issues/4725","id":127328344,"number":4725,"title":"Cloudtrail - After resource created, does not stay managed by terraform","user":{"login":"jmelfi","id":6218154,"avatar_url":"https://avatars.githubusercontent.com/u/6218154?v=3","gravatar_id":"","url":"https://api.github.com/users/jmelfi","html_url":"https://github.com/jmelfi","followers_url":"https://api.github.com/users/jmelfi/followers","following_url":"https://api.github.com/users/jmelfi/following{/other_user}","gists_url":"https://api.github.com/users/jmelfi/gists{/gist_id}","starred_url":"https://api.github.com/users/jmelfi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmelfi/subscriptions","organizations_url":"https://api.github.com/users/jmelfi/orgs","repos_url":"https://api.github.com/users/jmelfi/repos","events_url":"https://api.github.com/users/jmelfi/events{/privacy}","received_events_url":"https://api.github.com/users/jmelfi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/bug","name":"bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/core","name":"core","color":"cccccc"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/waiting-response","name":"waiting-response","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-01-18T23:06:54Z","updated_at":"2016-01-19T18:15:54Z","closed_at":null,"body":"I'm able to get the resouce for the trail to be provisioned the first time\r\n\r\n```shell \r\n% terraform apply base.plan\r\naws_cloudtrail.infra-logs: Creating...\r\n  enable_logging:                \"\" => \"1\"\r\n  include_global_service_events: \"\" => \"1\"\r\n  name:                          \"\" => \"infra-logs\"\r\n  s3_bucket_name:                \"\" => \"BUCKETNAME\"\r\n  s3_key_prefix:                 \"\" => \"PREFIX\"\r\naws_cloudtrail.infra-logs: Creation complete\r\n\r\nApply complete! Resources: 1 added, 0 changed, 0 destroyed.\r\n\r\nThe state of your infrastructure has been saved to the path\r\nbelow. This state is required to modify and destroy your\r\ninfrastructure, so keep it safe. To inspect the complete state\r\nuse the `terraform show` command.\r\n\r\nState path: terraform.tfstate\r\n```\r\n\r\nThis works perfectly and creates the trail as requested and attaches to the correct s3 bucket.  The issue I'm finding is that in `terraform.tfstate`, I'm unable to find any `aws_cloudtrail` objects that were saved.  When I run terraform again without any file edits, I get the following:\r\n\r\n```\r\n% terraform apply base.plan\r\naws_cloudtrail.infra-logs: Creating...\r\n  enable_logging:                \"\" => \"1\"\r\n  include_global_service_events: \"\" => \"1\"\r\n  name:                          \"\" => \"infra-logs\"\r\n  s3_bucket_name:                \"\" => \"infra-logs\"\r\n  s3_key_prefix:                 \"\" => \"infra\"\r\nError applying plan:\r\n\r\n1 error(s) occurred:\r\n\r\n* aws_cloudtrail.infra-logs: TrailAlreadyExistsException: Trail infra-logs already exists for customer: CUSTOMER_ID_NUMBER\r\n\tstatus code: 400, request id: 0444e1d2-be37-11e5-971f-a1649c2920ab\r\n\r\nTerraform does not automatically rollback in the face of errors.\r\nInstead, your Terraform state file has been partially updated with\r\nany resources that successfully completed. Please address the error\r\nabove and apply again to incrementally change your infrastructure.\r\n```\r\n\r\nWhat would the resolution be here so that this error stops being given erroneously? "},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/172938769","html_url":"https://github.com/hashicorp/terraform/issues/4725#issuecomment-172938769","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/4725","id":172938769,"user":{"login":"radeksimko","id":287584,"avatar_url":"https://avatars.githubusercontent.com/u/287584?v=3","gravatar_id":"","url":"https://api.github.com/users/radeksimko","html_url":"https://github.com/radeksimko","followers_url":"https://api.github.com/users/radeksimko/followers","following_url":"https://api.github.com/users/radeksimko/following{/other_user}","gists_url":"https://api.github.com/users/radeksimko/gists{/gist_id}","starred_url":"https://api.github.com/users/radeksimko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radeksimko/subscriptions","organizations_url":"https://api.github.com/users/radeksimko/orgs","repos_url":"https://api.github.com/users/radeksimko/repos","events_url":"https://api.github.com/users/radeksimko/events{/privacy}","received_events_url":"https://api.github.com/users/radeksimko/received_events","type":"User","site_admin":false},"created_at":"2016-01-19T18:15:54Z","updated_at":"2016-01-19T18:15:54Z","body":"Thanks for the clarification.\r\n\r\nIf this is really a bug, I strongly believe it would be in core, unrelated to CloudTrail. Can you retry this with any other resource? `aws_vpc` should be quick to create/destroy.\r\n\r\nI noticed you're explicitly defining the plan file, can you try and let terraform generate the plan at runtime and omit the plan file completely?"}}