Container for the parameters to the RegisterTaskDefinition operation. Registers a new task definition from the supplied family and containerDefinitions. Optionally, you can add data volumes to your containers with the volumes parameter. For more information about task definition parameters and defaults, see Amazon ECS Task Definitions in the Amazon EC2 Container Service Developer Guide.

You can specify an IAM role for your task with the taskRoleArn parameter. When you specify an IAM role for a task, its containers can then use the latest versions of the AWS CLI or SDKs to make API requests to the AWS services that are specified in the IAM policy associated with the role. For more information, see IAM Roles for Tasks in the Amazon EC2 Container Service Developer Guide.

You can specify a Docker networking mode for the containers in your task definition with the networkMode parameter. The available network modes correspond to those described in Network settings in the Docker run reference.

Inheritance: AmazonECSRequest
 public async System.Threading.Tasks.Task CreateTask()
 {
     var request = new RegisterTaskDefinitionRequest
     {
         ContainerDefinitions =
         {
             new ContainerDefinition
             {
                 Name = _task.Name,
                 Image = _task.Image,
                 Memory = 350,
                 PortMappings =
                 {
                     new PortMapping
                     {
                         ContainerPort = _task.ContainerPort,
                         HostPort = _task.HostPort,
                         Protocol  = TransportProtocol.Tcp
                     }
                 }
             }
         },
         Family = _task.Name
     };
     await _client.RegisterTaskDefinitionAsync(request);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the RegisterTaskDefinition operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the RegisterTaskDefinition operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<RegisterTaskDefinitionResponse> RegisterTaskDefinitionAsync(RegisterTaskDefinitionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new RegisterTaskDefinitionRequestMarshaller();
            var unmarshaller = RegisterTaskDefinitionResponseUnmarshaller.Instance;

            return InvokeAsync<RegisterTaskDefinitionRequest,RegisterTaskDefinitionResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        /// <summary>
        /// Registers a new task definition from the supplied <code>family</code> and <code>containerDefinitions</code>.
        /// Optionally, you can add data volumes to your containers with the <code>volumes</code>
        /// parameter. For more information on task definition parameters and defaults, see <a
        /// href="http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_defintions.html">Amazon
        /// ECS Task Definitions</a> in the <i>Amazon EC2 Container Service Developer Guide</i>.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the RegisterTaskDefinition service method.</param>
        /// 
        /// <returns>The response from the RegisterTaskDefinition service method, as returned by ECS.</returns>
        /// <exception cref="Amazon.ECS.Model.ClientException">
        /// These errors are usually caused by something the client did, such as use an action
        /// or resource on behalf of a user that doesn't have permission to use the action or
        /// resource, or specify an identifier that is not valid.
        /// </exception>
        /// <exception cref="Amazon.ECS.Model.InvalidParameterException">
        /// The specified parameter is invalid. Review the available parameters for the API request.
        /// </exception>
        /// <exception cref="Amazon.ECS.Model.ServerException">
        /// These errors are usually caused by a server-side issue.
        /// </exception>
        public RegisterTaskDefinitionResponse RegisterTaskDefinition(RegisterTaskDefinitionRequest request)
        {
            var marshaller = new RegisterTaskDefinitionRequestMarshaller();
            var unmarshaller = RegisterTaskDefinitionResponseUnmarshaller.Instance;

            return Invoke<RegisterTaskDefinitionRequest,RegisterTaskDefinitionResponse>(request, marshaller, unmarshaller);
        }
示例#4
0
 private Amazon.ECS.Model.RegisterTaskDefinitionResponse CallAWSServiceOperation(IAmazonECS client, Amazon.ECS.Model.RegisterTaskDefinitionRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon EC2 Container Service", "RegisterTaskDefinition");
     try
     {
         #if DESKTOP
         return(client.RegisterTaskDefinition(request));
         #elif CORECLR
         return(client.RegisterTaskDefinitionAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
示例#5
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.ECS.Model.RegisterTaskDefinitionRequest();

            if (cmdletContext.ContainerDefinition != null)
            {
                request.ContainerDefinitions = cmdletContext.ContainerDefinition;
            }
            if (cmdletContext.Cpu != null)
            {
                request.Cpu = cmdletContext.Cpu;
            }
            if (cmdletContext.ExecutionRoleArn != null)
            {
                request.ExecutionRoleArn = cmdletContext.ExecutionRoleArn;
            }
            if (cmdletContext.Family != null)
            {
                request.Family = cmdletContext.Family;
            }
            if (cmdletContext.InferenceAccelerator != null)
            {
                request.InferenceAccelerators = cmdletContext.InferenceAccelerator;
            }
            if (cmdletContext.IpcMode != null)
            {
                request.IpcMode = cmdletContext.IpcMode;
            }
            if (cmdletContext.Memory != null)
            {
                request.Memory = cmdletContext.Memory;
            }
            if (cmdletContext.NetworkMode != null)
            {
                request.NetworkMode = cmdletContext.NetworkMode;
            }
            if (cmdletContext.PidMode != null)
            {
                request.PidMode = cmdletContext.PidMode;
            }
            if (cmdletContext.PlacementConstraint != null)
            {
                request.PlacementConstraints = cmdletContext.PlacementConstraint;
            }

            // populate ProxyConfiguration
            var requestProxyConfigurationIsNull = true;

            request.ProxyConfiguration = new Amazon.ECS.Model.ProxyConfiguration();
            System.String requestProxyConfiguration_proxyConfiguration_ContainerName = null;
            if (cmdletContext.ProxyConfiguration_ContainerName != null)
            {
                requestProxyConfiguration_proxyConfiguration_ContainerName = cmdletContext.ProxyConfiguration_ContainerName;
            }
            if (requestProxyConfiguration_proxyConfiguration_ContainerName != null)
            {
                request.ProxyConfiguration.ContainerName = requestProxyConfiguration_proxyConfiguration_ContainerName;
                requestProxyConfigurationIsNull          = false;
            }
            List <Amazon.ECS.Model.KeyValuePair> requestProxyConfiguration_proxyConfiguration_Property = null;

            if (cmdletContext.ProxyConfiguration_Property != null)
            {
                requestProxyConfiguration_proxyConfiguration_Property = cmdletContext.ProxyConfiguration_Property;
            }
            if (requestProxyConfiguration_proxyConfiguration_Property != null)
            {
                request.ProxyConfiguration.Properties = requestProxyConfiguration_proxyConfiguration_Property;
                requestProxyConfigurationIsNull       = false;
            }
            Amazon.ECS.ProxyConfigurationType requestProxyConfiguration_proxyConfiguration_Type = null;
            if (cmdletContext.ProxyConfiguration_Type != null)
            {
                requestProxyConfiguration_proxyConfiguration_Type = cmdletContext.ProxyConfiguration_Type;
            }
            if (requestProxyConfiguration_proxyConfiguration_Type != null)
            {
                request.ProxyConfiguration.Type = requestProxyConfiguration_proxyConfiguration_Type;
                requestProxyConfigurationIsNull = false;
            }
            // determine if request.ProxyConfiguration should be set to null
            if (requestProxyConfigurationIsNull)
            {
                request.ProxyConfiguration = null;
            }
            if (cmdletContext.RequiresCompatibility != null)
            {
                request.RequiresCompatibilities = cmdletContext.RequiresCompatibility;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }
            if (cmdletContext.TaskRoleArn != null)
            {
                request.TaskRoleArn = cmdletContext.TaskRoleArn;
            }
            if (cmdletContext.Volume != null)
            {
                request.Volumes = cmdletContext.Volume;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
示例#6
0
        /// <summary>
        /// Initiates the asynchronous execution of the RegisterTaskDefinition operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the RegisterTaskDefinition operation on AmazonECSClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndRegisterTaskDefinition
        ///         operation.</returns>
        public IAsyncResult BeginRegisterTaskDefinition(RegisterTaskDefinitionRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new RegisterTaskDefinitionRequestMarshaller();
            var unmarshaller = RegisterTaskDefinitionResponseUnmarshaller.Instance;

            return BeginInvoke<RegisterTaskDefinitionRequest>(request, marshaller, unmarshaller,
                callback, state);
        }