/*******************************************************************************
* Copyright 2012-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file.
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
* *****************************************************************************
*
* AWS Tools for Windows (TM) PowerShell (TM)
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using Amazon.PowerShell.Common;
using Amazon.Runtime;
using Amazon.ECS;
using Amazon.ECS.Model;
namespace Amazon.PowerShell.Cmdlets.ECS
{
///
/// Starts a new task using the specified task definition.
///
///
///
/// You can allow Amazon ECS to place tasks for you, or you can customize how Amazon ECS
/// places tasks using placement constraints and placement strategies. For more information,
/// see Scheduling
/// Tasks in the Amazon Elastic Container Service Developer Guide.
///
/// Alternatively, you can use StartTask to use your own scheduler or place tasks
/// manually on specific container instances.
///
/// Starting April 15, 2023, Amazon Web Services will not onboard new customers to Amazon
/// Elastic Inference (EI), and will help current customers migrate their workloads to
/// options that offer better price and performance. After April 15, 2023, new customers
/// will not be able to launch instances with Amazon EI accelerators in Amazon SageMaker,
/// Amazon ECS, or Amazon EC2. However, customers who have used Amazon EI at least once
/// during the past 30-day period are considered current customers and will be able to
/// continue using the service.
///
/// The Amazon ECS API follows an eventual consistency model. This is because of the distributed
/// nature of the system supporting the API. This means that the result of an API command
/// you run that affects your Amazon ECS resources might not be immediately visible to
/// all subsequent commands you run. Keep this in mind when you carry out an API command
/// that immediately follows a previous API command.
///
/// To manage eventual consistency, you can do the following:
/// -
/// Confirm the state of the resource before you run a command to modify it. Run the DescribeTasks
/// command using an exponential backoff algorithm to ensure that you allow enough time
/// for the previous command to propagate through the system. To do this, run the DescribeTasks
/// command repeatedly, starting with a couple of seconds of wait time and increasing
/// gradually up to five minutes of wait time.
///
-
/// Add wait time between subsequent commands, even if the DescribeTasks command returns
/// an accurate response. Apply an exponential backoff algorithm starting with a couple
/// of seconds of wait time, and increase gradually up to about five minutes of wait time.
///
///
[Cmdlet("New", "ECSTask", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("Amazon.ECS.Model.RunTaskResponse")]
[AWSCmdlet("Calls the Amazon EC2 Container Service RunTask API operation.", Operation = new[] {"RunTask"}, SelectReturnType = typeof(Amazon.ECS.Model.RunTaskResponse))]
[AWSCmdletOutput("Amazon.ECS.Model.RunTaskResponse",
"This cmdlet returns an Amazon.ECS.Model.RunTaskResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class NewECSTaskCmdlet : AmazonECSClientCmdlet, IExecutor
{
#region Parameter AwsvpcConfiguration_AssignPublicIp
///
///
/// Whether the task's elastic network interface receives a public IP address. The default
/// value is DISABLED
.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("NetworkConfiguration_AwsvpcConfiguration_AssignPublicIp")]
[AWSConstantClassSource("Amazon.ECS.AssignPublicIp")]
public Amazon.ECS.AssignPublicIp AwsvpcConfiguration_AssignPublicIp { get; set; }
#endregion
#region Parameter CapacityProviderStrategy
///
///
/// The capacity provider strategy to use for the task.If a capacityProviderStrategy
is specified, the launchType
/// parameter must be omitted. If no capacityProviderStrategy
or launchType
/// is specified, the defaultCapacityProviderStrategy
for the cluster is
/// used.When you use cluster auto scaling, you must specify capacityProviderStrategy
/// and not launchType
. A capacity provider strategy may contain a maximum of 6 capacity providers.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public Amazon.ECS.Model.CapacityProviderStrategyItem[] CapacityProviderStrategy { get; set; }
#endregion
#region Parameter Cluster
///
///
/// The short name or full Amazon Resource Name (ARN) of the cluster to run your task
/// on. If you do not specify a cluster, the default cluster is assumed.
///
///
[System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)]
public System.String Cluster { get; set; }
#endregion
#region Parameter Overrides_ContainerOverride
///
///
/// One or more container overrides that are sent to a task.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Overrides_ContainerOverrides")]
public Amazon.ECS.Model.ContainerOverride[] Overrides_ContainerOverride { get; set; }
#endregion
#region Parameter Count
///
///
/// The number of instantiations of the specified task to place on your cluster. You can
/// specify up to 10 tasks for each call.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Int32? Count { get; set; }
#endregion
#region Parameter Overrides_Cpu
///
///
/// The CPU override for the task.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Overrides_Cpu { get; set; }
#endregion
#region Parameter EnableECSManagedTag
///
///
/// Specifies whether to use Amazon ECS managed tags for the task. For more information,
/// see Tagging
/// Your Amazon ECS Resources in the Amazon Elastic Container Service Developer
/// Guide.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("EnableECSManagedTags")]
public System.Boolean? EnableECSManagedTag { get; set; }
#endregion
#region Parameter EnableExecuteCommand
///
///
/// Determines whether to use the execute command functionality for the containers in
/// this task. If true
, this enables execute command functionality on all
/// containers in the task.If true
, then the task definition must have a task role, or you must
/// provide one as an override.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? EnableExecuteCommand { get; set; }
#endregion
#region Parameter Overrides_ExecutionRoleArn
///
///
/// The Amazon Resource Name (ARN) of the task execution role override for the task. For
/// more information, see Amazon
/// ECS task execution IAM role in the Amazon Elastic Container Service Developer
/// Guide.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Overrides_ExecutionRoleArn { get; set; }
#endregion
#region Parameter Group
///
///
/// The name of the task group to associate with the task. The default value is the family
/// name of the task definition (for example, family:my-family-name
).
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Group { get; set; }
#endregion
#region Parameter Overrides_InferenceAcceleratorOverride
///
///
/// The Elastic Inference accelerator override for the task.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Overrides_InferenceAcceleratorOverrides")]
public Amazon.ECS.Model.InferenceAcceleratorOverride[] Overrides_InferenceAcceleratorOverride { get; set; }
#endregion
#region Parameter LaunchType
///
///
/// The infrastructure to run your standalone task on. For more information, see Amazon
/// ECS launch types in the Amazon Elastic Container Service Developer Guide.The FARGATE
launch type runs your tasks on Fargate On-Demand infrastructure.Fargate Spot infrastructure is available for use but a capacity provider strategy
/// must be used. For more information, see Fargate
/// capacity providers in the Amazon ECS User Guide for Fargate.The EC2
launch type runs your tasks on Amazon EC2 instances registered
/// to your cluster.The EXTERNAL
launch type runs your tasks on your on-premises server or
/// virtual machine (VM) capacity registered to your cluster.A task can use either a launch type or a capacity provider strategy. If a launchType
/// is specified, the capacityProviderStrategy
parameter must be omitted.When you use cluster auto scaling, you must specify capacityProviderStrategy
/// and not launchType
.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[AWSConstantClassSource("Amazon.ECS.LaunchType")]
public Amazon.ECS.LaunchType LaunchType { get; set; }
#endregion
#region Parameter Overrides_Memory
///
///
/// The memory override for the task.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Overrides_Memory { get; set; }
#endregion
#region Parameter PlacementConstraint
///
///
/// An array of placement constraint objects to use for the task. You can specify up to
/// 10 constraints for each task (including constraints in the task definition and those
/// specified at runtime).
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("PlacementConstraints")]
public Amazon.ECS.Model.PlacementConstraint[] PlacementConstraint { get; set; }
#endregion
#region Parameter PlacementStrategy
///
///
/// The placement strategy objects to use for the task. You can specify a maximum of 5
/// strategy rules for each task.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public Amazon.ECS.Model.PlacementStrategy[] PlacementStrategy { get; set; }
#endregion
#region Parameter PlatformVersion
///
///
/// The platform version the task uses. A platform version is only specified for tasks
/// hosted on Fargate. If one isn't specified, the LATEST
platform version
/// is used. For more information, see Fargate
/// platform versions in the Amazon Elastic Container Service Developer Guide.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String PlatformVersion { get; set; }
#endregion
#region Parameter PropagateTag
///
///
/// Specifies whether to propagate the tags from the task definition to the task. If no
/// value is specified, the tags aren't propagated. Tags can only be propagated to the
/// task during task creation. To add tags to a task after task creation, use the TagResource
/// API action.An error will be received if you specify the SERVICE
option when running
/// a task.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("PropagateTags")]
[AWSConstantClassSource("Amazon.ECS.PropagateTags")]
public Amazon.ECS.PropagateTags PropagateTag { get; set; }
#endregion
#region Parameter ReferenceId
///
///
/// The reference ID to use for the task. The reference ID can have a maximum length of
/// 1024 characters.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ReferenceId { get; set; }
#endregion
#region Parameter AwsvpcConfiguration_SecurityGroup
///
///
/// The IDs of the security groups associated with the task or service. If you don't specify
/// a security group, the default security group for the VPC is used. There's a limit
/// of 5 security groups that can be specified per AwsVpcConfiguration
.All specified security groups must be from the same VPC.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("NetworkConfiguration_AwsvpcConfiguration_SecurityGroups")]
public System.String[] AwsvpcConfiguration_SecurityGroup { get; set; }
#endregion
#region Parameter EphemeralStorage_SizeInGiB
///
///
/// The total amount, in GiB, of ephemeral storage to set for the task. The minimum supported
/// value is 21
GiB and the maximum supported value is 200
GiB.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Overrides_EphemeralStorage_SizeInGiB")]
public System.Int32? EphemeralStorage_SizeInGiB { get; set; }
#endregion
#region Parameter StartedBy
///
///
/// An optional tag specified when a task is started. For example, if you automatically
/// trigger a task to run a batch process job, you could apply a unique identifier for
/// that job to your task with the startedBy
parameter. You can then identify
/// which tasks belong to that job by filtering the results of a ListTasks call
/// with the startedBy
value. Up to 36 letters (uppercase and lowercase),
/// numbers, hyphens (-), and underscores (_) are allowed.If a task is started by an Amazon ECS service, then the startedBy
parameter
/// contains the deployment ID of the service that starts it.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String StartedBy { get; set; }
#endregion
#region Parameter AwsvpcConfiguration_Subnet
///
///
/// The IDs of the subnets associated with the task or service. There's a limit of 16
/// subnets that can be specified per AwsVpcConfiguration
.All specified subnets must be from the same VPC.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("NetworkConfiguration_AwsvpcConfiguration_Subnets")]
public System.String[] AwsvpcConfiguration_Subnet { get; set; }
#endregion
#region Parameter Tag
///
///
/// The metadata that you apply to the task to help you categorize and organize them.
/// Each tag consists of a key and an optional value, both of which you define.The following basic restrictions apply to tags:- Maximum number of tags per resource - 50
- For each resource, each tag key must be unique, and each tag key can have only one
/// value.
- Maximum key length - 128 Unicode characters in UTF-8
- Maximum value length - 256 Unicode characters in UTF-8
- If your tagging schema is used across multiple services and resources, remember that
/// other services may have restrictions on allowed characters. Generally allowed characters
/// are: letters, numbers, and spaces representable in UTF-8, and the following characters:
/// + - = . _ : / @.
- Tag keys and values are case-sensitive.
- Do not use
aws:
, AWS:
, or any upper or lowercase combination
/// of such as a prefix for either keys or values as it is reserved for Amazon Web Services
/// use. You cannot edit or delete tag keys or values with this prefix. Tags with this
/// prefix do not count against your tags per resource limit.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Tags")]
public Amazon.ECS.Model.Tag[] Tag { get; set; }
#endregion
#region Parameter TaskDefinition
///
///
/// The family
and revision
(family:revision
) or
/// full ARN of the task definition to run. If a revision
isn't specified,
/// the latest ACTIVE
revision is used.When you create a policy for run-task, you can set the resource to be the latest task
/// definition revision, or a specific revision.The full ARN value must match the value that you specified as the Resource
/// of the principal's permissions policy.When you specify the policy resource as the latest task definition version (by setting
/// the Resource
in the policy to arn:aws:ecs:us-east-1:111122223333:task-definition/TaskFamilyName
),
/// then set this value to arn:aws:ecs:us-east-1:111122223333:task-definition/TaskFamilyName
.When you specify the policy resource as a specific task definition version (by setting
/// the Resource
in the policy to arn:aws:ecs:us-east-1:111122223333:task-definition/TaskFamilyName:1
/// or arn:aws:ecs:us-east-1:111122223333:task-definition/TaskFamilyName:*
),
/// then set this value to arn:aws:ecs:us-east-1:111122223333:task-definition/TaskFamilyName:1
.For more information, see Policy
/// Resources for Amazon ECS in the Amazon Elastic Container Service developer Guide.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.String TaskDefinition { get; set; }
#endregion
#region Parameter Overrides_TaskRoleArn
///
///
/// The Amazon Resource Name (ARN) of the role that containers in this task can assume.
/// All containers in this task are granted the permissions that are specified in this
/// role. For more information, see IAM
/// Role for Tasks in the Amazon Elastic Container Service Developer Guide.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Overrides_TaskRoleArn { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The default value is '*'.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.ECS.Model.RunTaskResponse).
/// Specifying the name of a property of type Amazon.ECS.Model.RunTaskResponse will result in that property being returned.
/// Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public string Select { get; set; } = "*";
#endregion
#region Parameter PassThru
///
/// Changes the cmdlet behavior to return the value passed to the Cluster parameter.
/// The -PassThru parameter is deprecated, use -Select '^Cluster' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^Cluster' instead. This parameter will be removed in a future version.")]
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter PassThru { get; set; }
#endregion
#region Parameter Force
///
/// This parameter overrides confirmation prompts to force
/// the cmdlet to continue its operation. This parameter should always
/// be used with caution.
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter Force { get; set; }
#endregion
protected override void ProcessRecord()
{
this._AWSSignerType = "v4";
base.ProcessRecord();
var resourceIdentifiersText = FormatParameterValuesForConfirmationMsg(nameof(this.Cluster), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "New-ECSTask (RunTask)"))
{
return;
}
var context = new CmdletContext();
// allow for manipulation of parameters prior to loading into context
PreExecutionContextLoad(context);
#pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
if (ParameterWasBound(nameof(this.Select)))
{
context.Select = CreateSelectDelegate(Select) ??
throw new System.ArgumentException("Invalid value for -Select parameter.", nameof(this.Select));
if (this.PassThru.IsPresent)
{
throw new System.ArgumentException("-PassThru cannot be used when -Select is specified.", nameof(this.Select));
}
}
else if (this.PassThru.IsPresent)
{
context.Select = (response, cmdlet) => this.Cluster;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
if (this.CapacityProviderStrategy != null)
{
context.CapacityProviderStrategy = new List(this.CapacityProviderStrategy);
}
context.Cluster = this.Cluster;
context.Count = this.Count;
context.EnableECSManagedTag = this.EnableECSManagedTag;
context.EnableExecuteCommand = this.EnableExecuteCommand;
context.Group = this.Group;
context.LaunchType = this.LaunchType;
context.AwsvpcConfiguration_AssignPublicIp = this.AwsvpcConfiguration_AssignPublicIp;
if (this.AwsvpcConfiguration_SecurityGroup != null)
{
context.AwsvpcConfiguration_SecurityGroup = new List(this.AwsvpcConfiguration_SecurityGroup);
}
if (this.AwsvpcConfiguration_Subnet != null)
{
context.AwsvpcConfiguration_Subnet = new List(this.AwsvpcConfiguration_Subnet);
}
if (this.Overrides_ContainerOverride != null)
{
context.Overrides_ContainerOverride = new List(this.Overrides_ContainerOverride);
}
context.Overrides_Cpu = this.Overrides_Cpu;
context.EphemeralStorage_SizeInGiB = this.EphemeralStorage_SizeInGiB;
context.Overrides_ExecutionRoleArn = this.Overrides_ExecutionRoleArn;
if (this.Overrides_InferenceAcceleratorOverride != null)
{
context.Overrides_InferenceAcceleratorOverride = new List(this.Overrides_InferenceAcceleratorOverride);
}
context.Overrides_Memory = this.Overrides_Memory;
context.Overrides_TaskRoleArn = this.Overrides_TaskRoleArn;
if (this.PlacementConstraint != null)
{
context.PlacementConstraint = new List(this.PlacementConstraint);
}
if (this.PlacementStrategy != null)
{
context.PlacementStrategy = new List(this.PlacementStrategy);
}
context.PlatformVersion = this.PlatformVersion;
context.PropagateTag = this.PropagateTag;
context.ReferenceId = this.ReferenceId;
context.StartedBy = this.StartedBy;
if (this.Tag != null)
{
context.Tag = new List(this.Tag);
}
context.TaskDefinition = this.TaskDefinition;
#if MODULAR
if (this.TaskDefinition == null && ParameterWasBound(nameof(this.TaskDefinition)))
{
WriteWarning("You are passing $null as a value for parameter TaskDefinition which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
// allow further manipulation of loaded context prior to processing
PostExecutionContextLoad(context);
var output = Execute(context) as CmdletOutput;
ProcessOutput(output);
}
#region IExecutor Members
public object Execute(ExecutorContext context)
{
var cmdletContext = context as CmdletContext;
// create request
var request = new Amazon.ECS.Model.RunTaskRequest();
if (cmdletContext.CapacityProviderStrategy != null)
{
request.CapacityProviderStrategy = cmdletContext.CapacityProviderStrategy;
}
if (cmdletContext.Cluster != null)
{
request.Cluster = cmdletContext.Cluster;
}
if (cmdletContext.Count != null)
{
request.Count = cmdletContext.Count.Value;
}
if (cmdletContext.EnableECSManagedTag != null)
{
request.EnableECSManagedTags = cmdletContext.EnableECSManagedTag.Value;
}
if (cmdletContext.EnableExecuteCommand != null)
{
request.EnableExecuteCommand = cmdletContext.EnableExecuteCommand.Value;
}
if (cmdletContext.Group != null)
{
request.Group = cmdletContext.Group;
}
if (cmdletContext.LaunchType != null)
{
request.LaunchType = cmdletContext.LaunchType;
}
// populate NetworkConfiguration
var requestNetworkConfigurationIsNull = true;
request.NetworkConfiguration = new Amazon.ECS.Model.NetworkConfiguration();
Amazon.ECS.Model.AwsVpcConfiguration requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration = null;
// populate AwsvpcConfiguration
var requestNetworkConfiguration_networkConfiguration_AwsvpcConfigurationIsNull = true;
requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration = new Amazon.ECS.Model.AwsVpcConfiguration();
Amazon.ECS.AssignPublicIp requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_AssignPublicIp = null;
if (cmdletContext.AwsvpcConfiguration_AssignPublicIp != null)
{
requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_AssignPublicIp = cmdletContext.AwsvpcConfiguration_AssignPublicIp;
}
if (requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_AssignPublicIp != null)
{
requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration.AssignPublicIp = requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_AssignPublicIp;
requestNetworkConfiguration_networkConfiguration_AwsvpcConfigurationIsNull = false;
}
List requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_SecurityGroup = null;
if (cmdletContext.AwsvpcConfiguration_SecurityGroup != null)
{
requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_SecurityGroup = cmdletContext.AwsvpcConfiguration_SecurityGroup;
}
if (requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_SecurityGroup != null)
{
requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration.SecurityGroups = requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_SecurityGroup;
requestNetworkConfiguration_networkConfiguration_AwsvpcConfigurationIsNull = false;
}
List requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_Subnet = null;
if (cmdletContext.AwsvpcConfiguration_Subnet != null)
{
requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_Subnet = cmdletContext.AwsvpcConfiguration_Subnet;
}
if (requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_Subnet != null)
{
requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration.Subnets = requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration_awsvpcConfiguration_Subnet;
requestNetworkConfiguration_networkConfiguration_AwsvpcConfigurationIsNull = false;
}
// determine if requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration should be set to null
if (requestNetworkConfiguration_networkConfiguration_AwsvpcConfigurationIsNull)
{
requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration = null;
}
if (requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration != null)
{
request.NetworkConfiguration.AwsvpcConfiguration = requestNetworkConfiguration_networkConfiguration_AwsvpcConfiguration;
requestNetworkConfigurationIsNull = false;
}
// determine if request.NetworkConfiguration should be set to null
if (requestNetworkConfigurationIsNull)
{
request.NetworkConfiguration = null;
}
// populate Overrides
var requestOverridesIsNull = true;
request.Overrides = new Amazon.ECS.Model.TaskOverride();
List requestOverrides_overrides_ContainerOverride = null;
if (cmdletContext.Overrides_ContainerOverride != null)
{
requestOverrides_overrides_ContainerOverride = cmdletContext.Overrides_ContainerOverride;
}
if (requestOverrides_overrides_ContainerOverride != null)
{
request.Overrides.ContainerOverrides = requestOverrides_overrides_ContainerOverride;
requestOverridesIsNull = false;
}
System.String requestOverrides_overrides_Cpu = null;
if (cmdletContext.Overrides_Cpu != null)
{
requestOverrides_overrides_Cpu = cmdletContext.Overrides_Cpu;
}
if (requestOverrides_overrides_Cpu != null)
{
request.Overrides.Cpu = requestOverrides_overrides_Cpu;
requestOverridesIsNull = false;
}
System.String requestOverrides_overrides_ExecutionRoleArn = null;
if (cmdletContext.Overrides_ExecutionRoleArn != null)
{
requestOverrides_overrides_ExecutionRoleArn = cmdletContext.Overrides_ExecutionRoleArn;
}
if (requestOverrides_overrides_ExecutionRoleArn != null)
{
request.Overrides.ExecutionRoleArn = requestOverrides_overrides_ExecutionRoleArn;
requestOverridesIsNull = false;
}
List requestOverrides_overrides_InferenceAcceleratorOverride = null;
if (cmdletContext.Overrides_InferenceAcceleratorOverride != null)
{
requestOverrides_overrides_InferenceAcceleratorOverride = cmdletContext.Overrides_InferenceAcceleratorOverride;
}
if (requestOverrides_overrides_InferenceAcceleratorOverride != null)
{
request.Overrides.InferenceAcceleratorOverrides = requestOverrides_overrides_InferenceAcceleratorOverride;
requestOverridesIsNull = false;
}
System.String requestOverrides_overrides_Memory = null;
if (cmdletContext.Overrides_Memory != null)
{
requestOverrides_overrides_Memory = cmdletContext.Overrides_Memory;
}
if (requestOverrides_overrides_Memory != null)
{
request.Overrides.Memory = requestOverrides_overrides_Memory;
requestOverridesIsNull = false;
}
System.String requestOverrides_overrides_TaskRoleArn = null;
if (cmdletContext.Overrides_TaskRoleArn != null)
{
requestOverrides_overrides_TaskRoleArn = cmdletContext.Overrides_TaskRoleArn;
}
if (requestOverrides_overrides_TaskRoleArn != null)
{
request.Overrides.TaskRoleArn = requestOverrides_overrides_TaskRoleArn;
requestOverridesIsNull = false;
}
Amazon.ECS.Model.EphemeralStorage requestOverrides_overrides_EphemeralStorage = null;
// populate EphemeralStorage
var requestOverrides_overrides_EphemeralStorageIsNull = true;
requestOverrides_overrides_EphemeralStorage = new Amazon.ECS.Model.EphemeralStorage();
System.Int32? requestOverrides_overrides_EphemeralStorage_ephemeralStorage_SizeInGiB = null;
if (cmdletContext.EphemeralStorage_SizeInGiB != null)
{
requestOverrides_overrides_EphemeralStorage_ephemeralStorage_SizeInGiB = cmdletContext.EphemeralStorage_SizeInGiB.Value;
}
if (requestOverrides_overrides_EphemeralStorage_ephemeralStorage_SizeInGiB != null)
{
requestOverrides_overrides_EphemeralStorage.SizeInGiB = requestOverrides_overrides_EphemeralStorage_ephemeralStorage_SizeInGiB.Value;
requestOverrides_overrides_EphemeralStorageIsNull = false;
}
// determine if requestOverrides_overrides_EphemeralStorage should be set to null
if (requestOverrides_overrides_EphemeralStorageIsNull)
{
requestOverrides_overrides_EphemeralStorage = null;
}
if (requestOverrides_overrides_EphemeralStorage != null)
{
request.Overrides.EphemeralStorage = requestOverrides_overrides_EphemeralStorage;
requestOverridesIsNull = false;
}
// determine if request.Overrides should be set to null
if (requestOverridesIsNull)
{
request.Overrides = null;
}
if (cmdletContext.PlacementConstraint != null)
{
request.PlacementConstraints = cmdletContext.PlacementConstraint;
}
if (cmdletContext.PlacementStrategy != null)
{
request.PlacementStrategy = cmdletContext.PlacementStrategy;
}
if (cmdletContext.PlatformVersion != null)
{
request.PlatformVersion = cmdletContext.PlatformVersion;
}
if (cmdletContext.PropagateTag != null)
{
request.PropagateTags = cmdletContext.PropagateTag;
}
if (cmdletContext.ReferenceId != null)
{
request.ReferenceId = cmdletContext.ReferenceId;
}
if (cmdletContext.StartedBy != null)
{
request.StartedBy = cmdletContext.StartedBy;
}
if (cmdletContext.Tag != null)
{
request.Tags = cmdletContext.Tag;
}
if (cmdletContext.TaskDefinition != null)
{
request.TaskDefinition = cmdletContext.TaskDefinition;
}
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;
}
public ExecutorContext CreateContext()
{
return new CmdletContext();
}
#endregion
#region AWS Service Operation Call
private Amazon.ECS.Model.RunTaskResponse CallAWSServiceOperation(IAmazonECS client, Amazon.ECS.Model.RunTaskRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon EC2 Container Service", "RunTask");
try
{
#if DESKTOP
return client.RunTask(request);
#elif CORECLR
return client.RunTaskAsync(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;
}
}
#endregion
internal partial class CmdletContext : ExecutorContext
{
public List CapacityProviderStrategy { get; set; }
public System.String Cluster { get; set; }
public System.Int32? Count { get; set; }
public System.Boolean? EnableECSManagedTag { get; set; }
public System.Boolean? EnableExecuteCommand { get; set; }
public System.String Group { get; set; }
public Amazon.ECS.LaunchType LaunchType { get; set; }
public Amazon.ECS.AssignPublicIp AwsvpcConfiguration_AssignPublicIp { get; set; }
public List AwsvpcConfiguration_SecurityGroup { get; set; }
public List AwsvpcConfiguration_Subnet { get; set; }
public List Overrides_ContainerOverride { get; set; }
public System.String Overrides_Cpu { get; set; }
public System.Int32? EphemeralStorage_SizeInGiB { get; set; }
public System.String Overrides_ExecutionRoleArn { get; set; }
public List Overrides_InferenceAcceleratorOverride { get; set; }
public System.String Overrides_Memory { get; set; }
public System.String Overrides_TaskRoleArn { get; set; }
public List PlacementConstraint { get; set; }
public List PlacementStrategy { get; set; }
public System.String PlatformVersion { get; set; }
public Amazon.ECS.PropagateTags PropagateTag { get; set; }
public System.String ReferenceId { get; set; }
public System.String StartedBy { get; set; }
public List Tag { get; set; }
public System.String TaskDefinition { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response;
}
}
}