Skip to content

Commit 398fcca

Browse files
authored
Merge pull request #2 from unifio/wc-updates
Refactor & upgrade
2 parents 83313e4 + d0b5ba4 commit 398fcca

31 files changed

+1275
-357
lines changed

.env.docker

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
AWS_REGION=us-east-2
2+
COVALENCE_PACKER_DIR=./
3+
COVALENCE_TERRAFORM_DIR=./
4+
COVALENCE_TEST_ENVS=basic,complete
5+
CHECKPOINT_DISABLE=1
6+
GODEBUG=netdns=cgo
7+
USER=root

.gitignore

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
**/.terraform
2-
**/.terraform.d
3-
**/.terraform/*
4-
**/*.tfstate.backup
5-
**/*.tfstate
6-
**/*.box
1+
*.tfstate*
2+
.terraform/
3+
.env
4+
spec/reports/**

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"editor.renderWhitespace": "all",
3+
"files.associations": {
4+
"*.tpl": "hcl",
5+
"*.tf": "terraform"
6+
},
7+
"files.insertFinalNewline": true,
8+
"files.trimTrailingWhitespace": true
9+
}

CHANGELOG.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## Unreleased
2+
3+
#### IMPROVEMENTS / NEW FEATURES:
4+
* Add support for application autoscaling
5+
6+
## 0.2.0 (April 9, 2017)
7+
8+
#### BACKWARDS INCOMPATIBILITIES / NOTES:
9+
* Versions of Terraform prior to v0.8.0 no longer supported.
10+
* The `common` module has been removed. Similar functionality has been moved into the `cluster` module. Existing resources will be recreated in an update.
11+
* The following input variables have been changed:
12+
* `agent_role_name (string, required)` -> (Removed. Use the `agent_role_id` output to add additional policies.)
13+
* `ami (string, required)` -> `ami_override (string, optional)`
14+
* `domain (string, optional)` -> Removed
15+
* `ecs_config (string, optional)` -> (Removed. Use `user_data_override` to specify custom configuraton.)
16+
* `hc_grace_period (string, default: 420)` -> `hc_grace_period (string, optional)`
17+
* `instance_type (string, default: t2.small)` -> `instance_type (string, required)`
18+
* `key_name (string, required)` -> `key_name (string, optional)`
19+
* `max_size (string, default: 3)` -> `max_size (string, required)`
20+
* `min_size (string, default: 3)` -> `min_size (string, required)`
21+
* `subnets (string, required)` -> `subnets (list, required)`
22+
23+
#### IMPROVEMENTS / NEW FEATURES:
24+
* Module now provides a default ECS configuration to the cluster hosts in the abscense of user supplied `user_data`.
25+
* The following parameters are now configurable:
26+
* `associate_public_ip_address`
27+
* `default_cooldown`
28+
* `desired_capacity`
29+
* `ebs_optimized`
30+
* `ebs_vol_del_on_term`
31+
* `ebs_vol_device_name`
32+
* `ebs_vol_encrypted`
33+
* `ebs_vol_iops`
34+
* `ebs_vol_size`
35+
* `ebs_vol_snapshot_id`
36+
* `ebs_vol_type`
37+
* `enable_monitoring`
38+
* `enabled_metrics`
39+
* `force_delete`
40+
* `iam_path`
41+
* `instance_based_naming_enabled`
42+
* `instance_name_prefix`
43+
* `instance_tags`
44+
* `logs_bucket_enabled`
45+
* `logs_bucket_name`
46+
* `placenment_group`
47+
* `placement_tenancy`
48+
* `protect_from_scale_in`
49+
* `root_vol_del_on_temr`
50+
* `root_vol_iops`
51+
* `root_vol_size`
52+
* `root_vol_type`
53+
* `security_groups`
54+
* `spot_price`
55+
* `suspended_processes`
56+
* `termination_policies`
57+
* `user_data_override`
58+
* `wait_for_capacity_timeout`

README.md

Lines changed: 76 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,113 @@
11
# Terraform AWS ECS Stack #
22
[![Circle CI](https://circleci.com/gh/unifio/terraform-aws-ecs/tree/master.svg?style=svg)](https://circleci.com/gh/unifio/terraform-aws-ecs/tree/master)
33

4-
Terraform module for the deployment of an AWS ECS cluster.
4+
Terraform module for the deployment of an AWS Elastic Container Service (ECS) cluster.
55

66
## Requirements ##
77

8-
- Terraform 0.6.16 or newer
8+
- Terraform 0.8.0 or newer
99
- AWS provider
1010

11-
## Common Module ##
12-
13-
The common module provisions the following resources for use with the ECS cluster:
14-
15-
- IAM role & instance profile
16-
- Default policies
17-
- S3 bucket for ECS logs
11+
## Cluster module ##
1812

19-
These resources can be shared amongst multiple clusters if desired.
13+
The cluster module provisions an ECS cluster and auto scaling group of agent instances.
2014

2115
### Input Variables ###
2216

23-
Name | Type | Default | Description
17+
#### Resource tags
18+
Name | Type | Required | Description
2419
--- | --- | --- | ---
25-
`bucket_prefix` | string | | Label to prepend S3 bucket names with.
26-
`stack_item_fullname` | string | | Long form descriptive name for this stack item. This value is used to create the 'application' resource tag for resources created by this stack item.
27-
`stack_item_label` | string | | Short form identifier for this stack. This value is used to create the 'Name' resource tag for resources created by this stack item, and also serves as a unique key for re-use.
28-
29-
### Usage ###
30-
31-
```js
32-
module "ecs" {
33-
source = "github.com/unifio/terraform-aws-ecs?ref=master//common"
34-
35-
bucket_prefix = "xmplco"
36-
stack_item_fullname = "Example Cluster"
37-
stack_item_label = "xmpl"
38-
}
39-
```
20+
`cluster_name` | string | yes | Name of the ECS based application stack.
21+
`stack_item_fullname` | string | yes | Long form descriptive name for this stack item. This value is used to create the 'application' resource tag for resources created by this stack item.
22+
`stack_item_label` | string | yes | Short form identifier for this stack. This value is used to create the 'Name' resource tag for resources created by this stack item, and also serves as a unique key for re-use.
4023

41-
### Outputs ###
42-
43-
Name | Type | Description
24+
#### VPC parameters
25+
Name | Type | Required | Description
4426
--- | --- | --- | ---
45-
`ecs_agent_role_arn` | string | ARN of the ECS IAM role.
46-
`ecs_agent_role_id` | string | ID of the ECS IAM role.
47-
`ecs_agent_role_name` | string | Name of the ECS IAM role.
48-
`ecs_agent_role_unique_id` | string | Unique ID of the ECS IAM role.
49-
`ecs_logs_bucket_name` | string | Name of the ECS S3 logs bucket.
50-
51-
## Cluster module ##
52-
53-
The cluster module provisions an ECS cluster and auto scaling group of agent instances.
27+
`subnets` | list | yes | A list of subnet IDs to launch resources in.
28+
`vpc_id` | string | yes | ID of the target VPC.
5429

55-
### Input Variables ###
56-
57-
Name | Type | Default | Description
30+
#### Cluster launch configuration parameters
31+
Name | Type | Required | Description
32+
--- | --- | --- | ---
33+
`ami_override` | string | | Custom Amazon Machine Image (AMI) to associate with the launch configuration.
34+
`associate_public_ip_address` | string | | Flag for associating public IP addresses with instances managed by the auto scaling group.
35+
`ebs_optimized` | string | | Flag to enable EBS optimization.
36+
`ebs_vol_del_on_term` | string | Default: true | Whether the volume should be destroyed on instance termination.
37+
`ebs_vol_device_name` | string | | The name of the device to mount.
38+
`ebs_vol_encrypted` | string | | Whether the volume should be encrypted or not. Do not use this option if you are using `ebs_vol_snapshot_id` as the encrypted flag will be determined by the snapshot.
39+
`ebs_vol_iops` | string | Default: 2000 | The amount of provisioned IOPS. Only utilized with `ebs_vol_type` of `io1`.
40+
`ebs_vol_size` | string | | The size of the volume in gigabytes.
41+
`ebs_vol_snapshot_id` | string | | The Snapshot ID to mount.
42+
`ebs_vol_type` | string | Default: gp2 | The type of volume. Valid values are `standard`, `gp2` and `io1`.
43+
`enable_monitoring` | string | | Flag to enable detailed monitoring.
44+
`iam_path` | string | Default: / | The path to the IAM resource.
45+
`instance_based_naming_enabled` | string | | Flag to enable instance-id based name tagging. Requires the AWS CLI to be installed on the instance. Currently only supports Linux based systems.
46+
`instance_name_prefix` | string | | String to prepend instance-id based name tags with.
47+
`instance_tags` | map | | Map of tags to add to instances. Requires the AWS CLI to be installed on the instance. Currently only supports Linux based systems.
48+
`instance_type` | string | yes | The EC2 instance type to associate with the launch configuration.
49+
`key_name` | string | | The SSH key pair to associate with the launch configuration.
50+
`logs_bucket_enabled` | string | Default: false | Flag for enabling access to the logs bucket from the instances.
51+
`logs_bucket_name` | string | | Name of the S3 bucket for logging.
52+
`placement_tenancy` | string | Default: default | The tenancy of the instance. Valid values are `default` or `dedicated`.
53+
`root_vol_del_on_term` | string | Default: true | Whether the volume should be destroyed on instance termination.
54+
`root_vol_iops` | string | Default: 2000 | The amount of provisioned IOPS. Only utilized with `root_vol_type` of `io1`.
55+
`root_vol_size` | string | | The size of the volume in gigabytes.
56+
`root_vol_type` | string | Default: gp2 | The type of volume. Valid values are `standard`, `gp2` and `io1`.
57+
`security_groups` | list | Default: [] | A list of security group IDs to associate with the instances.
58+
`spot_price` | string | | The price to use for reserving spot instances.
59+
`user_data_override` | string | | Custom instance initialization data to associate with the launch configuration.
60+
61+
#### Cluster auto scaling group parameters
62+
Name | Type | Required | Description
5863
--- | --- | --- | ---
59-
`agent_role_name` | string | | Name of the IAM role to be associated with the cluster members.
60-
`ami` | string | | Amazon Machine Image (AMI) of the cluster host.
61-
`cluster_name` | string | | Name of the ECS based application stack.
62-
`domain` | string | "" | The suffix domain name.
63-
`ecs_config` | string | "" | ECS agent configuration.
64-
`hc_check_type` | string | EC2 | Type of health check performed by the cluster. Valid values are 'ELB' or 'EC2'.
65-
`hc_grace_period` | string | 420 | Time allowed after an instance comes into service before checking health.
66-
`instance_type` | string | t2.small | EC2 instance type to associate with the cluster members.
67-
`key_name` | string | | SSH key pair to associate with the cluster members.
68-
`max_size` | string | 3 | Maximum number of instances allowed by the cluster.
69-
`min_size` | string | 3 | Minimum number of instances allowed by the cluster.
70-
`region` | string | us-east-1 | AWS region to be utilized.
71-
`stack_item_fullname` | string | | Long form descriptive name for this stack item. This value is used to create the 'application' resource tag for resources created by this stack item.
72-
`stack_item_label` | string | | Short form identifier for this stack. This value is used to create the 'Name' resource tag for resources created by this stack item, and also serves as a unique key for re-use.
73-
`subnets` | string | | List of VPC subnets to associate with the auto scaling group.
74-
`user_data` | string | "" | Instance initialization data to associate with the cluster members.
75-
`vpc_id` | string | | ID of the target VPC.
64+
`default_cooldown` | string | | The amount of time, in seconds, after a scaling activity completes before another scaling activity can start.
65+
`desired_capacity` | string | | The number of Amazon EC2 instances that should be running in the group.
66+
`enabled_metrics` | string | Default: [] | A list of metrics to collect. The allowed values are `GroupMinSize`, `GroupMaxSize`, `GroupDesiredCapacity`, `GroupInServiceInstances`, `GroupPendingInstances`, `GroupStandbyInstances`, `GroupTerminatingInstances`, `GroupTotalInstances`.
67+
`force_delete` | string | Default: false | Flag to allow deletion of the auto scaling group without waiting for all instances in the pool to terminate.
68+
`hc_check_type` | string | | Type of health check performed by the auto scaling group. Valid values are `ELB` or `EC2`.
69+
`hc_grace_period` | string | | Time allowed after an instance comes into service before checking health.
70+
`max_size` | string | yes | The maximum number of instances allowed by the auto scaling group.
71+
`min_size` | string | yes | Minimum number of instance to be maintained by the auto scaling group.
72+
`placement_group` | string | | The name of the placement group into which you'll launch your instances, if any.
73+
`protect_from_scale_in` | string | | Allows setting instance protection. The autoscaling group will not select instances with this setting for terminination during scale in events.
74+
`suspended_processes` | list | Default: [] | A list of processes to suspend for the AutoScaling Group. The allowed values are `Launch`, `Terminate`, `HealthCheck`, `ReplaceUnhealthy`, `AZRebalance`, `AlarmNotification`, `ScheduledActions`, `AddToLoadBalancer`. Note that if you suspend either the `Launch` or `Terminate` process types, it can prevent your autoscaling group from functioning properly.
75+
`termination_policies` | list | Default: [] | A list of policies to decide how the instances in the auto scale group should be terminated. The allowed values are `OldestInstance`, `NewestInstance`, `OldestLaunchConfiguration`, `ClosestToNextInstanceHour`, `Default`.
76+
`wait_for_capacity_timeout` | string | | A maximum duration that Terraform should wait for ASG managed instances to become healthy before timing out.
7677

7778
### Usage ###
7879

7980
```js
8081
module "cluster" {
8182
source = "github.com/unifio/terraform-aws-ecs?ref=master//cluster"
8283

83-
agent_role_name = "ecs"
84-
ami = "ami-xxxxxxxx"
84+
# Resource tags
8585
cluster_name = "xmpl-prod"
86-
domain = "service.consul"
87-
instance_type = "t2.small"
88-
key_name = "xmplprd"
89-
max_size = "3"
90-
min_size = "3"
91-
region = "us-east-1"
9286
stack_item_fullname = "Example Cluster"
9387
stack_item_label = "xmpl"
94-
subnets = "subnet-aaaaaaaa,subnet-bbbbbbbb,subnet-cccccccc"
95-
vpc_id = "vpc-xxxxxxxx"
88+
89+
# VPC parameters
90+
subnets = ["subnet-aaaaaaaa","subnet-bbbbbbbb","subnet-cccccccc"]
91+
vpc_id = "vpc-xxxxxxxx"
92+
93+
# LC parameters
94+
iam_path = "/tf_managed/"
95+
instance_based_naming_enabled = "true"
96+
instance_type = "t2.small"
97+
98+
# ASG parameters
99+
max_size = "3"
100+
min_size = "3"
96101
}
97102
```
98103

99104
### Outputs ###
100105

101106
Name | Type | Description
102107
--- | --- | --- | ---
103-
`cluster_id` | string | ID of the ECS cluster
104-
`cluster_name` | string | Name of the ECS cluster
108+
`agent_role_id` | string | ID of the ECS agent IAM role.
109+
`cluster_id` | string | ID of the ECS cluster.
110+
`cluster_name` | string | Name of the ECS cluster.
105111
`sg_id` | string | ID of the security group associated with the agent instances.
106112

107113
## Examples ##

Rakefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
require 'rake'
2+
require 'covalence/environment_tasks'
3+
require 'covalence/packer_tasks'
4+
require 'covalence/spec_tasks'

0 commit comments

Comments
 (0)