class Fog::AWS::ECS::Real
Attributes
Public Class Methods
Initialize connection to ECS
Notes¶ ↑
options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection
Examples¶ ↑
ecs = ECS.new( :aws_access_key_id => your_aws_access_key_id, :aws_secret_access_key => your_aws_secret_access_key )
Parameters¶ ↑
-
options<~Hash> - config arguments for connection. Defaults to {}.
-
region<~String> - optional region to use. For instance, 'eu-west-1', 'us-east-1' and etc.
-
Returns¶ ↑
# File lib/fog/aws/ecs.rb, line 58 def initialize(options={}) @use_iam_profile = options[:use_iam_profile] @instrumentor = options[:instrumentor] @instrumentor_name = options[:instrumentor_name] || 'fog.aws.ecs' @connection_options = options[:connection_options] || {} @region = options[:region] || 'us-east-1' @host = options[:host] || "ecs.#{@region}.amazonaws.com" @path = options[:path] || '/' @persistent = options[:persistent] || false @port = options[:port] || 443 @scheme = options[:scheme] || 'https' @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options) @version = options[:version] || '2014-11-13' setup_credentials(options) end
Public Instance Methods
Creates a new Amazon ECS
cluster docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateCluster.html
Parameters¶ ↑
-
clusterName <~String> - The name of your cluster.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'Cluster' <~Hash> - The full description of your new cluster
-
-
# File lib/fog/aws/requests/ecs/create_cluster.rb, line 15 def create_cluster(params={}) request({ 'Action' => 'CreateCluster', :parser => Fog::Parsers::AWS::ECS::CreateCluster.new }.merge(params)) end
Runs and maintains a desired number of tasks from a specified task definition. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html
Parameters¶ ↑
-
clientToken <~String> - unique, case-sensitive identifier you provide to ensure the idempotency of the request.
-
cluster <~String> - short name or full Amazon Resource Name (ARN) of the cluster that you want to run your service on.
-
desiredCount <~Integer> - number of instantiations of the specified task definition that you would like to place and keep running on your cluster.
-
loadBalancers <~Array> - list of load balancer objects, containing the load balancer name, the container name (as it appears in a container definition), and the container port to access from the load balancer.
-
role <~String> - name or full Amazon Resource Name (ARN) of the
IAM
role that allows your AmazonECS
container agent to make calls to your load balancer on your behalf. -
serviceName <~String> - name of your service
-
taskDefinition <~String> - family and revision (family:revision) or full Amazon Resource Name (ARN) of the task definition that you want to run in your service
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'Service' <~Hash> - The full description of your new service
-
-
# File lib/fog/aws/requests/ecs/create_service.rb, line 21 def create_service(params={}) if load_balancers = params.delete('loadBalancers') params.merge!(Fog::AWS.indexed_param('loadBalancers.member', [*load_balancers])) end request({ 'Action' => 'CreateService', :parser => Fog::Parsers::AWS::ECS::CreateService.new }.merge(params)) end
Deletes the specified cluster docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DeleteCluster.html
Parameters¶ ↑
-
cluster <~String> - The short name or full Amazon Resource Name (ARN) of the cluster that you want to delete
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'Cluster'<~Hash> - The full description of the deleted cluster
-
-
# File lib/fog/aws/requests/ecs/delete_cluster.rb, line 15 def delete_cluster(params={}) request({ 'Action' => 'DeleteCluster', :parser => Fog::Parsers::AWS::ECS::DeleteCluster.new }.merge(params)) end
Deletes a specified service within a cluster. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DeleteService.html
Parameters¶ ↑
-
cluster <~String> - name of the cluster that hosts the service you want to delete.
-
service <~String> - name of the service you want to delete.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'Service'<~Hash> - The full description of the deleted service
-
-
# File lib/fog/aws/requests/ecs/delete_service.rb, line 16 def delete_service(params={}) request({ 'Action' => 'DeleteService', :parser => Fog::Parsers::AWS::ECS::DeleteService.new }.merge(params)) end
Deregisters an Amazon ECS
container instance from the specified cluster. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DeregisterContainerInstance.html
Parameters¶ ↑
-
cluster <~String> - short name or full ARN of the cluster that hosts the container instance you want to deregister.
-
containerInstance <~String> - container instance UUID or full Amazon Resource Name (ARN) of the container instance you want to deregister.
-
force <~Boolean> - Force the deregistration of the container instance.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'ContainerInstance' <~Hash> - full description of the deregistered container instance
-
-
# File lib/fog/aws/requests/ecs/deregister_container_instance.rb, line 17 def deregister_container_instance(params={}) request({ 'Action' => 'DeregisterContainerInstance', :parser => Fog::Parsers::AWS::ECS::DeregisterContainerInstance.new }.merge(params)) end
Deregisters the specified task definition. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DeregisterTaskDefinition.html
Parameters¶ ↑
-
taskDefinition <~String> - The family and revision (family:revision) or full Amazon Resource Name (ARN) of the task definition that you want to deregister.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'TaskDefinition' <~Hash> - full description of the deregistered task
-
-
# File lib/fog/aws/requests/ecs/deregister_task_definition.rb, line 15 def deregister_task_definition(params={}) request({ 'Action' => 'DeregisterTaskDefinition', :parser => Fog::Parsers::AWS::ECS::DeregisterTaskDefinition.new }.merge(params)) end
Describes one or more of your clusters. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeClusters.html
Parameters¶ ↑
-
clusters <~Array> - list of cluster names or full cluster Amazon Resource Name (ARN) entries
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'clusters' <~Array> - The list of clusters
-
'failures' <~Array> - The list of failures (if any)
-
-
# File lib/fog/aws/requests/ecs/describe_clusters.rb, line 16 def describe_clusters(params={}) if members = params.delete('clusters') params.merge!(Fog::AWS.indexed_param('clusters.member', [*members])) end request({ 'Action' => 'DescribeClusters', :parser => Fog::Parsers::AWS::ECS::DescribeClusters.new }.merge(params)) end
Describes Amazon EC2 Container Service container instances. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeContainerInstances.html
Parameters¶ ↑
-
cluster <~String> - short name or full ARN of the cluster that hosts the container instances you want to describe.
-
containerInstances <~Array> - list of container instance UUIDs or full Amazon Resource Name (ARN) entries.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'containerInstances' <~Array> - list of container instances.
-
'failures' <~Array> - list of failures (if any)
-
-
# File lib/fog/aws/requests/ecs/describe_container_instances.rb, line 17 def describe_container_instances(params={}) if instances = params.delete('containerInstances') params.merge!(Fog::AWS.indexed_param('containerInstances.member', [*instances])) end request({ 'Action' => 'DescribeContainerInstances', :parser => Fog::Parsers::AWS::ECS::DescribeContainerInstances.new }.merge(params)) end
Describes the specified services running in your cluster. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeServices.html
Parameters¶ ↑
-
cluster <~String> - name of the cluster that hosts the service you want to describe.
-
services <~Array> - list of services you want to describe.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'services' <~Array> - The list of services described.
-
'failures' <~Array> - The list of failures associated with the call (if any).
-
-
# File lib/fog/aws/requests/ecs/describe_services.rb, line 17 def describe_services(params={}) if services = params.delete('services') params.merge!(Fog::AWS.indexed_param('services.member', [*services])) end request({ 'Action' => 'DescribeServices', :parser => Fog::Parsers::AWS::ECS::DescribeServices.new }.merge(params)) end
Describes a task definition docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTaskDefinition.html
Parameters¶ ↑
-
taskDefinition <~String> - The family for the latest revision, family and revision (family:revision) for a specific revision in the family, or full Amazon Resource Name (ARN) of the task definition that you want to describe.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'taskDefinition' <~Hash> - full task definition description
-
-
# File lib/fog/aws/requests/ecs/describe_task_definition.rb, line 15 def describe_task_definition(params={}) request({ 'Action' => 'DescribeTaskDefinition', :parser => Fog::Parsers::AWS::ECS::DescribeTaskDefinition.new }.merge(params)) end
Describes a specified task or tasks. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTasks.html
Parameters¶ ↑
-
cluster <~String> - short name or full Amazon Resource Name (ARN) of the cluster that hosts the task you want to describe
-
tasks <~Array> - space-separated list of task UUIDs or full Amazon Resource Name (ARN) entries
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'tasks' <~Array> - The list of tasks
-
'failures' <~Array> - The list of failures (if any)
-
-
# File lib/fog/aws/requests/ecs/describe_tasks.rb, line 17 def describe_tasks(params={}) if tasks = params.delete('tasks') params.merge!(Fog::AWS.indexed_param('tasks.member', [*tasks])) end request({ 'Action' => 'DescribeTasks', :parser => Fog::Parsers::AWS::ECS::DescribeTasks.new }.merge(params)) end
Returns a list of existing clusters docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListClusters.html
Parameters¶ ↑
-
maxResults <~Integer> - The maximum number of cluster results returned by ListClusters in paginated output.
-
nextToken <~String> - The nextToken value returned from a previous paginated ListClusters request where maxResults was used.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'ClusterArns' <~Array> - list of full Amazon Resource Name (ARN) entries for each cluster associated with your account.
-
'NextToken' <~String> - nextToken value to include in a future ListClusters request.
-
-
# File lib/fog/aws/requests/ecs/list_clusters.rb, line 17 def list_clusters(params={}) request({ 'Action' => 'ListClusters', :parser => Fog::Parsers::AWS::ECS::ListClusters.new }.merge(params)) end
Returns a list of container instances in a specified cluster. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListContainerInstances.html
Parameters¶ ↑
-
cluster <~String> - short name or full Amazon Resource Name (ARN) of the cluster that hosts the container instances you want to list.
-
maxResults <~Integer> - maximum number of container instance results returned by ListContainerInstances in paginated output.
-
nextToken <~String> - nextToken value returned from a previous paginated ListContainerInstances request where maxResults was used.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'ContainerInstanceArns' <~Array> - list of container instance full ARN entries for each container instance associated with the specified cluster.
-
'NextToken' <~String> - nextToken value to include in a future ListContainerInstances request.
-
-
# File lib/fog/aws/requests/ecs/list_container_instances.rb, line 18 def list_container_instances(params={}) request({ 'Action' => 'ListContainerInstances', :parser => Fog::Parsers::AWS::ECS::ListContainerInstances.new }.merge(params)) end
Lists the services that are running in a specified cluster. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListServices.html
Parameters¶ ↑
-
cluster <~String> - The short name or full Amazon Resource Name (ARN) of the cluster that hosts the services you want to list.
-
maxResults <~Integer> - The maximum number of container instance results returned by ListServices in paginated output.
-
nextToken <~String> - The nextToken value returned from a previous paginated ListServices request where maxResults was used.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'ServiceArns' <~Array> - list of full Amazon Resource Name (ARN) entries for each service associated with the specified cluster.
-
'NextToken' <~String> - nextToken value to include in a future ListServices request.
-
-
# File lib/fog/aws/requests/ecs/list_services.rb, line 18 def list_services(params={}) request({ 'Action' => 'ListServices', :parser => Fog::Parsers::AWS::ECS::ListServices.new }.merge(params)) end
Returns a list of task definition families that are registered to your account. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListTaskDefinitionFamilies.html
Parameters¶ ↑
-
familyPrefix <~String> - familyPrefix is a string that is used to filter the results of ListTaskDefinitionFamilies.
-
maxResults <~Integer> - maximum number of task definition family results returned by ListTaskDefinitionFamilies in paginated output.
-
nextToken <~String> - nextToken value returned from a previous paginated ListTaskDefinitionFamilies request where maxResults was used.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'Families' <~Array> - list of task definition family names that match the ListTaskDefinitionFamilies request.
-
'NextToken' <~String> - nextToken value to include in a future ListTaskDefinitionFamilies request.
-
-
# File lib/fog/aws/requests/ecs/list_task_definition_families.rb, line 18 def list_task_definition_families(params={}) request({ 'Action' => 'ListTaskDefinitionFamilies', :parser => Fog::Parsers::AWS::ECS::ListTaskDefinitionFamilies.new }.merge(params)) end
Returns a list of task definitions that are registered to your account docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListTaskDefinitions.html
Parameters¶ ↑
-
familyPrefix <~String> - The full family name that you want to filter the ListTaskDefinitions results with.
-
maxResults <~Integer> - The maximum number of task definition results returned by ListTaskDefinitions in paginated output.
-
nextToken <~String> - The nextToken value returned from a previous paginated ListTaskDefinitions request.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'TaskDefinitionArns' <~Array> - list of task definition Amazon Resource Name (ARN) entries for the ListTaskDefintions request.
-
'NextToken' <~String> - nextToken value to include in a future ListTaskDefinitions request
-
-
# File lib/fog/aws/requests/ecs/list_task_definitions.rb, line 18 def list_task_definitions(params={}) request({ 'Action' => 'ListTaskDefinitions', :parser => Fog::Parsers::AWS::ECS::ListTaskDefinitions.new }.merge(params)) end
Returns a list of tasks for a specified cluster. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListTasks.html
Parameters¶ ↑
-
cluster <~String> - short name or full Amazon Resource Name (ARN) of the cluster that hosts the tasks you want to list.
-
containerInstance <~String> - container instance UUID or full Amazon Resource Name (ARN) of the container instance that you want to filter the ListTasks results with.
-
family <~String> - name of the family that you want to filter the ListTasks results with.
-
maxResults <~Integer> - maximum number of task results returned by ListTasks in paginated output.
-
nextToken <~String> - nextToken value returned from a previous paginated ListTasks request where maxResults was used.
-
serviceName <~String> - name of the service that you want to filter the ListTasks results with.
-
startedBy <~String> - startedBy value that you want to filter the task results with.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'TaskArns' <~Array> - list of task Amazon Resource Name (ARN) entries for the ListTasks request.
-
'NextToken' <~String> - nextToken value to include in a future ListTasks request.
-
-
# File lib/fog/aws/requests/ecs/list_tasks.rb, line 22 def list_tasks(params={}) request({ 'Action' => 'ListTasks', :parser => Fog::Parsers::AWS::ECS::ListTasks.new }.merge(params)) end
Registers a new task definition from the supplied family and containerDefinitions. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RegisterTaskDefinition.html
Parameters¶ ↑
-
containerDefinitions <~Array> - list of container definitions in JSON format that describe the different containers that make up your task.
-
family <~String> - family for a task definition, which allows you to track multiple versions of the same task definition.
-
volumes <~String> - list of volume definitions in JSON format that containers in your task may use.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'TaskDefinition' <~Array> - full task definition description registered
-
-
# File lib/fog/aws/requests/ecs/register_task_definition.rb, line 17 def register_task_definition(params={}) serialized_params = {} params.each_pair do |k,v| serialized_params.merge!(Fog::AWS.serialize_keys(k, v)) end request({ 'Action' => 'RegisterTaskDefinition', :parser => Fog::Parsers::AWS::ECS::RegisterTaskDefinition.new }.merge(serialized_params)) end
# File lib/fog/aws/ecs.rb, line 76 def reload @connection.reset end
Start a task using random placement and the default Amazon ECS
scheduler. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RunTask.html
Parameters¶ ↑
-
cluster <~String> - short name or full Amazon Resource Name (ARN) of the cluster that you want to run your task on.
-
count <~Integer> - number of instantiations of the specified task that you would like to place on your cluster.
-
overrides <~Hash> - list of container overrides.
-
startedBy <~String> - optional tag specified when a task is started
-
taskDefinition <~String> - family and revision (family:revision) or full ARN of the task definition that you want to run.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'tasks' <~Array> - full description of the tasks that were run.
-
'failures' <~Array> - Any failed tasks from your RunTask action are listed here.
-
-
# File lib/fog/aws/requests/ecs/run_task.rb, line 20 def run_task(params={}) if overrides = params.delete('overrides') serialized_overrides = {} if overrides.is_a?(Hash) overrides.each_pair do |k,v| serialized_overrides.merge!(Fog::AWS.serialize_keys(k, v)) end end params.merge!('overrides' => serialized_overrides) end request({ 'Action' => 'RunTask', :parser => Fog::Parsers::AWS::ECS::RunTask.new }.merge(params)) end
Starts a new task from the specified task definition on the specified container instance or instances. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_StartTask.html
Parameters¶ ↑
-
cluster <~String> - short name or full Amazon Resource Name (ARN) of the cluster that you want to start your task on.
-
containerInstances <~Array> - container instance UUIDs or full ARN entries for the container instances on which you would like to place your task.
-
overrides <~Hash> - list of container overrides.
-
startedBy <~String> - optional tag specified when a task is started
-
taskDefinition <~String> - family and revision (family:revision) or full ARN of the task definition that you want to start.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'tasks' <~Array> - full description of the tasks that were started.
-
'failures' <~Array> - Any failed tasks from your StartTask action are listed here.
-
-
# File lib/fog/aws/requests/ecs/start_task.rb, line 20 def start_task(params={}) if container_instances = params.delete('containerInstances') params.merge!(Fog::AWS.indexed_param('containerInstances.member', [*container_instances])) end if overrides = params.delete('overrides') serialized_overrides = {} if overrides.is_a?(Hash) overrides.each_pair do |k,v| serialized_overrides.merge!(Fog::AWS.serialize_keys(k, v)) end end params.merge!('overrides' => serialized_overrides) end request({ 'Action' => 'StartTask', :parser => Fog::Parsers::AWS::ECS::StartTask.new }.merge(params)) end
Stops a running task. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_StopTask.html
Parameters¶ ↑
-
cluster <~String> - short name or full Amazon Resource Name (ARN) of the cluster that hosts the task you want to stop.
-
task <~String> - task UUIDs or full Amazon Resource Name (ARN) entry of the task you would like to stop.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'Task' <~Hash> - The full description of the stopped task.
-
-
# File lib/fog/aws/requests/ecs/stop_task.rb, line 16 def stop_task(params={}) request({ 'Action' => 'StopTask', :parser => Fog::Parsers::AWS::ECS::StopTask.new }.merge(params)) end
Modify the desired count or task definition used in a service. docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html
Parameters¶ ↑
-
cluster <~String> - short name or full Amazon Resource Name (ARN) of the cluster that your service is running on.
-
desiredCount <~Integer> - number of instantiations of the task that you would like to place and keep running in your service.
-
service <~String> - name of the service that you want to update.
-
taskDefinition <~String> - family and revision (family:revision) or full Amazon Resource Name (ARN) of the task definition that you want to run in your service.
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'Service'<~Hash> - The full description of the updated cluster
-
-
# File lib/fog/aws/requests/ecs/update_service.rb, line 18 def update_service(params={}) request({ 'Action' => 'UpdateService', :parser => Fog::Parsers::AWS::ECS::UpdateService.new }.merge(params)) end
Private Instance Methods
# File lib/fog/aws/ecs.rb, line 120 def _request(body, headers, idempotent, parser) @connection.request({ :body => body, :expects => 200, :headers => headers, :idempotent => idempotent, :method => 'POST', :parser => parser }) rescue Excon::Errors::HTTPStatusError => error match = Fog::AWS::Errors.match_error(error) raise if match.empty? raise case match[:code] when 'NotFound' Fog::AWS::ECS::NotFound.slurp(error, match[:message]) else Fog::AWS::ECS::Error.slurp(error, "#{match[:code]} => #{match[:message]}") end end
# File lib/fog/aws/ecs.rb, line 91 def request(params) refresh_credentials_if_expired idempotent = params.delete(:idempotent) parser = params.delete(:parser) body, headers = Fog::AWS.signed_params_v4( params, {'Content-Type' => 'application/x-www-form-urlencoded' }, { :aws_session_token => @aws_session_token, :signer => @signer, :host => @host, :path => @path, :port => @port, :version => @version, :method => 'POST' } ) if @instrumentor @instrumentor.instrument("#{@instrumentor_name}.request", params) do _request(body, headers, idempotent, parser) end else _request(body, headers, idempotent, parser) end end
# File lib/fog/aws/ecs.rb, line 82 def setup_credentials(options) @aws_access_key_id = options[:aws_access_key_id] @aws_secret_access_key = options[:aws_secret_access_key] @aws_session_token = options[:aws_session_token] @aws_credentials_expire_at = options[:aws_credentials_expire_at] @signer = Fog::AWS::SignatureV4.new( @aws_access_key_id, @aws_secret_access_key,@region,'ecs') end