# NOT RUN {
# This example creates a Spot fleet request with two launch specifications
# that differ only by subnet. The Spot fleet launches the instances in the
# specified subnet with the lowest price. If the instances are launched in
# a default VPC, they receive a public IP address by default. If the
# instances are launched in a nondefault VPC, they do not receive a public
# IP address by default. Note that you can't specify different subnets
# from the same Availability Zone in a Spot fleet request.
# }
# NOT RUN {
svc$request_spot_fleet(
SpotFleetRequestConfig = list(
IamFleetRole = "arn:aws:iam::123456789012:role/my-spot-fleet-role",
LaunchSpecifications = list(
list(
IamInstanceProfile = list(
Arn = "arn:aws:iam::123456789012:instance-profile/my-iam-role"
),
ImageId = "ami-1a2b3c4d",
InstanceType = "m3.medium",
KeyName = "my-key-pair",
SecurityGroups = list(
list(
GroupId = "sg-1a2b3c4d"
)
),
SubnetId = "subnet-1a2b3c4d, subnet-3c4d5e6f"
)
),
SpotPrice = "0.04",
TargetCapacity = 2L
)
)
# }
# NOT RUN {
# This example creates a Spot fleet request with two launch specifications
# that differ only by Availability Zone. The Spot fleet launches the
# instances in the specified Availability Zone with the lowest price. If
# your account supports EC2-VPC only, Amazon EC2 launches the Spot
# instances in the default subnet of the Availability Zone. If your
# account supports EC2-Classic, Amazon EC2 launches the instances in
# EC2-Classic in the Availability Zone.
# }
# NOT RUN {
svc$request_spot_fleet(
SpotFleetRequestConfig = list(
IamFleetRole = "arn:aws:iam::123456789012:role/my-spot-fleet-role",
LaunchSpecifications = list(
list(
IamInstanceProfile = list(
Arn = "arn:aws:iam::123456789012:instance-profile/my-iam-role"
),
ImageId = "ami-1a2b3c4d",
InstanceType = "m3.medium",
KeyName = "my-key-pair",
Placement = list(
AvailabilityZone = "us-west-2a, us-west-2b"
),
SecurityGroups = list(
list(
GroupId = "sg-1a2b3c4d"
)
)
)
),
SpotPrice = "0.04",
TargetCapacity = 2L
)
)
# }
# NOT RUN {
# This example assigns public addresses to instances launched in a
# nondefault VPC. Note that when you specify a network interface, you must
# include the subnet ID and security group ID using the network interface.
# }
# NOT RUN {
svc$request_spot_fleet(
SpotFleetRequestConfig = list(
IamFleetRole = "arn:aws:iam::123456789012:role/my-spot-fleet-role",
LaunchSpecifications = list(
list(
IamInstanceProfile = list(
Arn = "arn:aws:iam::880185128111:instance-profile/my-iam-role"
),
ImageId = "ami-1a2b3c4d",
InstanceType = "m3.medium",
KeyName = "my-key-pair",
NetworkInterfaces = list(
list(
AssociatePublicIpAddress = TRUE,
DeviceIndex = 0L,
Groups = list(
"sg-1a2b3c4d"
),
SubnetId = "subnet-1a2b3c4d"
)
)
)
),
SpotPrice = "0.04",
TargetCapacity = 2L
)
)
# }
# NOT RUN {
# This example creates a Spot fleet request that launches 30 instances
# using the diversified allocation strategy. The launch specifications
# differ by instance type. The Spot fleet distributes the instances across
# the launch specifications such that there are 10 instances of each type.
# }
# NOT RUN {
svc$request_spot_fleet(
SpotFleetRequestConfig = list(
AllocationStrategy = "diversified",
IamFleetRole = "arn:aws:iam::123456789012:role/my-spot-fleet-role",
LaunchSpecifications = list(
list(
ImageId = "ami-1a2b3c4d",
InstanceType = "c4.2xlarge",
SubnetId = "subnet-1a2b3c4d"
),
list(
ImageId = "ami-1a2b3c4d",
InstanceType = "m3.2xlarge",
SubnetId = "subnet-1a2b3c4d"
),
list(
ImageId = "ami-1a2b3c4d",
InstanceType = "r3.2xlarge",
SubnetId = "subnet-1a2b3c4d"
)
),
SpotPrice = "0.70",
TargetCapacity = 30L
)
)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab