Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 3efb6f5

Browse files
committed
Improved syntax of DSL and the README according
1 parent 8db9918 commit 3efb6f5

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,22 @@ First, define a ECSFile in your project, to design your ECS cluster.
2222

2323
Example of a Rails app on ECS:
2424
```ruby
25-
aws_profile_id ENV['AWS_PROFILE_ID']
26-
aws_region ENV['AWS_REGION']
25+
aws_region ENV.fetch('AWS_REGION', 'eu-central-1')
2726

28-
repository ENV['REPO_URL']
29-
version ENV['CURRENT_VERSION']
27+
# Used to create ARNs
28+
aws_profile_id '123123'
3029

31-
cluster ''
30+
# Defining the cluster name
31+
cluster 'yourproject-cluster'
3232

3333
# This is used as a template for the next two containers, it will not be used inside a task
3434
container :base_container do
35+
image "#{ENV['REPO_URL']}:#{ENV['CURRENT_VERSION']}"
3536
load_envs 'envs/base.yml'
3637
load_envs 'envs/production.yml'
37-
secret key: 'RAILS_MASTER_KEY', value: 'railsMasterKey' # Taking the secret from AWS System Manager
38+
secret key: 'RAILS_MASTER_KEY', value: 'railsMasterKey' # Taking the secret from AWS System Manager with name "arn:aws:ssm:__AWS_REGION__:__AWS_PROFILE_ID__:parameter/railsMasterKey"
3839
working_directory '/app'
39-
cloudwatch 'yourproject' # Configuring cloudwatch logs
40+
cloudwatch_logs 'yourproject' # Configuring cloudwatch logs
4041
end
4142

4243
# The rails web application
@@ -58,6 +59,8 @@ end
5859
# A container to exec cron jobs
5960
container :cron, extends: :base_container do
6061
command 'rails', 'runner'
62+
63+
requires_compatibilities ['FARGATE']
6164
end
6265

6366
# The main task, having two containers
@@ -79,6 +82,8 @@ task :'yourproject-cron' do
7982
containers :cron
8083
cpu 256
8184
memory 1024
85+
execution_role 'ecsTaskExecutionRole'
86+
network_mode 'awsvpc'
8287

8388
tag 'product', 'yourproject'
8489
end

lib/ecs_deploy_cli/container.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def merge(other)
3636
_options.merge!(other_options)
3737
end
3838

39-
def cloudwatch(value)
39+
def cloudwatch_logs(value)
4040
_options[:log_configuration] = {
4141
log_driver: 'awslogs',
4242
options: {
@@ -49,7 +49,6 @@ def cloudwatch(value)
4949

5050
def as_definition
5151
{
52-
image: "#{@config[:repository]}:#{@config[:version]}",
5352
memory_reservation: nil,
5453
essential: true
5554
}.merge(_options)

lib/ecs_deploy_cli/file_parser.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
module EcsDeployCli
44
class FileParser
5-
def version(version)
6-
config[:version] = version
7-
end
8-
95
def aws_profile_id(value)
106
config[:aws_profile_id] = value
117
end
@@ -18,10 +14,6 @@ def stage(stage)
1814
config[:stage] = stage
1915
end
2016

21-
def repository(repository)
22-
config[:repository] = repository
23-
end
24-
2517
def container(container, extends: nil, &block)
2618
@containers ||= {}
2719
@containers[container] = Container.new(container, config)
@@ -97,7 +89,7 @@ def apply!
9789

9890
def ensure_required_params!
9991
[
100-
:aws_profile_id, :aws_region, :repository, :version, :cluster
92+
:aws_profile_id, :aws_region, :cluster
10193
].each { |key| raise "Missing required parameter #{key}" unless config[key] }
10294
end
10395

lib/ecs_deploy_cli/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module EcsDeployCli
2-
VERSION = '0.1.0'
2+
VERSION = '0.1.0-alpha'
33
end

0 commit comments

Comments
 (0)