Skip to main content

idem-spotinst

Made with pop, a Python implementation of Plugin Oriented Programming Made with Python

The Idem spot instance provider

About

An Idem plugin to manage spot instance resources. A spot instance is an instance deployed at a discount on spare EC2 capacity.

What is POP?

This project is built with pop, a Python-based implementation of Plugin Oriented Programming (POP). POP seeks to bring together concepts and wisdom from the history of computing in new ways to solve modern computing problems.

For more information:

Getting Started

Prerequisites

  • Python 3.8+

  • git (if installing from source or contributing to the project)

    To contribute to the project and set up your local development environment, see CONTRIBUTING.rst in the source repository for this project.

Installation

You can install idem-spotinst with the Python package installer (PyPI) or from source.

Install from PyPI

pip install idem-spotinst

Install from Source

# clone repo
git clone git@<your-project-path>/idem-spotinst.git
cd idem-spotinst

# Setup venv
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Usage

Setup

After installation, idem-spotinst execution and state modules are accessible to the pop hub.

For more information:

To use idem-spotinst execution and state modules to manage spot instance resources, set up a credentials.yaml file for authentication. There are multiple authentication backends for idem-spotinst, where each has its own unique set of parameters. For example:

credentials.yaml:

spotinst:
  default:
    account_id: act-11c833de
    token: b5460afe3c29a30c28abd54d190d1aa923587574321e75925cfc8268b54b4562

For more about Idem credentials files, including recommended steps for encryption and environment variables, see Authenticating with Idem

You are now ready to use idem-spotinst.

States

Idem SLS files use states to ensure that resources are in a desired configuration. An idem-spotinst SLS file supports three state functions: present, absent, and describe.

present

The present function ensures that a resource exists. If a resource doesn’t exist, running present creates it. If the resource already exists, running present might leave it unchanged, or update it if there are any configuration changes.

You can only update values that the spotinst REST API supports.

absent

The absent function ensures that a resource does not exist. If the resource exists, running absent deletes it. If the resource doesn’t exist, running absent has no effect.

describe

The describe function returns a list of all resources of the specified type under the spotinst account ID from your credentials.yaml profile.

Accessing States

States can be accessed by their relative location in idem-spotinst/idem_spotinst/states.

For example, a spotinst launch specification state can be created with the present function as shown in the following SLS file.

my_resource_launch_spec_state.sls:

my_resource_launch_spec:
    spotinst.ocean.aws.launch_spec.present:
      - name: my_resource_launch_spec
      - taints:
        - effect: NoSchedule
          key: taint1
          value: taint-value-1
      - tags:
        - tagKey: Env
          tagValue: test
      - subnet_ids:
        - subnet-06747be60363933d9
        - subnet-03b6d0dfc57e1gbd6
      - security_group_ids:
        - sg-08dcdf4874a2f5g04
        - sg-0844f76b69f16b8b8
      - ocean_id: o-b78b1e79
      - labels:
        - key: tag1
          value: value1
        - key: tag2
          value: value2
      - instance_types:
        - t2.micro
      - image_id: ami-0c02fb55956c7d318

The Idem command to create the preceding state is:

idem state $PWD/my_resource_launch_spec_state.sls

Your SLS should follow the resource parameter structure shown in the Spotinst REST API.

  • Specify URI parameters in snake case with a leading dash and space “- “.

  • Specify all parameters of the API request body exactly as shown in the the Spotinst REST API.

Current Supported Resource States

ocean_aws

k8s_cluster

launch_spec

Metadata

Release files for idem-spotinst 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for idem-spotinst 2.0.0
File Size Uploaded
idem-spotinst-2.0.0.tar.gz 21.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for idem-spotinst 2.0.0
File Interpreter ABI Platform
idem_spotinst-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.0 kB

Release files / idem-spotinst-2.0.0.tar.gz

Download URL idem-spotinst-2.0.0.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9ac7effdafb645c735704a14bb9029ac1aaef24f332cbae8bd171abae849d2f0
BLAKE2b-256 checksum
How to use checksums
a5ca1431bf3f4bffe540db0805e867895276d5fd6688fc496d7f2b68a0f8a19f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.4 tqdm/4.65.0 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.17

Release files / idem_spotinst-2.0.0-py3-none-any.whl

Download URL idem_spotinst-2.0.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d64116b3c477244445400b711f4ad1bec28d640005ea96d9e6293058274ec4cb
BLAKE2b-256 checksum
How to use checksums
f492380816a48b8293f870941b433d5038a820a3efd3d703b7143c130867e19f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.4 tqdm/4.65.0 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.17

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page