Skip to content

Commit 9d186a0

Browse files
authored
Merge pull request #10 from webyneter/resolved-Brzhk-ecs-agent
Resolved brzhk ecs agent
2 parents d474052 + f05ffa4 commit 9d186a0

File tree

19 files changed

+104
-63
lines changed

19 files changed

+104
-63
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ RUN apt-get update \
1111
&& apt-get clean
1212

1313
COPY tools /usr/local/bin
14-
RUN curl -sL "https://releases.hashicorp.com/terraform/0.7.2/terraform_0.7.2_linux_amd64.zip"> terraform.zip \
14+
RUN curl -sL "https://releases.hashicorp.com/terraform/0.9.11/terraform_0.9.11_linux_amd64.zip"> terraform.zip \
1515
&& unzip terraform.zip \
1616
&& mv terraform /usr/local/bin
1717

18-
RUN curl -sL "https://releases.hashicorp.com/packer/0.10.1/packer_0.10.1_linux_amd64.zip" > packer.zip \
18+
RUN curl -sL "https://releases.hashicorp.com/packer/1.0.3/packer_1.0.3_linux_amd64.zip" > packer.zip \
1919
&& unzip packer.zip \
2020
&& mv packer /usr/local/bin
2121

22-
RUN curl -sL -o /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.1.3/dumb-init_1.1.3_amd64 && chmod +x /usr/local/bin/dumb-init
22+
RUN curl -sL -o /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && chmod +x /usr/local/bin/dumb-init
2323

2424
ENTRYPOINT ["/usr/local/bin/dumb-init"]
2525

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ endif
3333

3434
install-tools: $(tools)
3535

36+
ifeq (${platform},Darwin)
3637
/usr/local/bin/%: ./tools/%
3738
install -S -m 0755 $< /usr/local/bin
39+
else
40+
/usr/local/bin/%: ./tools/%
41+
install -m 0755 $< /usr/local/bin
42+
endif
3843

3944
amis:
4045
pack-ami build -p ./packer -t base -r

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ For more complicated service discovery which handles cases like versioning, we'd
198198

199199
### Bastion
200200

201-
The bastion host acts as the "jump point" for the rest of the infrastructure. Since most of our instances aren't exposed to the external internet, the bastion acts as the gatekeeper for any direct SSH access.
201+
The bastion host acts as the "jump point" for the rest of the infrastructure. Since most of our instances are not exposed to the external internet, the bastion acts as the gatekeeper for any direct SSH access.
202202

203203
The bastion is provisioned using the key name that you pass to the stack (and hopefully have stored somewhere). If you ever need to access an instance directly, you can do it by "jumping through" the bastion:
204204

defaults/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ variable "cidr" {
2323
}
2424

2525
variable "default_ecs_ami" {
26+
type = "map"
27+
2628
default = {
2729
us-east-1 = "ami-dde4e6ca"
2830
us-west-1 = "ami-6d21770d"
@@ -39,6 +41,8 @@ variable "default_ecs_ami" {
3941

4042
# http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/enable-access-logs.html#attach-bucket-policy
4143
variable "default_log_account_ids" {
44+
type = "map"
45+
4246
default = {
4347
us-east-1 = "127311923021"
4448
us-west-2 = "797873946194"

docs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Usage:
9292
# bastion
9393

9494
The bastion host acts as the "jump point" for the rest of the infrastructure.
95-
Since most of our instances aren't exposed to the external internet, the bastion acts as the gatekeeper for any direct SSH access.
95+
Since most of our instances are not exposed to the external internet, the bastion acts as the gatekeeper for any direct SSH access.
9696
The bastion is provisioned using the key name that you pass to the stack (and hopefully have stored somewhere).
9797
If you ever need to access an instance directly, you can do it by "jumping through" the bastion.
9898

@@ -134,7 +134,7 @@ Usage:
134134
# defaults
135135

136136
This module is used to set configuration defaults for the AWS infrastructure.
137-
It doesn't provide much value when used on its own because terraform makes it
137+
It does not provide much value when used on its own because terraform makes it
138138
hard to do dynamic generations of things like subnets, for now it's used as
139139
a helper module for the stack.
140140

@@ -252,7 +252,7 @@ Usage:
252252
| instance_type | The instance type to use, e.g t2.small | - | yes |
253253
| instance_ebs_optimized | When set to true the instance will be launched with EBS optimized turned on | `true` | no |
254254
| min_size | Minimum instance count | `3` | no |
255-
| max_size | Maxmimum instance count | `100` | no |
255+
| max_size | Maximum instance count | `100` | no |
256256
| desired_capacity | Desired instance count | `3` | no |
257257
| associate_public_ip_address | Should created instances be publicly accessible (if the SG allows) | `false` | no |
258258
| root_volume_size | Root volume size in GB | `25` | no |

iam-role/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ EOF
9595
}
9696

9797
resource "aws_iam_instance_profile" "default_ecs" {
98-
name = "ecs-instance-profile-${var.name}-${var.environment}"
99-
path = "/"
100-
role = "${aws_iam_role.default_ecs_role.name}"
98+
name = "ecs-instance-profile-${var.name}-${var.environment}"
99+
path = "/"
100+
role = "${aws_iam_role.default_ecs_role.name}"
101101
}
102102

103103
output "default_ecs_role_id" {

main.tf

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,31 @@ variable "cidr" {
4646
}
4747

4848
variable "internal_subnets" {
49+
type = "list"
4950
description = "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"
50-
default = ["10.30.0.0/19" ,"10.30.64.0/19", "10.30.128.0/19"]
51+
default = ["10.30.0.0/19", "10.30.64.0/19", "10.30.128.0/19"]
5152
}
5253

5354
variable "external_subnets" {
55+
type = "list"
5456
description = "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"
5557
default = ["10.30.32.0/20", "10.30.96.0/20", "10.30.160.0/20"]
5658
}
5759

5860
variable "availability_zones" {
61+
type = "list"
5962
description = "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"
6063
default = ["us-west-2a", "us-west-2b", "us-west-2c"]
6164
}
6265

6366
variable "bastion_instance_type" {
6467
description = "Instance type for the bastion"
65-
default = "t2.micro"
68+
default = "t2.micro"
6669
}
6770

6871
variable "ecs_cluster_name" {
6972
description = "the name of the cluster, if not specified the variable name will be used"
70-
default = ""
73+
default = ""
7174
}
7275

7376
variable "ecs_instance_type" {
@@ -207,28 +210,28 @@ module "iam_role" {
207210
}
208211

209212
module "ecs_cluster" {
210-
source = "./ecs-cluster"
211-
name = "${coalesce(var.ecs_cluster_name, var.name)}"
212-
environment = "${var.environment}"
213-
vpc_id = "${module.vpc.id}"
214-
image_id = "${coalesce(var.ecs_ami, module.defaults.ecs_ami)}"
215-
subnet_ids = "${module.vpc.internal_subnets}"
216-
key_name = "${var.key_name}"
217-
instance_type = "${var.ecs_instance_type}"
218-
instance_ebs_optimized = "${var.ecs_instance_ebs_optimized}"
219-
iam_instance_profile = "${module.iam_role.profile}"
220-
min_size = "${var.ecs_min_size}"
221-
max_size = "${var.ecs_max_size}"
222-
desired_capacity = "${var.ecs_desired_capacity}"
223-
region = "${var.region}"
224-
availability_zones = "${module.vpc.availability_zones}"
225-
root_volume_size = "${var.ecs_root_volume_size}"
226-
docker_volume_size = "${var.ecs_docker_volume_size}"
227-
docker_auth_type = "${var.ecs_docker_auth_type}"
228-
docker_auth_data = "${var.ecs_docker_auth_data}"
229-
security_groups = "${coalesce(var.ecs_security_groups, join(",", compact(concat(split(",", "${format("%s,%s,%s", module.security_groups.internal_ssh, module.security_groups.internal_elb, module.security_groups.external_elb)}"), split(",", "${var.ecs_extra_security_groups}")))))}"
230-
extra_cloud_config_type = "${var.extra_cloud_config_type}"
231-
extra_cloud_config_content = "${var.extra_cloud_config_content}"
213+
source = "./ecs-cluster"
214+
name = "${coalesce(var.ecs_cluster_name, var.name)}"
215+
environment = "${var.environment}"
216+
vpc_id = "${module.vpc.id}"
217+
image_id = "${coalesce(var.ecs_ami, module.defaults.ecs_ami)}"
218+
subnet_ids = "${module.vpc.internal_subnets}"
219+
key_name = "${var.key_name}"
220+
instance_type = "${var.ecs_instance_type}"
221+
instance_ebs_optimized = "${var.ecs_instance_ebs_optimized}"
222+
iam_instance_profile = "${module.iam_role.profile}"
223+
min_size = "${var.ecs_min_size}"
224+
max_size = "${var.ecs_max_size}"
225+
desired_capacity = "${var.ecs_desired_capacity}"
226+
region = "${var.region}"
227+
availability_zones = "${module.vpc.availability_zones}"
228+
root_volume_size = "${var.ecs_root_volume_size}"
229+
docker_volume_size = "${var.ecs_docker_volume_size}"
230+
docker_auth_type = "${var.ecs_docker_auth_type}"
231+
docker_auth_data = "${var.ecs_docker_auth_data}"
232+
security_groups = "${coalesce(var.ecs_security_groups, format("%s,%s,%s", module.security_groups.internal_ssh, module.security_groups.internal_elb, module.security_groups.external_elb))}"
233+
extra_cloud_config_type = "${var.extra_cloud_config_type}"
234+
extra_cloud_config_content = "${var.extra_cloud_config_content}"
232235
}
233236

234237
module "s3_logs" {

packer/base/packer.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
---
2+
# Latest xenial 16.04 LTS amd64 hvm:ebs-ssd Releases
3+
# us-gov-west-1 20170619.1 ami-939412f2
4+
# us-east-2 20170619.1 ami-8b92b4ee
5+
# sa-east-1 20170619.1 ami-34afc458
6+
# eu-central-1 20170619.1 ami-1c45e273
7+
# us-west-1 20170619.1 ami-73f7da13
8+
# us-west-2 20170619.1 ami-835b4efa
9+
# ap-northeast-2 20170619.1 ami-94d20dfa
10+
# ca-central-1 20170619.1 ami-7ed56a1a
11+
# eu-west-2 20170619.1 ami-cc7066a8
12+
# ap-southeast-1 20170619.1 ami-2378f540
13+
# eu-west-1 20170619.1 ami-6d48500b
14+
# ap-southeast-2 20170619.1 ami-e94e5e8a
15+
# ap-northeast-1 20170619.1 ami-785c491f
16+
# us-east-1 20170619.1 ami-d15a75c7
17+
# ap-south-1 20170619.1 ami-49e59a26
18+
# cn-north-1 20170303 ami-a163b4cc
19+
20+
221
# https://www.packer.io/docs/builders/amazon-ebs.html
322
ami:
4-
source_ami: ami-e6d5d2f1
23+
source_ami: ami-d15a75c7
524
region: us-east-1
625
instance_type: c4.2xlarge
726
ssh_username: ubuntu
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Package: *
2+
Pin: release o=Docker
3+
Pin-Priority: 900

packer/base/scripts/base.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/bash
22
set -e
33

4+
export DEBIAN_FRONTEND=noninteractive
45
systemctl disable apt-daily.service
56
systemctl disable apt-daily.timer
67

78
apt-get update -y
8-
apt-get upgrade -y
99

1010
apt-get install -y \
1111
build-essential \
@@ -35,8 +35,12 @@ apt-get install -y \
3535
ntp \
3636
logrotate \
3737
dhcping \
38+
nfs-common \
39+
curl \
40+
unzip \
41+
jq \
3842
dhcpdump
3943

4044
pip install awscli
4145

42-
apt-get dist-upgrade -y
46+
apt-get upgrade -y

0 commit comments

Comments
 (0)