createInstances method
Creates one or more Amazon Lightsail instances.
The create instances operation supports tag-based access
control via request tags. For more information, see the Lightsail
Developer Guide.
May throw AccessDeniedException.
May throw AccountSetupInProgressException.
May throw InvalidInputException.
May throw NotFoundException.
May throw OperationFailureException.
May throw RegionSetupInProgressException.
May throw ServiceException.
May throw UnauthenticatedException.
Parameter availabilityZone :
The Availability Zone in which to create your instance. Use the following
format: us-east-2a (case sensitive). You can get a list of
Availability Zones by using the get
regions operation. Be sure to add the include Availability
Zones parameter to your request.
Parameter blueprintId :
The ID for a virtual private server image (app_wordpress_x_x
or app_lamp_x_x). Use the get blueprints
operation to return a list of available images (or blueprints).
Parameter bundleId :
The bundle of specification information for your virtual private server
(or instance), including the pricing plan
(medium_x_x).
Parameter instanceNames :
The names to use for your new Lightsail instances. Separate multiple
values using quotation marks and commas, for example:
["MyFirstInstance","MySecondInstance"]
Parameter addOns :
An array of objects representing the add-ons to enable for the new
instance.
Parameter customImageName :
(Discontinued) The name for your custom image.
Parameter ipAddressType :
The IP address type for the instance.
The possible values are ipv4 for IPv4 only, ipv6
for IPv6 only, and dualstack for IPv4 and IPv6.
The default value is dualstack.
Parameter keyPairName :
The name of your key pair.
Parameter tags :
The tag keys and optional values to add to the resource during create.
Use the TagResource action to tag a resource after it's
created.
Parameter userData :
A launch script you can create that configures a server with additional
user data. For example, you might want to run apt-get -y
update.
Implementation
Future<CreateInstancesResult> createInstances({
required String availabilityZone,
required String blueprintId,
required String bundleId,
required List<String> instanceNames,
List<AddOnRequest>? addOns,
String? customImageName,
IpAddressType? ipAddressType,
String? keyPairName,
List<Tag>? tags,
String? userData,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.CreateInstances'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'availabilityZone': availabilityZone,
'blueprintId': blueprintId,
'bundleId': bundleId,
'instanceNames': instanceNames,
if (addOns != null) 'addOns': addOns,
if (customImageName != null) 'customImageName': customImageName,
if (ipAddressType != null) 'ipAddressType': ipAddressType.value,
if (keyPairName != null) 'keyPairName': keyPairName,
if (tags != null) 'tags': tags,
if (userData != null) 'userData': userData,
},
);
return CreateInstancesResult.fromJson(jsonResponse.body);
}