Skip to content

create_instances

create_instances(
    instance_names: StringList,
    availability_zone: string,
    blueprint_id: NonEmptyString,
    bundle_id: NonEmptyString,
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
    custom_image_name: Optional[ResourceName] = None,
    user_data: Optional[string] = None,
    key_pair_name: Optional[ResourceName] = None,
    tags: Optional[TagList] = None,
    add_ons: Optional[AddOnRequestList] = None,
    ip_address_type: Optional[IpAddressType] = None,
) -> CreateInstancesResult

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.

Parameters:

  • instance_names (StringList) –

    The names to use for your new Lightsail instances. Separate multiple values using quotation marks and commas, for example: ["MyFirstInstance","MySecondInstance"]

  • availability_zone (string) –

    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.

  • custom_image_name (Optional[ResourceName], default: None ) –

    (Discontinued) The name for your custom image.

    In releases prior to June 12, 2017, this parameter was ignored by the API. It is now discontinued.

  • blueprint_id (NonEmptyString) –

    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).

    Use active blueprints when creating new instances. Inactive blueprints are listed to support customers with existing instances and are not necessarily available to create new instances. Blueprints are marked inactive when they become outdated due to operating system updates or new application releases.

  • bundle_id (NonEmptyString) –

    The bundle of specification information for your virtual private server (or instance), including the pricing plan (medium_x_x).

  • user_data (Optional[string], default: None ) –

    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.

    Depending on the machine image you choose, the command to get software on your instance varies. Amazon Linux and CentOS use yum, Debian and Ubuntu use apt-get, and FreeBSD uses pkg. For a complete list, see the Amazon Lightsail Developer Guide.

  • key_pair_name (Optional[ResourceName], default: None ) –

    The name of your key pair.

  • tags (Optional[TagList], default: None ) –

    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.

  • add_ons (Optional[AddOnRequestList], default: None ) –

    An array of objects representing the add-ons to enable for the new instance.

  • ip_address_type (Optional[IpAddressType], default: None ) –

    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.

Raises:

  • AccessDeniedException –

    Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.

  • AccountSetupInProgressException –

    Lightsail throws this exception when an account is still in the setup in progress state.

  • InvalidInputException –

    Lightsail throws this exception when user input does not conform to the validation rules of an input field.

    Domain and distribution APIs are only available in the N. Virginia (us-east-1) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to us-east-1 to create, view, or edit these resources.

  • NotFoundException –

    Lightsail throws this exception when it cannot find a resource.

  • OperationFailureException –

    Lightsail throws this exception when an operation fails to execute.

  • RegionSetupInProgressException –

    Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.

  • ServiceException –

    A general service exception.

  • UnauthenticatedException –

    Lightsail throws this exception when the user has not been authenticated.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_lightsail/_services/lightsail.py
def create_instances(
    self,
    instance_names: "capo_lightsail.types.string_list.StringList",
    availability_zone: "capo_lightsail.types.string.string",
    blueprint_id: "capo_lightsail.types.non_empty_string.NonEmptyString",
    bundle_id: "capo_lightsail.types.non_empty_string.NonEmptyString",
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
    custom_image_name: Optional[
        "capo_lightsail.types.resource_name.ResourceName"
    ] = None,
    user_data: Optional["capo_lightsail.types.string.string"] = None,
    key_pair_name: Optional[
        "capo_lightsail.types.resource_name.ResourceName"
    ] = None,
    tags: Optional["capo_lightsail.types.tag_list.TagList"] = None,
    add_ons: Optional[
        "capo_lightsail.types.add_on_request_list.AddOnRequestList"
    ] = None,
    ip_address_type: Optional[
        "capo_lightsail.types.ip_address_type.IpAddressType"
    ] = None,
) -> "capo_lightsail.types.create_instances_result.CreateInstancesResult":
    """<p>Creates one or more Amazon Lightsail instances.</p> <p>The <code>create instances</code> operation supports tag-based access control via request tags. For more information, see the <a href="https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-controlling-access-using-tags">Lightsail Developer Guide</a>.</p>

    Args:
        instance_names: <p>The names to use for your new Lightsail instances. Separate multiple values using quotation marks and commas, for example: <code>["MyFirstInstance","MySecondInstance"]</code> </p>
        availability_zone: <p>The Availability Zone in which to create your instance. Use the following format: <code>us-east-2a</code> (case sensitive). You can get a list of Availability Zones by using the <a href="http://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetRegions.html">get regions</a> operation. Be sure to add the <code>include Availability Zones</code> parameter to your request.</p>
        custom_image_name: <p>(Discontinued) The name for your custom image.</p> <note> <p>In releases prior to June 12, 2017, this parameter was ignored by the API. It is now discontinued.</p> </note>
        blueprint_id: <p>The ID for a virtual private server image (<code>app_wordpress_x_x</code> or <code>app_lamp_x_x</code>). Use the <code>get blueprints</code> operation to return a list of available images (or <i>blueprints</i>).</p> <note> <p>Use active blueprints when creating new instances. Inactive blueprints are listed to support customers with existing instances and are not necessarily available to create new instances. Blueprints are marked inactive when they become outdated due to operating system updates or new application releases.</p> </note>
        bundle_id: <p>The bundle of specification information for your virtual private server (or <i>instance</i>), including the pricing plan (<code>medium_x_x</code>).</p>
        user_data: <p>A launch script you can create that configures a server with additional user data. For example, you might want to run <code>apt-get -y update</code>.</p> <note> <p>Depending on the machine image you choose, the command to get software on your instance varies. Amazon Linux and CentOS use <code>yum</code>, Debian and Ubuntu use <code>apt-get</code>, and FreeBSD uses <code>pkg</code>. For a complete list, see the <a href="https://docs.aws.amazon.com/lightsail/latest/userguide/compare-options-choose-lightsail-instance-image">Amazon Lightsail Developer Guide</a>.</p> </note>
        key_pair_name: <p>The name of your key pair.</p>
        tags: <p>The tag keys and optional values to add to the resource during create.</p> <p>Use the <code>TagResource</code> action to tag a resource after it's created.</p>
        add_ons: <p>An array of objects representing the add-ons to enable for the new instance.</p>
        ip_address_type: <p>The IP address type for the instance.</p> <p>The possible values are <code>ipv4</code> for IPv4 only, <code>ipv6</code> for IPv6 only, and <code>dualstack</code> for IPv4 and IPv6.</p> <p>The default value is <code>dualstack</code>.</p>

    Raises:
        capo_lightsail.errors.access_denied_exception.AccessDeniedException: <p>Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.</p>
        capo_lightsail.errors.account_setup_in_progress_exception.AccountSetupInProgressException: <p>Lightsail throws this exception when an account is still in the setup in progress state.</p>
        capo_lightsail.errors.invalid_input_exception.InvalidInputException: <p>Lightsail throws this exception when user input does not conform to the validation rules of an input field.</p> <note> <p>Domain and distribution APIs are only available in the N. Virginia (<code>us-east-1</code>) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to <code>us-east-1</code> to create, view, or edit these resources.</p> </note>
        capo_lightsail.errors.not_found_exception.NotFoundException: <p>Lightsail throws this exception when it cannot find a resource.</p>
        capo_lightsail.errors.operation_failure_exception.OperationFailureException: <p>Lightsail throws this exception when an operation fails to execute.</p>
        capo_lightsail.errors.region_setup_in_progress_exception.RegionSetupInProgressException: <p>Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.</p>
        capo_lightsail.errors.service_exception.ServiceException: <p>A general service exception.</p>
        capo_lightsail.errors.unauthenticated_exception.UnauthenticatedException: <p>Lightsail throws this exception when the user has not been authenticated.</p>
        capo_lightsail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lightsail.types.create_instances_request.CreateInstancesRequest]",
    ) -> OperationResponse[
        "capo_lightsail.types.create_instances_result.CreateInstancesResult"
    ]:
        import capo_lightsail._operations.lightsail_20161128.create_instances

        output, http_response = (
            capo_lightsail._operations.lightsail_20161128.create_instances.create_instances(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateInstances")
    )
    input_: capo_lightsail.types.create_instances_request.CreateInstancesRequest = {
        "instance_names": instance_names,
        "availability_zone": availability_zone,
        "blueprint_id": blueprint_id,
        "bundle_id": bundle_id,
    }
    if custom_image_name is not None:
        input_["custom_image_name"] = custom_image_name
    if user_data is not None:
        input_["user_data"] = user_data
    if key_pair_name is not None:
        input_["key_pair_name"] = key_pair_name
    if tags is not None:
        input_["tags"] = tags
    if add_ons is not None:
        input_["add_ons"] = add_ons
    if ip_address_type is not None:
        input_["ip_address_type"] = ip_address_type

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output