Package: idem-spotinst
The Idem spot instance providerAboutAn 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 withpop, a Python-based implementation ofPlugin 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:Intro to Plugin Oriented Programming (POP)pop-awesomepop-createGetting StartedPrerequisitesPython 3.8+git(if installing from source or contributing to the project)To contribute to the project and set up your local development environment, seeCONTRIBUTING.rstin the source repository for this project.InstallationYou can installidem-spotinstwith the Python package installer (PyPI) or from source.Install from PyPIpipinstallidem-spotinstInstall from Source# clone repogitclonegit@<your-project-path>/idem-spotinst.gitcdidem-spotinst# Setup venvpython3-mvenv.venvsource.venv/bin/activatepipinstall-e.UsageSetupAfter installation,idem-spotinstexecution and state modules are accessible to the pophub.For more information:Intro to Plugin Oriented Programming (POP)pop hubTo useidem-spotinstexecution and state modules to manage spot instance resources, set up a credentials.yaml file for authentication. There are multiple authentication backends foridem-spotinst, where each has its own unique set of parameters. For example:credentials.yaml:spotinst:default:account_id:act-11c833detoken:b5460afe3c29a30c28abd54d190d1aa923587574321e75925cfc8268b54b4562For more about Idem credentials files, including recommended steps for encryption and environment variables, seeAuthenticating with IdemYou are now ready to use idem-spotinst.StatesIdem SLS files use states to ensure that resources are in a desired configuration. An idem-spotinst SLS file supports three state functions:present,absent, anddescribe.presentThepresentfunction ensures that a resource exists. If a resource doesn’t exist, runningpresentcreates it. If the resource already exists, runningpresentmight leave it unchanged, or update it if there are any configuration changes.You can only update values that the spotinst REST API supports.absentTheabsentfunction ensures that a resource does not exist. If the resource exists, runningabsentdeletes it. If the resource doesn’t exist, runningabsenthas no effect.describeThedescribefunction returns a list of all resources of the specified type under the spotinst account ID from your credentials.yaml profile.Accessing StatesStates can be accessed by their relative location inidem-spotinst/idem_spotinst/states.For example, a spotinst launch specification state can be created with thepresentfunction 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:NoSchedulekey:taint1value:taint-value-1-tags:-tagKey:EnvtagValue:test-subnet_ids:-subnet-06747be60363933d9-subnet-03b6d0dfc57e1gbd6-security_group_ids:-sg-08dcdf4874a2f5g04-sg-0844f76b69f16b8b8-ocean_id:o-b78b1e79-labels:-key:tag1value:value1-key:tag2value:value2-instance_types:-t2.micro-image_id:ami-0c02fb55956c7d318The Idem command to create the preceding state is:idemstate$PWD/my_resource_launch_spec_state.slsYour SLS should follow the resource parameter structure shown in theSpotinst 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 theSpotinst REST API.Current Supported Resource Statesocean_awsk8s_clusterlaunch_spec