Skip to main content

No project description provided

Project description

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

  • 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

idem-spotinst-0.2.0.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

idem_spotinst-0.2.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file idem-spotinst-0.2.0.tar.gz.

File metadata

  • Download URL: idem-spotinst-0.2.0.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.2 tqdm/4.65.0 importlib-metadata/6.6.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.16

File hashes

Hashes for idem-spotinst-0.2.0.tar.gz
Algorithm Hash digest
SHA256 87160c046cb77743a024669e8305711844a38af4cb3d8184f1547194e8ddccf7
MD5 a323cb588613c3bf229372805a0fdcd9
BLAKE2b-256 f3263856d3095c03492ec7362c94c145a5091502705e6820c95b13e285203122

See more details on using hashes here.

File details

Details for the file idem_spotinst-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: idem_spotinst-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.2 tqdm/4.65.0 importlib-metadata/6.6.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.16

File hashes

Hashes for idem_spotinst-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae926b20958155380dd14ee8d278808c586748c15396367a7fd57b912b3752f3
MD5 167939531346fc6a4be64a57a168423b
BLAKE2b-256 074819b220a875fc34ee8f91d75c91336a784236ee5dcd6e34dfc9f60a495335

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page