/******************************************************************************* * 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.EC2; using Amazon.EC2.Model; namespace Amazon.PowerShell.Cmdlets.EC2 { /// /// Launches the specified number of instances using an AMI for which you have permissions. /// /// /// /// You can specify a number of options, or leave the default options. The following rules /// apply: /// /// You can create a launch /// template, which is a resource that contains the parameters to launch an instance. /// When you launch an instance using RunInstances, you can specify the launch /// template instead of specifying the launch parameters. /// /// To ensure faster instance launches, break up large requests into smaller batches. /// For example, create five separate launch requests for 100 instances each instead of /// one launch request for 500 instances. /// /// An instance is ready for you to use when it's in the running state. You /// can check the state of your instance using DescribeInstances. You can tag instances /// and EBS volumes during launch, after launch, or both. For more information, see CreateTags /// and Tagging /// your Amazon EC2 resources. /// /// Linux instances have access to the public key of the key pair at boot. You can use /// this key to provide secure access to the instance. Amazon EC2 public images use this /// feature to provide secure access without passwords. For more information, see Key /// pairs. /// /// For troubleshooting, see What /// to do if an instance immediately terminates, and Troubleshooting /// connecting to your instance. /// /// [Cmdlet("New", "EC2Instance", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("Amazon.EC2.Model.Reservation")] [AWSCmdlet("Calls the Amazon Elastic Compute Cloud (EC2) RunInstances API operation.", Operation = new[] {"RunInstances"}, SelectReturnType = typeof(Amazon.EC2.Model.RunInstancesResponse))] [AWSCmdletOutput("Amazon.EC2.Model.Reservation or Amazon.EC2.Model.RunInstancesResponse", "This cmdlet returns an Amazon.EC2.Model.Reservation object.", "The service call response (type Amazon.EC2.Model.RunInstancesResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class NewEC2InstanceCmdlet : AmazonEC2ClientCmdlet, IExecutor { protected override bool IsSensitiveRequest { get; set; } = true; #region Parameter AdditionalInfo /// /// /// Reserved. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String AdditionalInfo { get; set; } #endregion #region Parameter Placement_Affinity /// /// /// The affinity setting for the instance on the Dedicated Host.This parameter is not supported for CreateFleet /// or ImportInstance. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("Affinity")] public System.String Placement_Affinity { get; set; } #endregion #region Parameter IamInstanceProfile_Arn /// /// /// The Amazon Resource Name (ARN) of the instance profile. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("InstanceProfile_Arn")] public System.String IamInstanceProfile_Arn { get; set; } #endregion #region Parameter MaintenanceOptions_AutoRecovery /// /// /// Disables the automatic recovery behavior of your instance or sets it to default. For /// more information, see Simplified /// automatic recovery. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.EC2.InstanceAutoRecoveryState")] public Amazon.EC2.InstanceAutoRecoveryState MaintenanceOptions_AutoRecovery { get; set; } #endregion #region Parameter Placement_AvailabilityZone /// /// /// The Availability Zone of the instance.If not specified, an Availability Zone will be automatically chosen for you based /// on the load balancing criteria for the Region.This parameter is not supported for CreateFleet. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("AvailabilityZone")] public System.String Placement_AvailabilityZone { get; set; } #endregion #region Parameter BlockDeviceMapping /// /// /// The block device mapping, which defines the EBS volumes and instance store volumes /// to attach to the instance at launch. For more information, see Block /// device mappings in the Amazon EC2 User Guide. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("BlockDeviceMappings")] public Amazon.EC2.Model.BlockDeviceMapping[] BlockDeviceMapping { get; set; } #endregion #region Parameter CapacityReservationTarget_CapacityReservationId /// /// /// The ID of the Capacity Reservation in which to run the instance. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("CapacityReservationSpecification_CapacityReservationTarget_CapacityReservationId")] public System.String CapacityReservationTarget_CapacityReservationId { get; set; } #endregion #region Parameter CapacityReservationSpecification_CapacityReservationPreference /// /// /// Indicates the instance's Capacity Reservation preferences. Possible preferences include: /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.EC2.CapacityReservationPreference")] public Amazon.EC2.CapacityReservationPreference CapacityReservationSpecification_CapacityReservationPreference { get; set; } #endregion #region Parameter CapacityReservationTarget_CapacityReservationResourceGroupArn /// /// /// The ARN of the Capacity Reservation resource group in which to run the instance. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("CapacityReservationSpecification_CapacityReservationTarget_CapacityReservationResourceGroupArn")] public System.String CapacityReservationTarget_CapacityReservationResourceGroupArn { get; set; } #endregion #region Parameter HibernationOptions_Configured /// /// /// Set to true to enable your instance for hibernation.Default: false /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? HibernationOptions_Configured { get; set; } #endregion #region Parameter CreditSpecification_CpuCredit /// /// /// The credit option for CPU usage of a T instance.Valid values: standard | unlimited /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("CpuCredit","CreditSpecification_CpuCredits")] public System.String CreditSpecification_CpuCredit { get; set; } #endregion #region Parameter CpuOption /// /// /// The CPU options for the instance. For more information, see Optimize /// CPU options in the Amazon EC2 User Guide. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("CpuOptions")] public Amazon.EC2.Model.CpuOptionsRequest CpuOption { get; set; } #endregion #region Parameter DisableApiStop /// /// /// Indicates whether an instance is enabled for stop protection. For more information, /// see Stop /// protection. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? DisableApiStop { get; set; } #endregion #region Parameter DisableApiTermination /// /// /// If you set this parameter to true, you can't terminate the instance using /// the Amazon EC2 console, CLI, or API; otherwise, you can. To change this attribute /// after launch, use ModifyInstanceAttribute. /// Alternatively, if you set InstanceInitiatedShutdownBehavior to terminate, /// you can terminate the instance by running the shutdown command from the instance.Default: false /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? DisableApiTermination { get; set; } #endregion #region Parameter EbsOptimized /// /// /// Indicates whether the instance is optimized for Amazon EBS I/O. This optimization /// provides dedicated throughput to Amazon EBS and an optimized configuration stack to /// provide optimal Amazon EBS I/O performance. This optimization isn't available with /// all instance types. Additional usage charges apply when using an EBS-optimized instance.Default: false /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? EbsOptimized { get; set; } #endregion #region Parameter ElasticGpuSpecification /// /// /// An elastic GPU to associate with the instance. An Elastic GPU is a GPU resource that /// you can attach to your Windows instance to accelerate the graphics performance of /// your applications. For more information, see Amazon /// EC2 Elastic GPUs in the Amazon EC2 User Guide. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public Amazon.EC2.Model.ElasticGpuSpecification[] ElasticGpuSpecification { get; set; } #endregion #region Parameter ElasticInferenceAccelerator /// /// /// An elastic inference accelerator to associate with the instance. Elastic inference /// accelerators are a resource you can attach to your Amazon EC2 instances to accelerate /// your Deep Learning (DL) inference workloads.You cannot specify accelerators from different generations in the same request.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. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ElasticInferenceAccelerators")] public Amazon.EC2.Model.ElasticInferenceAccelerator[] ElasticInferenceAccelerator { get; set; } #endregion #region Parameter EnclaveOptions_Enabled /// /// /// To enable the instance for Amazon Web Services Nitro Enclaves, set this parameter /// to true. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? EnclaveOptions_Enabled { get; set; } #endregion #region Parameter PrivateDnsNameOptions_EnableResourceNameDnsAAAARecord /// /// /// Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? PrivateDnsNameOptions_EnableResourceNameDnsAAAARecord { get; set; } #endregion #region Parameter PrivateDnsNameOptions_EnableResourceNameDnsARecord /// /// /// Indicates whether to respond to DNS queries for instance hostnames with DNS A records. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Boolean? PrivateDnsNameOptions_EnableResourceNameDnsARecord { get; set; } #endregion #region Parameter Placement_GroupId /// /// /// The ID of the placement group that the instance is in. If you specify GroupId, /// you can't specify GroupName. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String Placement_GroupId { get; set; } #endregion #region Parameter Placement_GroupName /// /// /// The name of the placement group that the instance is in. If you specify GroupName, /// you can't specify GroupId. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("PlacementGroup")] public System.String Placement_GroupName { get; set; } #endregion #region Parameter Placement_HostId /// /// /// The ID of the Dedicated Host on which the instance resides.This parameter is not supported for CreateFleet /// or ImportInstance. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("HostId","Placement_Host")] public System.String Placement_HostId { get; set; } #endregion #region Parameter PrivateDnsNameOptions_HostnameType /// /// /// The type of hostname for EC2 instances. For IPv4 only subnets, an instance DNS name /// must be based on the instance IPv4 address. For IPv6 only subnets, an instance DNS /// name must be based on the instance ID. For dual-stack subnets, you can specify whether /// DNS names use the instance IPv4 address or the instance ID. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.EC2.HostnameType")] public Amazon.EC2.HostnameType PrivateDnsNameOptions_HostnameType { get; set; } #endregion #region Parameter Placement_HostResourceGroupArn /// /// /// The ARN of the host resource group in which to launch the instances.If you specify this parameter, either omit the Tenancy parameter or set it /// to host.This parameter is not supported for CreateFleet. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String Placement_HostResourceGroupArn { get; set; } #endregion #region Parameter MetadataOptions_HttpEndpoint /// /// /// Enables or disables the HTTP metadata endpoint on your instances.If you specify a value of disabled, you cannot access your instance metadata.Default: enabled /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.EC2.InstanceMetadataEndpointState")] public Amazon.EC2.InstanceMetadataEndpointState MetadataOptions_HttpEndpoint { get; set; } #endregion #region Parameter MetadataOptions_HttpProtocolIpv6 /// /// /// Enables or disables the IPv6 endpoint for the instance metadata service. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.EC2.InstanceMetadataProtocolState")] public Amazon.EC2.InstanceMetadataProtocolState MetadataOptions_HttpProtocolIpv6 { get; set; } #endregion #region Parameter MetadataOptions_HttpPutResponseHopLimit /// /// /// The desired HTTP PUT response hop limit for instance metadata requests. The larger /// the number, the further instance metadata requests can travel.Default: 1Possible values: Integers from 1 to 64 /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int32? MetadataOptions_HttpPutResponseHopLimit { get; set; } #endregion #region Parameter MetadataOptions_HttpToken /// /// /// IMDSv2 uses token-backed sessions. Set the use of HTTP tokens to optional /// (in other words, set the use of IMDSv2 to optional) or required /// (in other words, set the use of IMDSv2 to required).Default: optional /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("MetadataOptions_HttpTokens")] [AWSConstantClassSource("Amazon.EC2.HttpTokensState")] public Amazon.EC2.HttpTokensState MetadataOptions_HttpToken { get; set; } #endregion #region Parameter ImageId /// /// /// The ID of the AMI. An AMI ID is required to launch an instance and must be specified /// here or in a launch template. /// /// [System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)] public System.String ImageId { get; set; } #endregion #region Parameter InstanceInitiatedShutdownBehavior /// /// /// Indicates whether an instance stops or terminates when you initiate shutdown from /// the instance (using the operating system command for system shutdown).Default: stop /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.EC2.ShutdownBehavior")] public Amazon.EC2.ShutdownBehavior InstanceInitiatedShutdownBehavior { get; set; } #endregion #region Parameter InstanceMarketOption /// /// /// The market (purchasing) option for the instances.For RunInstances, persistent Spot Instance requests are only supported when /// InstanceInterruptionBehavior is set to either hibernate or stop. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("InstanceMarketOptions")] public Amazon.EC2.Model.InstanceMarketOptionsRequest InstanceMarketOption { get; set; } #endregion #region Parameter MetadataOptions_InstanceMetadataTag /// /// /// Set to enabled to allow access to instance tags from the instance metadata. /// Set to disabled to turn off access to instance tags from the instance /// metadata. For more information, see Work /// with instance tags using the instance metadata.Default: disabled /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("MetadataOptions_InstanceMetadataTags")] [AWSConstantClassSource("Amazon.EC2.InstanceMetadataTagsState")] public Amazon.EC2.InstanceMetadataTagsState MetadataOptions_InstanceMetadataTag { get; set; } #endregion #region Parameter InstanceType /// /// /// The instance type. For more information, see Instance /// types in the Amazon EC2 User Guide. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.EC2.InstanceType")] public Amazon.EC2.InstanceType InstanceType { get; set; } #endregion #region Parameter Ipv6AddressCount /// /// /// The number of IPv6 addresses to associate with the primary network interface. Amazon /// EC2 chooses the IPv6 addresses from the range of your subnet. You cannot specify this /// option and the option to assign specific IPv6 addresses in the same request. You can /// specify this option if you've specified a minimum number of instances to launch.You cannot specify this option and the network interfaces option in the same request. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int32? Ipv6AddressCount { get; set; } #endregion #region Parameter Ipv6Address /// /// /// The IPv6 addresses from the range of the subnet to associate with the primary network /// interface. You cannot specify this option and the option to assign a number of IPv6 /// addresses in the same request. You cannot specify this option if you've specified /// a minimum number of instances to launch.You cannot specify this option and the network interfaces option in the same request. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("Ipv6Addresses")] public Amazon.EC2.Model.InstanceIpv6Address[] Ipv6Address { get; set; } #endregion #region Parameter KernelId /// /// /// The ID of the kernel.We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, /// see PV-GRUB /// in the Amazon EC2 User Guide. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String KernelId { get; set; } #endregion #region Parameter KeyName /// /// /// The name of the key pair. You can create a key pair using CreateKeyPair /// or ImportKeyPair.If you do not specify a key pair, you can't connect to the instance unless you choose /// an AMI that is configured to allow users another way to log in. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String KeyName { get; set; } #endregion #region Parameter LaunchTemplate /// /// /// The launch template to use to launch the instances. Any parameters that you specify /// in RunInstances override the same parameters in the launch template. You can /// specify either the name or ID of a launch template, but not both. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public Amazon.EC2.Model.LaunchTemplateSpecification LaunchTemplate { get; set; } #endregion #region Parameter LicenseSpecification /// /// /// The license configurations. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("LicenseSpecifications")] public Amazon.EC2.Model.LicenseConfigurationRequest[] LicenseSpecification { get; set; } #endregion #region Parameter MaxCount /// /// /// The maximum number of instances to launch. If you specify more instances than Amazon /// EC2 can launch in the target Availability Zone, Amazon EC2 launches the largest possible /// number of instances above MinCount.Constraints: Between 1 and the maximum number you're allowed for the specified instance /// type. For more information about the default limits, and how to request an increase, /// see How /// many instances can I run in Amazon EC2 in the Amazon EC2 FAQ. /// /// If a value for this parameter is not specified the cmdlet will use a default value of '1'. /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int32? MaxCount { get; set; } #endregion #region Parameter MinCount /// /// /// The minimum number of instances to launch. If you specify a minimum that is more instances /// than Amazon EC2 can launch in the target Availability Zone, Amazon EC2 launches no /// instances.Constraints: Between 1 and the maximum number you're allowed for the specified instance /// type. For more information about the default limits, and how to request an increase, /// see How /// many instances can I run in Amazon EC2 in the Amazon EC2 General FAQ. /// /// If a value for this parameter is not specified the cmdlet will use a default value of '1'. /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int32? MinCount { get; set; } #endregion #region Parameter Monitoring /// /// /// Specifies whether detailed monitoring is enabled for the instance. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("Monitoring_Enabled")] public System.Boolean? Monitoring { get; set; } #endregion #region Parameter IamInstanceProfile_Name /// /// /// The name of the instance profile. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("InstanceProfile_Id","InstanceProfile_Name")] public System.String IamInstanceProfile_Name { get; set; } #endregion #region Parameter NetworkInterface /// /// /// The network interfaces to associate with the instance. If you specify a network interface, /// you must specify any security groups and subnets as part of the network interface. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("NetworkInterfaces","NetworkInterfaceSet")] public Amazon.EC2.Model.InstanceNetworkInterfaceSpecification[] NetworkInterface { get; set; } #endregion #region Parameter Placement_PartitionNumber /// /// /// The number of the partition that the instance is in. Valid only if the placement group /// strategy is set to partition.This parameter is not supported for CreateFleet. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int32? Placement_PartitionNumber { get; set; } #endregion #region Parameter PrivateIpAddress /// /// /// The primary IPv4 address. You must specify a value from the IPv4 address range of /// the subnet.Only one private IP address can be designated as primary. You can't specify this option /// if you've specified the option to designate a private IP address as the primary IP /// address in a network interface specification. You cannot specify this option if you're /// launching more than one instance in the request.You cannot specify this option and the network interfaces option in the same request. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String PrivateIpAddress { get; set; } #endregion #region Parameter RamdiskId /// /// /// The ID of the RAM disk to select. Some kernels require additional drivers at launch. /// Check the kernel requirements for information about whether you need to specify a /// RAM disk. To find kernel requirements, go to the Amazon Web Services Resource Center /// and search for the kernel ID.We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, /// see PV-GRUB /// in the Amazon EC2 User Guide. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String RamdiskId { get; set; } #endregion #region Parameter SecurityGroupId /// /// /// The IDs of the security groups. You can create a security group using CreateSecurityGroup.If you specify a network interface, you must specify any security groups as part of /// the network interface. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("SecurityGroupIds")] public System.String[] SecurityGroupId { get; set; } #endregion #region Parameter SecurityGroup /// /// /// [Default VPC] The names of the security groups.If you specify a network interface, you must specify any security groups as part of /// the network interface.Default: Amazon EC2 uses the default security group. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("SecurityGroups")] public System.String[] SecurityGroup { get; set; } #endregion #region Parameter Placement_SpreadDomain /// /// /// Reserved for future use. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String Placement_SpreadDomain { get; set; } #endregion #region Parameter SubnetId /// /// /// The ID of the subnet to launch the instance into.If you specify a network interface, you must specify any subnets as part of the network /// interface. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String SubnetId { get; set; } #endregion #region Parameter TagSpecification /// /// /// The tags to apply to the resources that are created during instance launch.You can specify tags for the following resources only:To tag a resource after it has been created, see CreateTags. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("TagSpecifications")] public Amazon.EC2.Model.TagSpecification[] TagSpecification { get; set; } #endregion #region Parameter Placement_Tenancy /// /// /// The tenancy of the instance. An instance with a tenancy of dedicated /// runs on single-tenant hardware.This parameter is not supported for CreateFleet. /// The host tenancy is not supported for ImportInstance /// or for T3 instances that are configured for the unlimited CPU credit /// option. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("Tenancy")] [AWSConstantClassSource("Amazon.EC2.Tenancy")] public Amazon.EC2.Tenancy Placement_Tenancy { get; set; } #endregion #region Parameter UserData /// /// The base64-encoded MIME user data for the instances. If the -EncodeUserData switch is also set, the value for this parameter can be supplied as normal ASCII text and will be base64-encoded by the cmdlet. /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String UserData { get; set; } #endregion #region Parameter ClientToken /// /// /// Unique, case-sensitive identifier you provide to ensure the idempotency of the request. /// If you do not specify a client token, a randomly generated token is used for the request /// to ensure idempotency.For more information, see Ensuring /// Idempotency.Constraints: Maximum 64 ASCII characters /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ClientToken { get; set; } #endregion #region Parameter Select /// /// Use the -Select parameter to control the cmdlet output. The default value is 'Reservation'. /// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.EC2.Model.RunInstancesResponse). /// Specifying the name of a property of type Amazon.EC2.Model.RunInstancesResponse 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; } = "Reservation"; #endregion #region Parameter PassThru /// /// Changes the cmdlet behavior to return the value passed to the ImageId parameter. /// The -PassThru parameter is deprecated, use -Select '^ImageId' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^ImageId' 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.ImageId), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "New-EC2Instance (RunInstances)")) { 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.ImageId; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.AdditionalInfo = this.AdditionalInfo; if (this.BlockDeviceMapping != null) { context.BlockDeviceMapping = new List(this.BlockDeviceMapping); } context.CapacityReservationSpecification_CapacityReservationPreference = this.CapacityReservationSpecification_CapacityReservationPreference; context.CapacityReservationTarget_CapacityReservationId = this.CapacityReservationTarget_CapacityReservationId; context.CapacityReservationTarget_CapacityReservationResourceGroupArn = this.CapacityReservationTarget_CapacityReservationResourceGroupArn; context.ClientToken = this.ClientToken; context.CpuOption = this.CpuOption; context.CreditSpecification_CpuCredit = this.CreditSpecification_CpuCredit; context.DisableApiStop = this.DisableApiStop; context.DisableApiTermination = this.DisableApiTermination; context.EbsOptimized = this.EbsOptimized; if (this.ElasticGpuSpecification != null) { context.ElasticGpuSpecification = new List(this.ElasticGpuSpecification); } if (this.ElasticInferenceAccelerator != null) { context.ElasticInferenceAccelerator = new List(this.ElasticInferenceAccelerator); } context.EnclaveOptions_Enabled = this.EnclaveOptions_Enabled; context.HibernationOptions_Configured = this.HibernationOptions_Configured; context.IamInstanceProfile_Arn = this.IamInstanceProfile_Arn; context.IamInstanceProfile_Name = this.IamInstanceProfile_Name; context.ImageId = this.ImageId; context.InstanceInitiatedShutdownBehavior = this.InstanceInitiatedShutdownBehavior; context.InstanceMarketOption = this.InstanceMarketOption; context.InstanceType = this.InstanceType; context.Ipv6AddressCount = this.Ipv6AddressCount; if (this.Ipv6Address != null) { context.Ipv6Address = new List(this.Ipv6Address); } context.KernelId = this.KernelId; context.KeyName = this.KeyName; context.LaunchTemplate = this.LaunchTemplate; if (this.LicenseSpecification != null) { context.LicenseSpecification = new List(this.LicenseSpecification); } context.MaintenanceOptions_AutoRecovery = this.MaintenanceOptions_AutoRecovery; context.MaxCount = this.MaxCount; if (!ParameterWasBound(nameof(this.MaxCount))) { WriteVerbose("MaxCount parameter unset, using default value of '1'"); context.MaxCount = 1; } #if MODULAR if (this.MaxCount == null && ParameterWasBound(nameof(this.MaxCount))) { WriteWarning("You are passing $null as a value for parameter MaxCount 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 context.MetadataOptions_HttpEndpoint = this.MetadataOptions_HttpEndpoint; context.MetadataOptions_HttpProtocolIpv6 = this.MetadataOptions_HttpProtocolIpv6; context.MetadataOptions_HttpPutResponseHopLimit = this.MetadataOptions_HttpPutResponseHopLimit; context.MetadataOptions_HttpToken = this.MetadataOptions_HttpToken; context.MetadataOptions_InstanceMetadataTag = this.MetadataOptions_InstanceMetadataTag; context.MinCount = this.MinCount; if (!ParameterWasBound(nameof(this.MinCount))) { WriteVerbose("MinCount parameter unset, using default value of '1'"); context.MinCount = 1; } #if MODULAR if (this.MinCount == null && ParameterWasBound(nameof(this.MinCount))) { WriteWarning("You are passing $null as a value for parameter MinCount 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 context.Monitoring = this.Monitoring; if (this.NetworkInterface != null) { context.NetworkInterface = new List(this.NetworkInterface); } context.Placement_Affinity = this.Placement_Affinity; context.Placement_AvailabilityZone = this.Placement_AvailabilityZone; context.Placement_GroupId = this.Placement_GroupId; context.Placement_GroupName = this.Placement_GroupName; context.Placement_HostId = this.Placement_HostId; context.Placement_HostResourceGroupArn = this.Placement_HostResourceGroupArn; context.Placement_PartitionNumber = this.Placement_PartitionNumber; context.Placement_SpreadDomain = this.Placement_SpreadDomain; context.Placement_Tenancy = this.Placement_Tenancy; context.PrivateDnsNameOptions_EnableResourceNameDnsAAAARecord = this.PrivateDnsNameOptions_EnableResourceNameDnsAAAARecord; context.PrivateDnsNameOptions_EnableResourceNameDnsARecord = this.PrivateDnsNameOptions_EnableResourceNameDnsARecord; context.PrivateDnsNameOptions_HostnameType = this.PrivateDnsNameOptions_HostnameType; context.PrivateIpAddress = this.PrivateIpAddress; context.RamdiskId = this.RamdiskId; if (this.SecurityGroupId != null) { context.SecurityGroupId = new List(this.SecurityGroupId); } if (this.SecurityGroup != null) { context.SecurityGroup = new List(this.SecurityGroup); } context.SubnetId = this.SubnetId; if (this.TagSpecification != null) { context.TagSpecification = new List(this.TagSpecification); } context.UserData = this.UserData; // 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.EC2.Model.RunInstancesRequest(); if (cmdletContext.AdditionalInfo != null) { request.AdditionalInfo = cmdletContext.AdditionalInfo; } if (cmdletContext.BlockDeviceMapping != null) { request.BlockDeviceMappings = cmdletContext.BlockDeviceMapping; } // populate CapacityReservationSpecification var requestCapacityReservationSpecificationIsNull = true; request.CapacityReservationSpecification = new Amazon.EC2.Model.CapacityReservationSpecification(); Amazon.EC2.CapacityReservationPreference requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationPreference = null; if (cmdletContext.CapacityReservationSpecification_CapacityReservationPreference != null) { requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationPreference = cmdletContext.CapacityReservationSpecification_CapacityReservationPreference; } if (requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationPreference != null) { request.CapacityReservationSpecification.CapacityReservationPreference = requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationPreference; requestCapacityReservationSpecificationIsNull = false; } Amazon.EC2.Model.CapacityReservationTarget requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget = null; // populate CapacityReservationTarget var requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTargetIsNull = true; requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget = new Amazon.EC2.Model.CapacityReservationTarget(); System.String requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget_capacityReservationTarget_CapacityReservationId = null; if (cmdletContext.CapacityReservationTarget_CapacityReservationId != null) { requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget_capacityReservationTarget_CapacityReservationId = cmdletContext.CapacityReservationTarget_CapacityReservationId; } if (requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget_capacityReservationTarget_CapacityReservationId != null) { requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget.CapacityReservationId = requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget_capacityReservationTarget_CapacityReservationId; requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTargetIsNull = false; } System.String requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget_capacityReservationTarget_CapacityReservationResourceGroupArn = null; if (cmdletContext.CapacityReservationTarget_CapacityReservationResourceGroupArn != null) { requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget_capacityReservationTarget_CapacityReservationResourceGroupArn = cmdletContext.CapacityReservationTarget_CapacityReservationResourceGroupArn; } if (requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget_capacityReservationTarget_CapacityReservationResourceGroupArn != null) { requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget.CapacityReservationResourceGroupArn = requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget_capacityReservationTarget_CapacityReservationResourceGroupArn; requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTargetIsNull = false; } // determine if requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget should be set to null if (requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTargetIsNull) { requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget = null; } if (requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget != null) { request.CapacityReservationSpecification.CapacityReservationTarget = requestCapacityReservationSpecification_capacityReservationSpecification_CapacityReservationTarget; requestCapacityReservationSpecificationIsNull = false; } // determine if request.CapacityReservationSpecification should be set to null if (requestCapacityReservationSpecificationIsNull) { request.CapacityReservationSpecification = null; } if (cmdletContext.ClientToken != null) { request.ClientToken = cmdletContext.ClientToken; } if (cmdletContext.CpuOption != null) { request.CpuOptions = cmdletContext.CpuOption; } // populate CreditSpecification var requestCreditSpecificationIsNull = true; request.CreditSpecification = new Amazon.EC2.Model.CreditSpecificationRequest(); System.String requestCreditSpecification_creditSpecification_CpuCredit = null; if (cmdletContext.CreditSpecification_CpuCredit != null) { requestCreditSpecification_creditSpecification_CpuCredit = cmdletContext.CreditSpecification_CpuCredit; } if (requestCreditSpecification_creditSpecification_CpuCredit != null) { request.CreditSpecification.CpuCredits = requestCreditSpecification_creditSpecification_CpuCredit; requestCreditSpecificationIsNull = false; } // determine if request.CreditSpecification should be set to null if (requestCreditSpecificationIsNull) { request.CreditSpecification = null; } if (cmdletContext.DisableApiStop != null) { request.DisableApiStop = cmdletContext.DisableApiStop.Value; } if (cmdletContext.DisableApiTermination != null) { request.DisableApiTermination = cmdletContext.DisableApiTermination.Value; } if (cmdletContext.EbsOptimized != null) { request.EbsOptimized = cmdletContext.EbsOptimized.Value; } if (cmdletContext.ElasticGpuSpecification != null) { request.ElasticGpuSpecification = cmdletContext.ElasticGpuSpecification; } if (cmdletContext.ElasticInferenceAccelerator != null) { request.ElasticInferenceAccelerators = cmdletContext.ElasticInferenceAccelerator; } // populate EnclaveOptions var requestEnclaveOptionsIsNull = true; request.EnclaveOptions = new Amazon.EC2.Model.EnclaveOptionsRequest(); System.Boolean? requestEnclaveOptions_enclaveOptions_Enabled = null; if (cmdletContext.EnclaveOptions_Enabled != null) { requestEnclaveOptions_enclaveOptions_Enabled = cmdletContext.EnclaveOptions_Enabled.Value; } if (requestEnclaveOptions_enclaveOptions_Enabled != null) { request.EnclaveOptions.Enabled = requestEnclaveOptions_enclaveOptions_Enabled.Value; requestEnclaveOptionsIsNull = false; } // determine if request.EnclaveOptions should be set to null if (requestEnclaveOptionsIsNull) { request.EnclaveOptions = null; } // populate HibernationOptions var requestHibernationOptionsIsNull = true; request.HibernationOptions = new Amazon.EC2.Model.HibernationOptionsRequest(); System.Boolean? requestHibernationOptions_hibernationOptions_Configured = null; if (cmdletContext.HibernationOptions_Configured != null) { requestHibernationOptions_hibernationOptions_Configured = cmdletContext.HibernationOptions_Configured.Value; } if (requestHibernationOptions_hibernationOptions_Configured != null) { request.HibernationOptions.Configured = requestHibernationOptions_hibernationOptions_Configured.Value; requestHibernationOptionsIsNull = false; } // determine if request.HibernationOptions should be set to null if (requestHibernationOptionsIsNull) { request.HibernationOptions = null; } // populate IamInstanceProfile var requestIamInstanceProfileIsNull = true; request.IamInstanceProfile = new Amazon.EC2.Model.IamInstanceProfileSpecification(); System.String requestIamInstanceProfile_iamInstanceProfile_Arn = null; if (cmdletContext.IamInstanceProfile_Arn != null) { requestIamInstanceProfile_iamInstanceProfile_Arn = cmdletContext.IamInstanceProfile_Arn; } if (requestIamInstanceProfile_iamInstanceProfile_Arn != null) { request.IamInstanceProfile.Arn = requestIamInstanceProfile_iamInstanceProfile_Arn; requestIamInstanceProfileIsNull = false; } System.String requestIamInstanceProfile_iamInstanceProfile_Name = null; if (cmdletContext.IamInstanceProfile_Name != null) { requestIamInstanceProfile_iamInstanceProfile_Name = cmdletContext.IamInstanceProfile_Name; } if (requestIamInstanceProfile_iamInstanceProfile_Name != null) { request.IamInstanceProfile.Name = requestIamInstanceProfile_iamInstanceProfile_Name; requestIamInstanceProfileIsNull = false; } // determine if request.IamInstanceProfile should be set to null if (requestIamInstanceProfileIsNull) { request.IamInstanceProfile = null; } if (cmdletContext.ImageId != null) { request.ImageId = cmdletContext.ImageId; } if (cmdletContext.InstanceInitiatedShutdownBehavior != null) { request.InstanceInitiatedShutdownBehavior = cmdletContext.InstanceInitiatedShutdownBehavior; } if (cmdletContext.InstanceMarketOption != null) { request.InstanceMarketOptions = cmdletContext.InstanceMarketOption; } if (cmdletContext.InstanceType != null) { request.InstanceType = cmdletContext.InstanceType; } if (cmdletContext.Ipv6AddressCount != null) { request.Ipv6AddressCount = cmdletContext.Ipv6AddressCount.Value; } if (cmdletContext.Ipv6Address != null) { request.Ipv6Addresses = cmdletContext.Ipv6Address; } if (cmdletContext.KernelId != null) { request.KernelId = cmdletContext.KernelId; } if (cmdletContext.KeyName != null) { request.KeyName = cmdletContext.KeyName; } if (cmdletContext.LaunchTemplate != null) { request.LaunchTemplate = cmdletContext.LaunchTemplate; } if (cmdletContext.LicenseSpecification != null) { request.LicenseSpecifications = cmdletContext.LicenseSpecification; } // populate MaintenanceOptions var requestMaintenanceOptionsIsNull = true; request.MaintenanceOptions = new Amazon.EC2.Model.InstanceMaintenanceOptionsRequest(); Amazon.EC2.InstanceAutoRecoveryState requestMaintenanceOptions_maintenanceOptions_AutoRecovery = null; if (cmdletContext.MaintenanceOptions_AutoRecovery != null) { requestMaintenanceOptions_maintenanceOptions_AutoRecovery = cmdletContext.MaintenanceOptions_AutoRecovery; } if (requestMaintenanceOptions_maintenanceOptions_AutoRecovery != null) { request.MaintenanceOptions.AutoRecovery = requestMaintenanceOptions_maintenanceOptions_AutoRecovery; requestMaintenanceOptionsIsNull = false; } // determine if request.MaintenanceOptions should be set to null if (requestMaintenanceOptionsIsNull) { request.MaintenanceOptions = null; } if (cmdletContext.MaxCount != null) { request.MaxCount = cmdletContext.MaxCount.Value; } // populate MetadataOptions var requestMetadataOptionsIsNull = true; request.MetadataOptions = new Amazon.EC2.Model.InstanceMetadataOptionsRequest(); Amazon.EC2.InstanceMetadataEndpointState requestMetadataOptions_metadataOptions_HttpEndpoint = null; if (cmdletContext.MetadataOptions_HttpEndpoint != null) { requestMetadataOptions_metadataOptions_HttpEndpoint = cmdletContext.MetadataOptions_HttpEndpoint; } if (requestMetadataOptions_metadataOptions_HttpEndpoint != null) { request.MetadataOptions.HttpEndpoint = requestMetadataOptions_metadataOptions_HttpEndpoint; requestMetadataOptionsIsNull = false; } Amazon.EC2.InstanceMetadataProtocolState requestMetadataOptions_metadataOptions_HttpProtocolIpv6 = null; if (cmdletContext.MetadataOptions_HttpProtocolIpv6 != null) { requestMetadataOptions_metadataOptions_HttpProtocolIpv6 = cmdletContext.MetadataOptions_HttpProtocolIpv6; } if (requestMetadataOptions_metadataOptions_HttpProtocolIpv6 != null) { request.MetadataOptions.HttpProtocolIpv6 = requestMetadataOptions_metadataOptions_HttpProtocolIpv6; requestMetadataOptionsIsNull = false; } System.Int32? requestMetadataOptions_metadataOptions_HttpPutResponseHopLimit = null; if (cmdletContext.MetadataOptions_HttpPutResponseHopLimit != null) { requestMetadataOptions_metadataOptions_HttpPutResponseHopLimit = cmdletContext.MetadataOptions_HttpPutResponseHopLimit.Value; } if (requestMetadataOptions_metadataOptions_HttpPutResponseHopLimit != null) { request.MetadataOptions.HttpPutResponseHopLimit = requestMetadataOptions_metadataOptions_HttpPutResponseHopLimit.Value; requestMetadataOptionsIsNull = false; } Amazon.EC2.HttpTokensState requestMetadataOptions_metadataOptions_HttpToken = null; if (cmdletContext.MetadataOptions_HttpToken != null) { requestMetadataOptions_metadataOptions_HttpToken = cmdletContext.MetadataOptions_HttpToken; } if (requestMetadataOptions_metadataOptions_HttpToken != null) { request.MetadataOptions.HttpTokens = requestMetadataOptions_metadataOptions_HttpToken; requestMetadataOptionsIsNull = false; } Amazon.EC2.InstanceMetadataTagsState requestMetadataOptions_metadataOptions_InstanceMetadataTag = null; if (cmdletContext.MetadataOptions_InstanceMetadataTag != null) { requestMetadataOptions_metadataOptions_InstanceMetadataTag = cmdletContext.MetadataOptions_InstanceMetadataTag; } if (requestMetadataOptions_metadataOptions_InstanceMetadataTag != null) { request.MetadataOptions.InstanceMetadataTags = requestMetadataOptions_metadataOptions_InstanceMetadataTag; requestMetadataOptionsIsNull = false; } // determine if request.MetadataOptions should be set to null if (requestMetadataOptionsIsNull) { request.MetadataOptions = null; } if (cmdletContext.MinCount != null) { request.MinCount = cmdletContext.MinCount.Value; } if (cmdletContext.Monitoring != null) { request.Monitoring = cmdletContext.Monitoring.Value; } if (cmdletContext.NetworkInterface != null) { request.NetworkInterfaces = cmdletContext.NetworkInterface; } // populate Placement var requestPlacementIsNull = true; request.Placement = new Amazon.EC2.Model.Placement(); System.String requestPlacement_placement_Affinity = null; if (cmdletContext.Placement_Affinity != null) { requestPlacement_placement_Affinity = cmdletContext.Placement_Affinity; } if (requestPlacement_placement_Affinity != null) { request.Placement.Affinity = requestPlacement_placement_Affinity; requestPlacementIsNull = false; } System.String requestPlacement_placement_AvailabilityZone = null; if (cmdletContext.Placement_AvailabilityZone != null) { requestPlacement_placement_AvailabilityZone = cmdletContext.Placement_AvailabilityZone; } if (requestPlacement_placement_AvailabilityZone != null) { request.Placement.AvailabilityZone = requestPlacement_placement_AvailabilityZone; requestPlacementIsNull = false; } System.String requestPlacement_placement_GroupId = null; if (cmdletContext.Placement_GroupId != null) { requestPlacement_placement_GroupId = cmdletContext.Placement_GroupId; } if (requestPlacement_placement_GroupId != null) { request.Placement.GroupId = requestPlacement_placement_GroupId; requestPlacementIsNull = false; } System.String requestPlacement_placement_GroupName = null; if (cmdletContext.Placement_GroupName != null) { requestPlacement_placement_GroupName = cmdletContext.Placement_GroupName; } if (requestPlacement_placement_GroupName != null) { request.Placement.GroupName = requestPlacement_placement_GroupName; requestPlacementIsNull = false; } System.String requestPlacement_placement_HostId = null; if (cmdletContext.Placement_HostId != null) { requestPlacement_placement_HostId = cmdletContext.Placement_HostId; } if (requestPlacement_placement_HostId != null) { request.Placement.HostId = requestPlacement_placement_HostId; requestPlacementIsNull = false; } System.String requestPlacement_placement_HostResourceGroupArn = null; if (cmdletContext.Placement_HostResourceGroupArn != null) { requestPlacement_placement_HostResourceGroupArn = cmdletContext.Placement_HostResourceGroupArn; } if (requestPlacement_placement_HostResourceGroupArn != null) { request.Placement.HostResourceGroupArn = requestPlacement_placement_HostResourceGroupArn; requestPlacementIsNull = false; } System.Int32? requestPlacement_placement_PartitionNumber = null; if (cmdletContext.Placement_PartitionNumber != null) { requestPlacement_placement_PartitionNumber = cmdletContext.Placement_PartitionNumber.Value; } if (requestPlacement_placement_PartitionNumber != null) { request.Placement.PartitionNumber = requestPlacement_placement_PartitionNumber.Value; requestPlacementIsNull = false; } System.String requestPlacement_placement_SpreadDomain = null; if (cmdletContext.Placement_SpreadDomain != null) { requestPlacement_placement_SpreadDomain = cmdletContext.Placement_SpreadDomain; } if (requestPlacement_placement_SpreadDomain != null) { request.Placement.SpreadDomain = requestPlacement_placement_SpreadDomain; requestPlacementIsNull = false; } Amazon.EC2.Tenancy requestPlacement_placement_Tenancy = null; if (cmdletContext.Placement_Tenancy != null) { requestPlacement_placement_Tenancy = cmdletContext.Placement_Tenancy; } if (requestPlacement_placement_Tenancy != null) { request.Placement.Tenancy = requestPlacement_placement_Tenancy; requestPlacementIsNull = false; } // determine if request.Placement should be set to null if (requestPlacementIsNull) { request.Placement = null; } // populate PrivateDnsNameOptions var requestPrivateDnsNameOptionsIsNull = true; request.PrivateDnsNameOptions = new Amazon.EC2.Model.PrivateDnsNameOptionsRequest(); System.Boolean? requestPrivateDnsNameOptions_privateDnsNameOptions_EnableResourceNameDnsAAAARecord = null; if (cmdletContext.PrivateDnsNameOptions_EnableResourceNameDnsAAAARecord != null) { requestPrivateDnsNameOptions_privateDnsNameOptions_EnableResourceNameDnsAAAARecord = cmdletContext.PrivateDnsNameOptions_EnableResourceNameDnsAAAARecord.Value; } if (requestPrivateDnsNameOptions_privateDnsNameOptions_EnableResourceNameDnsAAAARecord != null) { request.PrivateDnsNameOptions.EnableResourceNameDnsAAAARecord = requestPrivateDnsNameOptions_privateDnsNameOptions_EnableResourceNameDnsAAAARecord.Value; requestPrivateDnsNameOptionsIsNull = false; } System.Boolean? requestPrivateDnsNameOptions_privateDnsNameOptions_EnableResourceNameDnsARecord = null; if (cmdletContext.PrivateDnsNameOptions_EnableResourceNameDnsARecord != null) { requestPrivateDnsNameOptions_privateDnsNameOptions_EnableResourceNameDnsARecord = cmdletContext.PrivateDnsNameOptions_EnableResourceNameDnsARecord.Value; } if (requestPrivateDnsNameOptions_privateDnsNameOptions_EnableResourceNameDnsARecord != null) { request.PrivateDnsNameOptions.EnableResourceNameDnsARecord = requestPrivateDnsNameOptions_privateDnsNameOptions_EnableResourceNameDnsARecord.Value; requestPrivateDnsNameOptionsIsNull = false; } Amazon.EC2.HostnameType requestPrivateDnsNameOptions_privateDnsNameOptions_HostnameType = null; if (cmdletContext.PrivateDnsNameOptions_HostnameType != null) { requestPrivateDnsNameOptions_privateDnsNameOptions_HostnameType = cmdletContext.PrivateDnsNameOptions_HostnameType; } if (requestPrivateDnsNameOptions_privateDnsNameOptions_HostnameType != null) { request.PrivateDnsNameOptions.HostnameType = requestPrivateDnsNameOptions_privateDnsNameOptions_HostnameType; requestPrivateDnsNameOptionsIsNull = false; } // determine if request.PrivateDnsNameOptions should be set to null if (requestPrivateDnsNameOptionsIsNull) { request.PrivateDnsNameOptions = null; } if (cmdletContext.PrivateIpAddress != null) { request.PrivateIpAddress = cmdletContext.PrivateIpAddress; } if (cmdletContext.RamdiskId != null) { request.RamdiskId = cmdletContext.RamdiskId; } if (cmdletContext.SecurityGroupId != null) { request.SecurityGroupIds = cmdletContext.SecurityGroupId; } if (cmdletContext.SecurityGroup != null) { request.SecurityGroups = cmdletContext.SecurityGroup; } if (cmdletContext.SubnetId != null) { request.SubnetId = cmdletContext.SubnetId; } if (cmdletContext.TagSpecification != null) { request.TagSpecifications = cmdletContext.TagSpecification; } if (cmdletContext.UserData != null) { request.UserData = cmdletContext.UserData; } 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.EC2.Model.RunInstancesResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.RunInstancesRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "RunInstances"); try { #if DESKTOP return client.RunInstances(request); #elif CORECLR return client.RunInstancesAsync(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 System.String AdditionalInfo { get; set; } public List BlockDeviceMapping { get; set; } public Amazon.EC2.CapacityReservationPreference CapacityReservationSpecification_CapacityReservationPreference { get; set; } public System.String CapacityReservationTarget_CapacityReservationId { get; set; } public System.String CapacityReservationTarget_CapacityReservationResourceGroupArn { get; set; } public System.String ClientToken { get; set; } public Amazon.EC2.Model.CpuOptionsRequest CpuOption { get; set; } public System.String CreditSpecification_CpuCredit { get; set; } public System.Boolean? DisableApiStop { get; set; } public System.Boolean? DisableApiTermination { get; set; } public System.Boolean? EbsOptimized { get; set; } public List ElasticGpuSpecification { get; set; } public List ElasticInferenceAccelerator { get; set; } public System.Boolean? EnclaveOptions_Enabled { get; set; } public System.Boolean? HibernationOptions_Configured { get; set; } public System.String IamInstanceProfile_Arn { get; set; } public System.String IamInstanceProfile_Name { get; set; } public System.String ImageId { get; set; } public Amazon.EC2.ShutdownBehavior InstanceInitiatedShutdownBehavior { get; set; } public Amazon.EC2.Model.InstanceMarketOptionsRequest InstanceMarketOption { get; set; } public Amazon.EC2.InstanceType InstanceType { get; set; } public System.Int32? Ipv6AddressCount { get; set; } public List Ipv6Address { get; set; } public System.String KernelId { get; set; } public System.String KeyName { get; set; } public Amazon.EC2.Model.LaunchTemplateSpecification LaunchTemplate { get; set; } public List LicenseSpecification { get; set; } public Amazon.EC2.InstanceAutoRecoveryState MaintenanceOptions_AutoRecovery { get; set; } public System.Int32? MaxCount { get; set; } public Amazon.EC2.InstanceMetadataEndpointState MetadataOptions_HttpEndpoint { get; set; } public Amazon.EC2.InstanceMetadataProtocolState MetadataOptions_HttpProtocolIpv6 { get; set; } public System.Int32? MetadataOptions_HttpPutResponseHopLimit { get; set; } public Amazon.EC2.HttpTokensState MetadataOptions_HttpToken { get; set; } public Amazon.EC2.InstanceMetadataTagsState MetadataOptions_InstanceMetadataTag { get; set; } public System.Int32? MinCount { get; set; } public System.Boolean? Monitoring { get; set; } public List NetworkInterface { get; set; } public System.String Placement_Affinity { get; set; } public System.String Placement_AvailabilityZone { get; set; } public System.String Placement_GroupId { get; set; } public System.String Placement_GroupName { get; set; } public System.String Placement_HostId { get; set; } public System.String Placement_HostResourceGroupArn { get; set; } public System.Int32? Placement_PartitionNumber { get; set; } public System.String Placement_SpreadDomain { get; set; } public Amazon.EC2.Tenancy Placement_Tenancy { get; set; } public System.Boolean? PrivateDnsNameOptions_EnableResourceNameDnsAAAARecord { get; set; } public System.Boolean? PrivateDnsNameOptions_EnableResourceNameDnsARecord { get; set; } public Amazon.EC2.HostnameType PrivateDnsNameOptions_HostnameType { get; set; } public System.String PrivateIpAddress { get; set; } public System.String RamdiskId { get; set; } public List SecurityGroupId { get; set; } public List SecurityGroup { get; set; } public System.String SubnetId { get; set; } public List TagSpecification { get; set; } public System.String UserData { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => response.Reservation; } } }