{"action":"created","issue":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/2993","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/2993/labels{/name}","comments_url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/2993/comments","events_url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/2993/events","html_url":"https://github.com/terraform-providers/terraform-provider-aws/issues/2993","id":288494713,"node_id":"MDU6SXNzdWUyODg0OTQ3MTM=","number":2993,"title":"Lifecycle hook in autoscaling group not recreated from codedeploy deployment group","user":{"login":"gunnarvelle","id":8956884,"node_id":"MDQ6VXNlcjg5NTY4ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/8956884?v=4","gravatar_id":"","url":"https://api.github.com/users/gunnarvelle","html_url":"https://github.com/gunnarvelle","followers_url":"https://api.github.com/users/gunnarvelle/followers","following_url":"https://api.github.com/users/gunnarvelle/following{/other_user}","gists_url":"https://api.github.com/users/gunnarvelle/gists{/gist_id}","starred_url":"https://api.github.com/users/gunnarvelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gunnarvelle/subscriptions","organizations_url":"https://api.github.com/users/gunnarvelle/orgs","repos_url":"https://api.github.com/users/gunnarvelle/repos","events_url":"https://api.github.com/users/gunnarvelle/events{/privacy}","received_events_url":"https://api.github.com/users/gunnarvelle/received_events","type":"User","site_admin":false},"labels":[{"id":801971593,"node_id":"MDU6TGFiZWw4MDE5NzE1OTM=","url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/labels/service/autoscaling","name":"service/autoscaling","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-01-15T06:48:28Z","updated_at":"2018-10-23T06:46:07Z","closed_at":null,"author_association":"NONE","body":"When a codedeploy deployment group is created and it references an autoscaling group, a lifecycle hook is created in the autoscaling group. If this lifecycle hook accidentaly gets deleted, terraform does not recreate it because the deployment group is unchanged. \r\n\r\n### Terraform Version\r\n11.2\r\n\r\n### Affected Resource(s)\r\n- aws_autoscaling_group\r\n- aws_codedeploy_deployment_group\r\n\r\n### Terraform Configuration Files\r\n```hcl\r\nresource \"aws_autoscaling_group\" \"instance\" {\r\n  name                      = \"${var.env_name}-${var.component_name}\"\r\n  launch_configuration      = \"${aws_launch_configuration.instance.name}\"\r\n\r\n  lifecycle {\r\n    create_before_destroy = true\r\n  }\r\n\r\n  max_size                  = \"${var.autoscaling_max_size}\"\r\n  min_size                  = \"${var.autoscaling_min_size}\"\r\n  health_check_grace_period = \"${var.autoscaling_grace_period}\"\r\n  health_check_type         = \"${var.autoscaling_health_check_function}\"\r\n  vpc_zone_identifier       = [ \"${split(\",\", var.private_subnets)}\" ]\r\n\r\n  tag {\r\n    key                 = \"Environment\"\r\n    value               = \"${var.env_name}\"\r\n    propagate_at_launch = true\r\n  }\r\n}\r\n\r\nresource \"aws_autoscaling_attachment\" \"asg_public_elb\" {\r\n  autoscaling_group_name = \"${aws_autoscaling_group.instance.id}\"\r\n  elb                    = \"${aws_elb.instance.id}\"\r\n}\r\n\r\nresource \"aws_codedeploy_app\" \"instance\" {\r\n  name = \"${var.env_name}.${var.component_name}\"\r\n}\r\n\r\nresource \"aws_codedeploy_deployment_group\" \"instance\" {\r\n  deployment_group_name  = \"${var.env_name}.${var.component_name}\"\r\n  app_name               = \"${aws_codedeploy_app.instance.name}\"\r\n  service_role_arn       = \"${var.codedeploy_auth_role}\"\r\n\r\n  deployment_config_name = \"CodeDeployDefault.OneAtATime\"\r\n  autoscaling_groups     = [ \"${aws_autoscaling_group.instance.name}\" ]\r\n\r\n  trigger_configuration {\r\n    trigger_events     = [ \"DeploymentStart\", \"DeploymentSuccess\", \"DeploymentFailure\", \"DeploymentStop\",\r\n      \"InstanceStart\", \"InstanceSuccess\", \"InstanceFailure\" ]\r\n    trigger_name       = \"${var.component_name}-deployment\"\r\n    trigger_target_arn = \"${var.deployment_notification_arn}\"\r\n  }\r\n}\r\n```\r\n\r\n### Expected Behavior\r\nTerraform should have discovered the missing lifecycle hook, and recreated it. \r\n\r\n### Actual Behavior\r\nLifecycle hook still missing. I have to edit the deployment group using the admin console and save it with no changes. Then the lifecycle hook gets recreated by codedeploy.\r\n\r\n### Steps to Reproduce\r\n1. `terraform apply`\r\n2. Delete lifecycle hook from autoscaling group.\r\n3. `terraform apply`\r\n\r\n### Important Factoids\r\nNone I am aware of.\r\n"},"comment":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/comments/432115324","html_url":"https://github.com/terraform-providers/terraform-provider-aws/issues/2993#issuecomment-432115324","issue_url":"https://api.github.com/repos/terraform-providers/terraform-provider-aws/issues/2993","id":432115324,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjExNTMyNA==","user":{"login":"gunnarvelle","id":8956884,"node_id":"MDQ6VXNlcjg5NTY4ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/8956884?v=4","gravatar_id":"","url":"https://api.github.com/users/gunnarvelle","html_url":"https://github.com/gunnarvelle","followers_url":"https://api.github.com/users/gunnarvelle/followers","following_url":"https://api.github.com/users/gunnarvelle/following{/other_user}","gists_url":"https://api.github.com/users/gunnarvelle/gists{/gist_id}","starred_url":"https://api.github.com/users/gunnarvelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gunnarvelle/subscriptions","organizations_url":"https://api.github.com/users/gunnarvelle/orgs","repos_url":"https://api.github.com/users/gunnarvelle/repos","events_url":"https://api.github.com/users/gunnarvelle/events{/privacy}","received_events_url":"https://api.github.com/users/gunnarvelle/received_events","type":"User","site_admin":false},"created_at":"2018-10-23T06:46:07Z","updated_at":"2018-10-23T06:46:07Z","author_association":"NONE","body":"@macnibblet The only way to reinitialize the hook is to edit the application in codedeploy and save it without making changes. Then the lifecycle hook is refreshed or created if missing."}}
{"actor":{"display_login":"gunnarvelle"}}