{"action":"opened","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/6390","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/6390/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/6390/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/6390/events","html_url":"https://github.com/hashicorp/terraform/issues/6390","id":151598439,"number":6390,"title":"Failed CloudFront logging_config change stored to state and not refreshed","user":{"login":"tmatilai","id":79116,"avatar_url":"https://avatars.githubusercontent.com/u/79116?v=3","gravatar_id":"","url":"https://api.github.com/users/tmatilai","html_url":"https://github.com/tmatilai","followers_url":"https://api.github.com/users/tmatilai/followers","following_url":"https://api.github.com/users/tmatilai/following{/other_user}","gists_url":"https://api.github.com/users/tmatilai/gists{/gist_id}","starred_url":"https://api.github.com/users/tmatilai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmatilai/subscriptions","organizations_url":"https://api.github.com/users/tmatilai/orgs","repos_url":"https://api.github.com/users/tmatilai/repos","events_url":"https://api.github.com/users/tmatilai/events{/privacy}","received_events_url":"https://api.github.com/users/tmatilai/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-28T10:04:02Z","updated_at":"2016-04-28T10:04:02Z","closed_at":null,"body":"I had an existing `aws_cloudfront_distribution` resource without `logging_config` configuration.\r\nThe when adding a new `aws_s3_bucket` and a referencing `logging_config` block, the Bucket was created but not ready when Terraform tried to configure it for the CloudFront distribution:\r\n\r\n```\r\naws_s3_bucket.logs: Creating...\r\n  acl:              \"\" => \"private\"\r\n  arn:              \"\" => \"<computed>\"\r\n  bucket:           \"\" => \"foo-logs\"\r\n  force_destroy:    \"\" => \"0\"\r\n  hosted_zone_id:   \"\" => \"<computed>\"\r\n  region:           \"\" => \"<computed>\"\r\n  website_domain:   \"\" => \"<computed>\"\r\n  website_endpoint: \"\" => \"<computed>\"\r\naws_s3_bucket.logs: Creation complete\r\naws_cloudfront_distribution.app: Modifying...\r\n  logging_config.#:                          \"0\" => \"1\"\r\n  logging_config.1955940039.bucket:          \"\" => \"foo-logs\"\r\n  logging_config.1955940039.include_cookies: \"\" => \"0\"\r\n  logging_config.1955940039.prefix:          \"\" => \"cloudfront\"\r\nError applying plan:\r\n\r\n1 error(s) occurred:\r\n\r\n* aws_cloudfront_distribution.app: InvalidArgument: The parameter Logging Bucket does not refer to a valid S3 bucket.\r\n        status code: 400, request id: <xxx>\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\nThis is a familiar case with AWS and it's caching, but the issue is that Terraform anyway **stored the new but failed configuration to the state file** and does not see any changes in the future `plan` or `apply` calls. So it does not refresh the state from AWS."}}