Skip to content

Commit 28713d6

Browse files
Merge pull request segmentio#65 from BuildDirect/set-minimum_healthy
allow setting minimum healthy percent, maximum percent
2 parents 7d3b77d + 6d4cb0d commit 28713d6

File tree

4 files changed

+78
-33
lines changed

4 files changed

+78
-33
lines changed

docs.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
| domain_name_servers | the internal DNS servers, defaults to the internal route53 server of the VPC | `""` | no |
2727
| region | the AWS region in which resources are created, you must set the availability_zones variable as well if you define this value to something other than the default | `"us-west-2"` | no |
2828
| cidr | the CIDR block to provision for the VPC, if set to something other than the default, both internal_subnets and external_subnets have to be defined as well | `"10.30.0.0/16"` | no |
29-
| internal_subnets | a comma-separated list of CIDRs for internal subnets in your VPC, must be set if the cidr variable is defined, needs to have as many elements as there are availability zones | `"10.30.0.0/19,10.30.64.0/19,10.30.128.0/19"` | no |
30-
| external_subnets | a comma-separated list of CIDRs for external subnets in your VPC, must be set if the cidr variable is defined, needs to have as many elements as there are availability zones | `"10.30.32.0/20,10.30.96.0/20,10.30.160.0/20"` | no |
31-
| availability_zones | a comma-separated list of availability zones, defaults to all AZ of the region, if set to something other than the defaults, both internal_subnets and external_subnets have to be defined as well | `"us-west-2a,us-west-2b,us-west-2c"` | no |
29+
| internal_subnets | a list of CIDRs for internal subnets in your VPC, must be set if the cidr variable is defined, needs to have as many elements as there are availability zones | - | yes |
30+
| external_subnets | a list of CIDRs for external subnets in your VPC, must be set if the cidr variable is defined, needs to have as many elements as there are availability zones | - | yes |
31+
| availability_zones | a comma-separated list of availability zones, defaults to all AZ of the region, if set to something other than the defaults, both internal_subnets and external_subnets have to be defined as well | - | yes |
32+
| bastion_instance_type | Instance type for the bastion | `"t2.micro"` | no |
33+
| ecs_cluster_name | the name of the cluster, if not specified the variable name will be used | `""` | no |
3234
| ecs_instance_type | the instance type to use for your default ecs cluster | `"m4.large"` | no |
33-
| ecs_instance_ebs_optimized | use EBS - not all instance types support EBS | `"true"` | no |
35+
| ecs_instance_ebs_optimized | use EBS - not all instance types support EBS | `true` | no |
3436
| ecs_min_size | the minimum number of instances to use in the default ecs cluster | `3` | no |
3537
| ecs_max_size | the maximum number of instances to use in the default ecs cluster | `100` | no |
3638
| ecs_desired_capacity | the desired number of instances to use in the default ecs cluster | `3` | no |
@@ -52,8 +54,6 @@
5254
| external_elb | Security group for external ELBs. |
5355
| internal_subnets | Comma separated list of internal subnet IDs. |
5456
| external_subnets | Comma separated list of external subnet IDs. |
55-
| internal_route_tables | Comma separated list of internal route table IDs. |
56-
| external_route_tables | The external route table ID. |
5757
| iam_role | ECS Service IAM role. |
5858
| log_bucket_id | S3 bucket ID for ELB logs. |
5959
| domain_name | The internal domain name, e.g "stack.local". |
@@ -63,6 +63,8 @@
6363
| vpc_security_group | The VPC security group ID. |
6464
| vpc_id | The VPC ID. |
6565
| ecs_cluster_security_group_id | The default ECS cluster security group ID. |
66+
| internal_route_tables | Comma separated list of internal route table IDs. |
67+
| external_route_tables | The external route table ID. |
6668

6769
# bastion
6870

@@ -129,8 +131,8 @@
129131
|------|-------------|:-----:|:-----:|
130132
| region | The AWS region | - | yes |
131133
| cidr | The CIDR block to provision for the VPC | - | yes |
132-
| default_ecs_ami | | - | yes |
133-
| default_log_account_ids | | - | yes |
134+
| default_ecs_ami | | `<map>` | no |
135+
| default_log_account_ids | | `<map>` | no |
134136

135137
## Outputs
136138

@@ -199,12 +201,12 @@
199201
name = "cdn"
200202
vpc_id = "vpc-id"
201203
image_id = "ami-id"
202-
subnet_ids = "1,2"
204+
subnet_ids = ["1" ,"2"]
203205
key_name = "ssh-key"
204206
security_groups = "1,2"
205207
iam_instance_profile = "id"
206208
region = "us-west-2"
207-
availability_zones = "a,b"
209+
availability_zones = ["a", "b"]
208210
instance_type = "t2.small"
209211
}
210212

@@ -218,12 +220,12 @@
218220
| environment | Environment tag, e.g prod | - | yes |
219221
| vpc_id | VPC ID | - | yes |
220222
| image_id | AMI Image ID | - | yes |
221-
| subnet_ids | Comma separated list of subnet IDs | - | yes |
223+
| subnet_ids | List of subnet IDs | - | yes |
222224
| key_name | SSH key name to use | - | yes |
223225
| security_groups | Comma separated list of security groups | - | yes |
224226
| iam_instance_profile | Instance profile ARN to use in the launch configuration | - | yes |
225227
| region | AWS Region | - | yes |
226-
| availability_zones | Comma separated list of AZs | - | yes |
228+
| availability_zones | List of AZs | - | yes |
227229
| instance_type | The instance type to use, e.g t2.small | - | yes |
228230
| instance_ebs_optimized | When set to true the instance will be launched with EBS optimized turned on | `true` | no |
229231
| min_size | Minimum instance count | `3` | no |
@@ -315,9 +317,9 @@
315317
| environment | The environment tag, e.g prod | - | yes |
316318
| vpc_id | The VPC ID to use | - | yes |
317319
| zone_id | The Route53 Zone ID where the DNS record will be created | - | yes |
318-
| security_groups | A comma-separated list of security group IDs | - | yes |
319-
| subnet_ids | A comma-separated list of subnet IDs | - | yes |
320-
| availability_zones | A comma-separated list of availability zones | - | yes |
320+
| security_groups | A list of security group IDs | - | yes |
321+
| subnet_ids | A list of subnet IDs | - | yes |
322+
| availability_zones | A list of availability zones | - | yes |
321323
| database_name | The database name | - | yes |
322324
| master_username | The master user username | - | yes |
323325
| master_password | The master user password | - | yes |
@@ -418,6 +420,8 @@
418420
| protocol | The ELB protocol, HTTP or TCP | `"HTTP"` | no |
419421
| iam_role | IAM Role ARN to use | - | yes |
420422
| zone_id | The zone ID to create the record in | - | yes |
423+
| deployment_minimum_healthy_percent | lower limit (% of desired_count) of # of running tasks during a deployment | `100` | no |
424+
| deployment_maximum_percent | upper limit (% of desired_count) of # of running tasks during a deployment | `200` | no |
421425

422426
## Outputs
423427

@@ -472,10 +476,10 @@
472476
| Name | Description | Default | Required |
473477
|------|-------------|:-----:|:-----:|
474478
| cidr | The CIDR block for the VPC. | - | yes |
475-
| external_subnets | Comma separated list of subnets | - | yes |
476-
| internal_subnets | Comma separated list of subnets | - | yes |
479+
| external_subnets | List of external subnets | - | yes |
480+
| internal_subnets | List of internal subnets | - | yes |
477481
| environment | Environment tag, e.g prod | - | yes |
478-
| availability_zones | Comma separated list of availability zones | - | yes |
482+
| availability_zones | List of availability zones | - | yes |
479483
| name | Name tag, e.g stack | `"stack"` | no |
480484

481485
## Outputs
@@ -484,7 +488,7 @@
484488
|------|-------------|
485489
| id | The VPC ID |
486490
| external_subnets | A comma-separated list of subnet IDs. |
487-
| internal_subnets | A comma-separated list of subnet IDs. |
491+
| internal_subnets | A list of subnet IDs. |
488492
| security_group | The default VPC security group ID. |
489493
| availability_zones | The list of availability zones of the VPC. |
490494
| internal_rtb_id | The internal route table ID. |
@@ -533,6 +537,8 @@
533537
| desired_count | The desired count | `2` | no |
534538
| memory | The number of MiB of memory to reserve for the container | `512` | no |
535539
| cpu | The number of cpu units to reserve for the container | `512` | no |
540+
| deployment_minimum_healthy_percent | lower limit (% of desired_count) of # of running tasks during a deployment | `100` | no |
541+
| deployment_maximum_percent | upper limit (% of desired_count) of # of running tasks during a deployment | `200` | no |
536542

537543
## Outputs
538544

@@ -575,3 +581,6 @@
575581
| desired_count | The desired count | `1` | no |
576582
| memory | The number of MiB of memory to reserve for the container | `512` | no |
577583
| cpu | The number of cpu units to reserve for the container | `512` | no |
584+
| deployment_minimum_healthy_percent | lower limit (% of desired_count) of # of running tasks during a deployment | `100` | no |
585+
| deployment_maximum_percent | upper limit (% of desired_count) of # of running tasks during a deployment | `200` | no |
586+

service/main.tf

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,28 @@ variable "zone_id" {
111111
description = "The zone ID to create the record in"
112112
}
113113

114+
variable "deployment_minimum_healthy_percent" {
115+
description = "lower limit (% of desired_count) of # of running tasks during a deployment"
116+
default = 100
117+
}
118+
119+
variable "deployment_maximum_percent" {
120+
description = "upper limit (% of desired_count) of # of running tasks during a deployment"
121+
default = 200
122+
}
123+
114124
/**
115125
* Resources.
116126
*/
117127

118128
resource "aws_ecs_service" "main" {
119-
name = "${module.task.name}"
120-
cluster = "${var.cluster}"
121-
task_definition = "${module.task.arn}"
122-
desired_count = "${var.desired_count}"
123-
iam_role = "${var.iam_role}"
129+
name = "${module.task.name}"
130+
cluster = "${var.cluster}"
131+
task_definition = "${module.task.arn}"
132+
desired_count = "${var.desired_count}"
133+
iam_role = "${var.iam_role}"
134+
deployment_minimum_healthy_percent = "${var.deployment_minimum_healthy_percent}"
135+
deployment_maximum_percent = "${var.deployment_maximum_percent}"
124136

125137
load_balancer {
126138
elb_name = "${module.elb.id}"

web-service/main.tf

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,28 @@ variable "cpu" {
120120
default = 512
121121
}
122122

123+
variable "deployment_minimum_healthy_percent" {
124+
description = "lower limit (% of desired_count) of # of running tasks during a deployment"
125+
default = 100
126+
}
127+
128+
variable "deployment_maximum_percent" {
129+
description = "upper limit (% of desired_count) of # of running tasks during a deployment"
130+
default = 200
131+
}
132+
123133
/**
124134
* Resources.
125135
*/
126136

127137
resource "aws_ecs_service" "main" {
128-
name = "${module.task.name}"
129-
cluster = "${var.cluster}"
130-
task_definition = "${module.task.arn}"
131-
desired_count = "${var.desired_count}"
132-
iam_role = "${var.iam_role}"
138+
name = "${module.task.name}"
139+
cluster = "${var.cluster}"
140+
task_definition = "${module.task.arn}"
141+
desired_count = "${var.desired_count}"
142+
iam_role = "${var.iam_role}"
143+
deployment_minimum_healthy_percent = "${var.deployment_minimum_healthy_percent}"
144+
deployment_maximum_percent = "${var.deployment_maximum_percent}"
133145

134146
load_balancer {
135147
elb_name = "${module.elb.id}"

worker/main.tf

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,27 @@ variable "cpu" {
6868
default = 512
6969
}
7070

71+
variable "deployment_minimum_healthy_percent" {
72+
description = "lower limit (% of desired_count) of # of running tasks during a deployment"
73+
default = 100
74+
}
75+
76+
variable "deployment_maximum_percent" {
77+
description = "upper limit (% of desired_count) of # of running tasks during a deployment"
78+
default = 200
79+
}
80+
7181
/**
7282
* Resources.
7383
*/
7484

7585
resource "aws_ecs_service" "main" {
76-
name = "${module.task.name}"
77-
cluster = "${var.cluster}"
78-
task_definition = "${module.task.arn}"
79-
desired_count = "${var.desired_count}"
86+
name = "${module.task.name}"
87+
cluster = "${var.cluster}"
88+
task_definition = "${module.task.arn}"
89+
desired_count = "${var.desired_count}"
90+
deployment_minimum_healthy_percent = "${var.deployment_minimum_healthy_percent}"
91+
deployment_maximum_percent = "${var.deployment_maximum_percent}"
8092

8193
lifecycle {
8294
create_before_destroy = true

0 commit comments

Comments
 (0)