shiprails 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/lib/shiprails/ship/deploy.rb +1 -0
- data/lib/shiprails/ship/setup.rb +29 -1
- data/lib/shiprails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4171fc524487ffbff3c3e0d06fc4349820514651
|
4
|
+
data.tar.gz: a58bdc054d7caf03b51ac5badff5e4d4768ae402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90509f89375d0705f7d2ed73a8ce94598751fbe2bb27c4f8f866b776265e19be74bd0f7208b12fe79affe22db7c45e8f9e517e43bd1977f9af90b289c0d3be8b
|
7
|
+
data.tar.gz: fac8e27fb72f129ef5a6b26c7fb248ab06c259af6b8366a08c8839cfd622baa0923ad55316e7becb2680fe3bc9e8ee067a386964c3ec6195eccc727bbcdaa7a4
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.3
|
@@ -107,6 +107,7 @@ module Shiprails
|
|
107
107
|
{ name: "GIT_SHA", value: git_sha },
|
108
108
|
{ name: "RACK_ENV", value: environment_name },
|
109
109
|
{ name: "S3_CONFIG_BUCKET", value: config_s3_bucket },
|
110
|
+
{ name: "S3_CONFIG_ENVIRONMENT", value: environment_name },
|
110
111
|
{ name: "S3_CONFIG_REVISION", value: config_s3_version }
|
111
112
|
]
|
112
113
|
say "Updated #{service_name} container (#{image_name})."
|
data/lib/shiprails/ship/setup.rb
CHANGED
@@ -35,6 +35,13 @@ module Shiprails
|
|
35
35
|
say "Created CloudWatch Log groups.", :green
|
36
36
|
end
|
37
37
|
|
38
|
+
def create_ecs_task_role
|
39
|
+
#
|
40
|
+
# TODO: create role for tasks to read config from S3
|
41
|
+
#
|
42
|
+
say "TODO: create task role", :blue
|
43
|
+
end
|
44
|
+
|
38
45
|
def create_ecs_tasks
|
39
46
|
say "Creating ECS tasks..."
|
40
47
|
configuration[:services].each do |service_name, service|
|
@@ -53,6 +60,10 @@ module Shiprails
|
|
53
60
|
task_definition.delete :requires_attributes
|
54
61
|
say "Updating ECS task (#{task_name})."
|
55
62
|
rescue Aws::ECS::Errors::ClientException => e
|
63
|
+
#
|
64
|
+
# TODO: set task role
|
65
|
+
#
|
66
|
+
say "TODO: set task role", :blue
|
56
67
|
task_definition = {
|
57
68
|
container_definitions: [
|
58
69
|
{
|
@@ -63,6 +74,7 @@ module Shiprails
|
|
63
74
|
{ name: "AWS_REGION", value: region_name.to_s },
|
64
75
|
{ name: "RACK_ENV", value: environment_name },
|
65
76
|
{ name: "S3_CONFIG_BUCKET", value: config_s3_bucket },
|
77
|
+
{ name: "S3_CONFIG_ENVIRONMENT", value: environment_name },
|
66
78
|
{ name: "S3_CONFIG_REVISION", value: "0" }
|
67
79
|
],
|
68
80
|
image: "#{region[:repository_url]}:latest",
|
@@ -137,6 +149,22 @@ module Shiprails
|
|
137
149
|
ecs = Aws::ECS::Client.new(region: region_name.to_s)
|
138
150
|
elb = Aws::ElasticLoadBalancingV2::Client.new(region: region_name.to_s)
|
139
151
|
region[:environments].each do |environment_name|
|
152
|
+
role_name = "#{project_name}_#{environment_name}-ecsServiceRole"
|
153
|
+
iam = Aws::IAM::Client.new
|
154
|
+
begin
|
155
|
+
role = iam.create_role({
|
156
|
+
assume_role_policy_document: "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":[\"ecs.amazonaws.com\"]},\"Action\":[\"sts:AssumeRole\"]}]}",
|
157
|
+
path: "/",
|
158
|
+
role_name: role_name,
|
159
|
+
})
|
160
|
+
iam.attach_role_policy({
|
161
|
+
policy_arn: "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceRole",
|
162
|
+
role_name: role_name,
|
163
|
+
})
|
164
|
+
say "Created ECS Service role..."
|
165
|
+
rescue Aws::IAM::Errors::EntityAlreadyExists => err
|
166
|
+
end
|
167
|
+
|
140
168
|
cluster_name = "#{project_name}_#{environment_name}"
|
141
169
|
task_name = "#{image_name}_#{environment_name}"
|
142
170
|
task_definition_response = ecs.describe_task_definition({task_definition: task_name})
|
@@ -153,7 +181,7 @@ module Shiprails
|
|
153
181
|
}
|
154
182
|
(service[:ports] || []).each do |port|
|
155
183
|
if yes? "Should port #{port} for #{image_name} be load balanced in #{environment_name}?"
|
156
|
-
ecs_service[:role] =
|
184
|
+
ecs_service[:role] = role_name
|
157
185
|
load_balancers = elb.describe_load_balancers.to_h
|
158
186
|
say "EC2 Load Balancers"
|
159
187
|
choices = ["CREATE NEW ELB"] + load_balancers[:load_balancers].map{|lb| "#{lb[:load_balancer_name]} (#{lb[:load_balancer_arn]})" }
|
data/lib/shiprails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shiprails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zane Shannon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
189
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
190
|
+
rubygems_version: 2.6.11
|
191
191
|
signing_key:
|
192
192
|
specification_version: 4
|
193
193
|
summary: Shiprails helps you deploy Rails to AWS ECS.
|