There are more AWS SDK examples available in the AWS Doc SDK Examples
Use ModifyReservedInstances with a CLI
The following code examples show how to use ModifyReservedInstances.
- CLI
-
- AWS CLI
-
Example 1: To modify Reserved Instances
The following
modify-reserved-instancesexample moves a Reserved Instance to another Availability Zone in the same region.aws ec2 modify-reserved-instances \ --reserved-instances-idsa1b2c3d4-5678-90ab-cdef-EXAMPLE11111\ --target-configurationsAvailabilityZone=us-west-2c,Platform=EC2-Classic,InstanceCount=10Output:
{ "ReservedInstancesModificationId": "rimod-d3ed4335-b1d3-4de6-ab31-0f13aaf46687" }For more information, see Modify Reserved Instances in the Amazon EC2 User Guide.
Example 2: To modify the network platform of Reserved Instances
The following
modify-reserved-instancesexample converts EC2-Classic Reserved Instances to EC2-VPC.aws ec2 modify-reserved-instances \ --reserved-instances-idsa1b2c3d4-5678-90ab-cdef-EXAMPLE22222\ --target-configurationsAvailabilityZone=us-west-2c,Platform=EC2-VPC,InstanceCount=5Output:
{ "ReservedInstancesModificationId": "rimod-82fa9020-668f-4fb6-945d-61537009d291" }For more information, see Modify Reserved Instances in the Amazon EC2 User Guide.
Example 3: To modify the instance size of Reserved Instances
The following
modify-reserved-instancesexample modifies a Reserved Instance that has 10 m1.small Linux/UNIX instances in us-west-2c so that 8 m1.small instances become 2 m1.large instances, and the remaining 2 m1.small become 1 m1.medium instance in the same Availability Zone.aws ec2 modify-reserved-instances \ --reserved-instances-idsa1b2c3d4-5678-90ab-cdef-EXAMPLE33333\ --target-configurationsAvailabilityZone=us-west-2c,Platform=EC2-Classic,InstanceCount=2,InstanceType=m1.largeAvailabilityZone=us-west-2c,Platform=EC2-Classic,InstanceCount=1,InstanceType=m1.mediumOutput:
{ "ReservedInstancesModificationId": "rimod-acc5f240-080d-4717-b3e3-1c6b11fa00b6" }For more information, see Modify Reserved Instances in the Amazon EC2 User Guide.
-
For API details, see ModifyReservedInstances
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This example modifies the Availability Zone, instance count, and platform for the specified Reserved instances.
$config = New-Object Amazon.EC2.Model.ReservedInstancesConfiguration $config.AvailabilityZone = "us-west-2a" $config.InstanceCount = 1 $config.Platform = "EC2-VPC" Edit-EC2ReservedInstance ` -ReservedInstancesId @("FE32132D-70D5-4795-B400-AE435EXAMPLE", "0CC556F3-7AB8-4C00-B0E5-98666EXAMPLE") ` -TargetConfiguration $config-
For API details, see ModifyReservedInstances in AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This example modifies the Availability Zone, instance count, and platform for the specified Reserved instances.
$config = New-Object Amazon.EC2.Model.ReservedInstancesConfiguration $config.AvailabilityZone = "us-west-2a" $config.InstanceCount = 1 $config.Platform = "EC2-VPC" Edit-EC2ReservedInstance ` -ReservedInstancesId @("FE32132D-70D5-4795-B400-AE435EXAMPLE", "0CC556F3-7AB8-4C00-B0E5-98666EXAMPLE") ` -TargetConfiguration $config-
For API details, see ModifyReservedInstances in AWS Tools for PowerShell Cmdlet Reference (V5).
-