Class: ECSUtil::Commands::RunCommand
- Inherits:
-
ECSUtil::Command
- Object
- ECSUtil::Command
- ECSUtil::Commands::RunCommand
- Defined in:
- lib/ecsutil/commands/run.rb
Instance Attribute Summary
Attributes inherited from ECSUtil::Command
Instance Method Summary collapse
Methods inherited from ECSUtil::Command
Methods included from Shared
#deregister_scheduled_tasks, #deregister_secrets, #deregister_services, #deregister_tasks, #load_active_task_definitions, #load_secrets, #load_services
Methods included from Vault
#vault_edit, #vault_read, #vault_write
Methods included from AWS
#aws_call, #create_service, #degerister_task_definition, #delete_rule, #delete_service, #describe_service, #describe_services, #fetch_parameter_store_keys, #generate_event_rule, #generate_event_target, #generate_service, #generate_task_definition, #list_active_task_definitions, #list_rules, #list_services, #put_rule, #put_targets, #register_task_definition, #update_service
Methods included from Helpers
#array_hash, #confirm, #json_file, #parse_env_data, #step_info, #terminate
Constructor Details
This class inherits a constructor from ECSUtil::Command
Instance Method Details
#run ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ecsutil/commands/run.rb', line 2 def run task_name = args.shift terminate("Task name is required") unless task_name task = config["tasks"][task_name] family = sprintf("%s-%s-%s", config["app"], config["env"], task_name) arn = load_active_task_definitions.find do |task_arn| task_arn.split("/", 2).last.start_with?(family) end if !arn terminate "Cant find task definition for #{family}" end opts = { startedBy: config["user"], cluster: config["cluster"], taskDefinition: arn, launchType: "FARGATE", networkConfiguration: { awsvpcConfiguration: { subnets: [config["subnets"]].flatten, securityGroups: [task["security_groups"]].flatten, "assignPublicIp": "ENABLED" } } } if args && args.any? step_info "Using override command: #{args}" opts[:overrides] = { containerOverrides: [ { name: task_name, command: args, } ] } end step_info "Running task using #{arn}" aws_call("ecs", "run-task", opts) end |