Implements a blue-green deployment strategy for server-based applications using a classic ELB, with options for handling deployment timeouts and instance termination.

Terraform Template

resource "aws_codedeploy_app" "example" {
  name = "example-app"
}

resource "aws_codedeploy_deployment_group" "example" {
  app_name = aws_codedeploy_app.example.name

  blue_green_deployment_config {

    deployment_ready_option {
      action_on_timeout = "STOP_DEPLOYMENT"
      wait_time_in_minutes = 60
    }

    green_fleet_provisioning_option {
      action = "DISCOVER_EXISTING"
    }

    terminate_blue_instances_on_deployment_success {
      action = "KEEP_ALIVE"
    }
  }
  deployment_group_name = "example-group"

  deployment_style {
    deployment_option = "WITH_TRAFFIC_CONTROL"
    deployment_type = "BLUE_GREEN"
  }

  load_balancer_info {

    elb_info {
      name = "aws_elb.example.name"
    }
  }
  service_role_arn = "aws_iam_role.example.arn"
}