A tool to convert AWS EC2 instances back and forth between On-Demand and Spot billing models.

Overview

ec2-spot-converter

This tool converts existing AWS EC2 instances back and forth between On-Demand and 'persistent' Spot billing models while preserving instance attributes (Launch configuration, Tags..), network attributes (existing Private IP addresses, Elastic IP), storage (Volumes), Elastic Inference accelerators, Elastic GPUs.

Others features:

  • Can also perform Spot-to-Spot and OnDemand-to-OnDemand conversions:
    • Allow replacement of existing Spot instances with new "identical" ones to update the instance type and CPU options,
    • Help to fix some Spot instance conditions (Ex: 'IncorrectSpotRequestState Exception'),
    • Allow Root Disk encryption during conversion.
  • Can preserve ELB Target Group instance registrations (disabled by default),
  • Can update existing CloudWatch alarms referring the converted Instance Id (disabled by default),

Conversion time ranges from 2 to 5 minutes depending on the instance type.

IMPORTANT REMARK: This tool aims to ease handling of 'Pet' machines when you have to do so (very frequent after a pure Lift&Shift migration into the Cloud). The author strongly advises to always consider managing resources as 'Cattle' (with IaC, AutoScaling Groups, Stateless...). As a consequence, this tool should be only useful transient while transitionning to Cloud Native best-practices.

Getting started

Prerequisistes:

  • Install the tool on an EC2 Linux instance located in the same account and region than the instance to convert,
TOOL_VERSION=`curl https://raw.githubusercontent.com/jcjorel/ec2-spot-converter/master/VERSION.txt`
curl https://raw.githubusercontent.com/jcjorel/ec2-spot-converter/master/releases/ec2-spot-converter-${TOOL_VERSION} -o ec2-spot-converter
chmod u+x ec2-spot-converter
  • Attach to the EC2 tool instance an IAM role with provided policy.json file,
  • Install Python3 and boto3 package (with python3 -m pip install boto3).

Convert an On-Demand instance to Spot model

# Initialize the DynamoDB table that will hold conversion states. **DO IT ONLY ONCE PER REGION AND ACCOUNT**.
$ ./ec2-spot-converter --generate-dynamodb-table
Creating DynamoDB table 'ec2-spot-converter-state-table'...

# Convert running On-Demand instance i-0dadf8589b7ec16f6 to Spot model
#   This instance has 3 attached volumes (w/ one multi-attached 'io1' type), 2 ENIs and 1 EIP.
$ ./ec2-spot-converter --stop-instance --review-conversion-result --instance-id i-0dadf8589b7ec16f6
[STEP 1/21] Read DynamoDB state table...
  => SUCCESS. Record 'i-0dadf8589b7ec16f6' doesn't exist yet.
[STEP 2/21] Discover instance state...
  => SUCCESS. Stopping i-0dadf8589b7ec16f6...
[STEP 3/21] Wait for 'stopped' instance state...
Waiting for instance to stop... (current state=stopping)
Waiting for instance to stop... (current state=stopping)
Waiting for instance to stop... (current state=stopping)
  => SUCCESS. Instance in 'stopped' state.
[STEP 4/21] Tag all resources (Instance, ENI(s), Volumes) with ec2-spot-converter job Id...
  => SUCCESS. Successfully tagged ['i-0dadf8589b7ec16f6', 'eni-092172a81811424d5', 'eni-0f33bc507e00eff48', 'vol-05e7ca553ae156cc3', 'vol-081fc97c000b836b2', 'vol-08792eacd354100cb'].
[STEP 5/21] Get storage volume details...
  => SUCCESS. Successfully retrieved volume details for ['vol-05e7ca553ae156cc3', 'vol-081fc97c000b836b2', 'vol-08792eacd354100cb'].
[STEP 6/21] Detach instance volumes with DeleteOnTermination=False...
Detaching volume vol-081fc97c000b836b2...
Detaching volume vol-08792eacd354100cb...
  => SUCCESS. Detached volumes ['vol-081fc97c000b836b2', 'vol-08792eacd354100cb'].
[STEP 7/21] Wait for volume detach status...
Detected multi-attached volume 'vol-08792eacd354100cb'. Taking care of this special case...
Detected multi-attached volume 'vol-08792eacd354100cb'. Taking care of this special case...
  => SUCCESS. All detached volumes are 'available' : ['vol-081fc97c000b836b2', 'vol-08792eacd354100cb'].
[STEP 8/21] Start AMI creation...
AMI Block device mapping: [{'DeviceName': '/dev/xvda', 'Ebs': {'DeleteOnTermination': True, 'VolumeSize': 8, 'VolumeType': 'gp2'}}]
  => SUCCESS. AMI image ec2-spot-converter-i-0dadf8589b7ec16f6/ami-0f1908293d6fba760 started.
[STEP 9/21] Prepare network interfaces for instance disconnection...
  => SUCCESS. Successfully prepared network interfaces ['eni-092172a81811424d5', 'eni-0f33bc507e00eff48'].
[STEP 10/21] Wait for AMI to be ready...
Waiting for image ami-0f1908293d6fba760 to be available...
Waiting for image ami-0f1908293d6fba760 to be available...
  => SUCCESS. AMI ami-0f1908293d6fba760 is ready.
[STEP 11/21] Checkpoint the current exact state of the instance...
  => SUCCESS. Checkpointed instance state.
[STEP 12/21] Terminate instance...
  => SUCCESS. Successfully terminated instance i-0dadf8589b7ec16f6.
[STEP 13/21] Wait resource release...
  => SUCCESS. All resources released : ['eni-092172a81811424d5', 'eni-0f33bc507e00eff48'].
[STEP 14/21] Create new instance...
  => SUCCESS. Created new instance 'i-06236de813ed5bacd'.
[STEP 15/21] Wait new instance to come up...
  => SUCCESS. Instance i-06236de813ed5bacd is in 'running' state.
[STEP 16/21] Reattach volumes...
Attaching volume vol-081fc97c000b836b2 to i-06236de813ed5bacd with device name /dev/sdb...
Attaching volume vol-08792eacd354100cb to i-06236de813ed5bacd with device name /dev/sdf...
  /!\ WARNING /!\ Volumes attached after boot. YOUR NEW INSTANCE MAY NEED A REBOOT!
  => SUCCESS. Successfully reattached volumes ['vol-081fc97c000b836b2', 'vol-08792eacd354100cb']...
[STEP 17/21] Configure network interfaces...
Setting 'DeleteOnTermination=True' for interface eni-092172a81811424d5...
Setting 'DeleteOnTermination=True' for interface eni-0f33bc507e00eff48...
  => SUCCESS. Successfully configured network interfaces ['eni-092172a81811424d5', 'eni-0f33bc507e00eff48'].
[STEP 18/21] Manage Elastic IP...
  => SUCCESS. Reassociated EIPs '['34.247.111.29']'.
[STEP 19/21] Reboot new instance (if needed and requested)...
  => SUCCESS. It is recommend to reboot 'i-06236de813ed5bacd'... Please specify --reboot-if-needed option next time.
[STEP 20/21] Untag resources...
  => SUCCESS. Successfully untagged ['i-06236de813ed5bacd', 'eni-092172a81811424d5', 'eni-0f33bc507e00eff48', 'vol-081fc97c000b836b2', 'vol-08792eacd354100cb'].
[STEP 21/21] Deregister image... => SKIPPED! Need '--delete-ami' argument.
Conversion successful! New instance id: i-06236de813ed5bacd, ElapsedTime: 112 seconds

/!\ WARNING /!\ Volumes attached after boot. YOUR NEW INSTANCE MAY NEED A REBOOT!

If the option --review-conversion-result is specified, at conversion end, a VIm Diff window pops-up and allow interactive review of the differences between the original now terminated instance and the newly created one: You should see differences only related to dates, Association Ids, AMI Id (and all volume Ids with 'DeleteOnTermination=True' and the Root volume).

Result review window

Convert a Spot instance to On-Demand model

The operation is similar to the Spot model conversion with the difference that the option --target-billing-model must be set to on-demand explicitly.

Note: ec2-spot-converter can also convert back an instance currently in Spot interrupted state to On-Demand model.

Convert a Spot instance to Spot model to change the instance type and/or CPU Options

ec2-spot-converter tool can be used to replace a Spot instance by another one just changing the instance type. This operation is not yet possible "in-place" through an AWS EC2 API so the tool will terminate and replace the Spot instance preserving all attributes but updating the instance type (or CPU options) during the process.

Specify options --target-instance-type and/or --cpu-optionson an existing Spot instance to start conversion.

Fix Spot instance with 'IncorrectSpotRequestState Exception'

The tool is able to fix 'IncorrectSpotRequestState Exceptions' due to the Spot request been cancelled by the user but the Spot instance was left running. This kind of instance may suffer some unexpected behaviors like no possibility to stop them anymore.

The tool can be used to recreate a new healthy Spot instance from the problematic Spot instance.

Simply call ec2-spot-converter with the problematic Instance Id and specify options --target-billing-model 'spot' and --do-not-require-stopped-instance (as the instance can not be stopped).

It is recommended to perform a System stop (so NOT a System reboot) on the guest Operating System to switch Read-Only all volumes and ensure Filesystem data consistency. On a Linux guest, usually, the Linux command halt will stop the Operating System safely and won't reboot immediatly: Please ensure that the message "reboot: System halted." is displayed on the guest console thanks to AWS Console screenshot feature.

Encrypt Root Disk during conversion

The tool can be used to encrypt the Root Disk (and more generally, all volumes marked with attribute DeleteOnTermination=True that will be part of the Backup AMI).

Simply specify option --volume-kms-key-id with a valid KMS Key Id and all volumes part of the Backup AMI will be encrypted in the new instance. If a volume is already encrypted, it will be left as-is just generating a warning.

Ex:

--volume-kms-key-id arn:aws:kms:eu-west-1:111111111111:key/22222222-3333-4444-5555-666666666666

If you want to convert Spot-to-Spot or OnDemand-to-OnDemand, specify --force option as well.

Preserve ELB target group registrations

The tool can preserve the target group registrations of the converted instance. As the conversion is based on the termination of the specified instance Id, all references in target groups of this instance Id must be updated with the new instance Id created during the conversion.

The feature is enabled by setting option --check-targetgroups with either a list of target group ARNs to inspect or the wildcard character '*' which means all target groups in the account and region. As an AWS account can contain up to 3000 target groups and induce long processing times, the feature is disabled by default.

Optionally, the tool can wait, at end of conversion, for the newly created instance to reach one of specified health states in all participating target groups. Specify --wait-for-tg-states setting without argument to wait for the ["unused", "healthy"] states or provide a list of expected target group states (ex: specify both unhealthy and healthy to exit from the tool after the initial phase even in case of failure to pass health checks).

Update CloudWatch Alarms referring the converted Instance Id

After a conversion, by default, all existing CloudWatch alarms, that refer to the original converted instance Id, become stale because pointing on a metric associated to a terminated instance Id.

This behavior can be changed by requesting the tool to update these CloudWatch alarms with the new Instance Id value.

Specify --update-cw-alarms optionally with arguments:

  • When no argument is specified (or '*'), all existing CloudWatch alarms in the current account will be searched for instance id reference,
  • When arguments are specified, they are used as CloudWatch alarm prefixes to filterin only a subset of existing alarms (=faster processing). Ex: --update-cw-alarms Frontend Backend will filterin all CloudWatch alarm names that start with either Frontend or Backendstrings.

Only alarms referring to a metric with a dimension named InstanceId and the value of the converted Instance Id will be updated.

As an AWS account can contain thousands of CloudWatch alarms, this feature is disabled by default.

Command line usage

usage: ec2-spot-converter [-h] -i INSTANCE_ID [-m {spot,on-demand}]
                          [-t TARGET_INSTANCE_TYPE] [--ignore-userdata]
                          [--ignore-hibernation-options]
                          [--cpu-options CPU_OPTIONS]
                          [--max-spot-price MAX_SPOT_PRICE]
                          [--volume-kms-key-id VOLUME_KMS_KEY_ID] [-s]
                          [--reboot-if-needed]
                          [--update-cw-alarms [UPDATE_CW_ALARMS [UPDATE_CW_ALARMS ...]]]
                          [--delete-ami]
                          [--check-targetgroups CHECK_TARGETGROUPS [CHECK_TARGETGROUPS ...]]
                          [--wait-for-tg-states [{unused,unhealthy,healthy,initial,draining} [{unused,unhealthy,healthy,initial,draining} ...]]]
                          [--do-not-require-stopped-instance] [-r]
                          [--dynamodb-tablename DYNAMODB_TABLENAME]
                          [--generate-dynamodb-table] [-f]
                          [--do-not-pause-on-major-warnings]
                          [--reset-step RESET_STEP] [-d] [-v]

EC2 Spot converter

optional arguments:
  -h, --help            show this help message and exit
  -i INSTANCE_ID, --instance-id INSTANCE_ID
                        The id of the EC2 instance to convert.
  -m {spot,on-demand}, --target-billing-model {spot,on-demand}
                        The expected billing model after conversion. Default:
                        'spot'
  -t TARGET_INSTANCE_TYPE, --target-instance-type TARGET_INSTANCE_TYPE
                        The expected instance type (ex: m5.large...) after
                        conversion. This flag is only useful when applied to a
                        Spot instance as EC2.modify_instance_attribute() can't
                        be used to change Instance type. Default:
                        
  --ignore-userdata     Do not copy 'UserData' on converted instance.
  --ignore-hibernation-options
                        Do not copy 'HibernationOptions' on converted
                        instance.
  --cpu-options CPU_OPTIONS
                        Instance CPU Options JSON structure. Format:
                        {"CoreCount":123,"ThreadsPerCore":123}. Note: The
                        special 'ignore' value will force to not define the
                        CPUOptions structure in the new EC2 Launch
                        specification.
  --max-spot-price MAX_SPOT_PRICE
                        Maximum hourly price for Spot instance target.
                        Default: On-Demand price.
  --volume-kms-key-id VOLUME_KMS_KEY_ID
                        Identifier (key ID, key alias, ID ARN, or alias ARN)
                        for a Customer or AWS managed KMS Key used to encrypt
                        the EBS volume(s). Note: You cannot specify 'aws/ebs'
                        directly, please specify the plain KMS Key ARN
                        instead. It applies ONLY to volumes placed in the
                        Backup AMI *AND* not already encrypted.
  -s, --stop-instance   Stop instance instead of failing because it is in
                        'running' state.
  --reboot-if-needed    Reboot the new instance if needed.
  --update-cw-alarms [UPDATE_CW_ALARMS [UPDATE_CW_ALARMS ...]]
                        Update CloudWatch alarms with reference to the
                        converted Instance Id. Optionnaly, a CloudWatch alarm
                        name prefix list can be supplied to narrow instance id
                        lookup to a subset of matching alarm names. Without
                        args, all CloudWatch alarms in the current account
                        will be searched.
  --delete-ami          Delete AMI at end of conversion.
  --check-targetgroups CHECK_TARGETGROUPS [CHECK_TARGETGROUPS ...]
                        List of target group ARNs to look for converted
                        instance registrations. Wildcard '*' means all ELB
                        target groups in the current account and region
                        (WARNING: An account can contain up to 3000 target
                        groups and induce long processing time). Default: None
                        (means no target group registration preservation by
                        default)
  --wait-for-tg-states [{unused,unhealthy,healthy,initial,draining} [{unused,unhealthy,healthy,initial,draining} ...]]
                        Wait for target group registrations to reach specified
                        state(s) at end of conversion. Default: ['unused',
                        'healthy']
  --do-not-require-stopped-instance
                        Allow instance conversion while instance is in
                        'running' state. (NOT RECOMMENDED)
  -r, --review-conversion-result
                        Display side-by-side conversion result. Note: REQUIRES
                        'VIM' EDITOR!
  --dynamodb-tablename DYNAMODB_TABLENAME
                        A DynamoDB table name to hold conversion states.
                        Default: 'ec2-spot-converter-state-table'
  --generate-dynamodb-table
                        Create a DynamoDB table to hold conversion states.
  -f, --force           Force to start a conversion even if the tool suggests
                        that it is not needed.
  --do-not-pause-on-major-warnings
                        Do not pause on major warnings. Without this flag, the
                        tool waits 10 seconds to let user read major warnings.
  --reset-step RESET_STEP
                        (DANGEROUS) Force the state machine to go back to the
                        specified processing step.
  -d, --debug           Turn on debug traces.
  -v, --version         Display tool version.

At the end of a conversion, the tool can replay as many times as wished former conversion results specifying the original instance id: It will display again all execution steps and it can be useful to review again the conversion result (VIm Diff window) of a previous run. The --delete-ami option can also be added in a subsequent call to suppress the AMI and associated snapshots built by a previous tool execution.

Resilience

The tool is designed with maximum safety of stateful data and operations in mind: All conversion states are persisted in a DynamoDB table and, if the tool is interrupted or encounters an error, it should be restartable where it went interrupted without special user action. In the unexpected (and unlikely) event of a major bug and bad outcome, please consult the DynamoDB line corresponding to your instance Id: This line contains JSON states of your original instance and other information (AMI, Interfaces...) allowing to reconstruct the original instance by hand. In such event, please also create a GitHub issue with a precise description of the encountered problem and so help improving the tool!

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Contributor credits (Thank you!):

  • @regevbr: Contributed ELB target group registration preservation.

Licensing

The code in this project is licensed under MIT license.

Comments
  • ec2 target group registration is lost after transition

    ec2 target group registration is lost after transition

    I have load balancer target groups that have 2c2 instances registered as their targets. After the transition to spot, those registrations are lost. Suggested fix: save the registration information of the instances and reattach them after the new instance is up

    opened by regevbr 15
  • Usage as a Lambda Function?

    Usage as a Lambda Function?

    As title says, do you see any roadblocks to adopting this code for a lambda function? I'm worried about potential timeouts and refactoring the code to be able to be called from a lambda event.

    What are your thoughts?

    opened by rirze 9
  • Unable to stop instance

    Unable to stop instance

    When I run the final command to convert an on demand instance to spot instance, the process is not going beyond step 6.

    [INFO] 2021-07-03 01:05:59,943 ec2-spot-converter - [STEP 1/26] Read DynamoDB state table...
    [INFO] 2021-07-03 01:05:59,980 ec2-spot-converter -   => SUCCESS. Record 'i-00df331228ea82943' read succesfully.
    [INFO] 2021-07-03 01:06:00,104 ec2-spot-converter - [STEP 2/26] Discover instance state... : RECOVERED STATE. SKIPPED!
    [INFO] 2021-07-03 01:06:00,104 ec2-spot-converter -   => SUCCESS. Instance is in state running...
    [INFO] 2021-07-03 01:06:00,105 ec2-spot-converter - [STEP 3/26] Deregister from ELB target groups... => SKIPPED! Need '--check-targetgroups' argument.
    [INFO] 2021-07-03 01:06:00,105 ec2-spot-converter - [STEP 4/26] Wait for drainage of ELB target groups... => SKIPPED! Need '--check-targetgroups' argument.
    [INFO] 2021-07-03 01:06:00,105 ec2-spot-converter - [STEP 5/26] Stop the instance... : RECOVERED STATE. SKIPPED!
    [INFO] 2021-07-03 01:06:00,105 ec2-spot-converter -   => SUCCESS. Stopping 'i-00df331228ea82943'...
    [INFO] 2021-07-03 01:06:00,105 ec2-spot-converter - [STEP 6/26] Wait for expected instance state...
    [INFO] 2021-07-03 01:06:00,168 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:06:15,220 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:06:30,276 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:06:45,325 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:07:00,374 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:07:15,438 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:07:30,480 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:07:45,536 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:08:00,587 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:08:15,645 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:08:30,698 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:08:45,756 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:09:00,838 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:09:15,886 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:09:30,951 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    [INFO] 2021-07-03 01:09:46,010 ec2-spot-converter - Waiting for instance to stop... (current state=running)
    

    However, the first time I ran this, the instance stopped at step 6, but no more steps were executed (I waited for more than 10 minutes). Now when I am trying it (tried it multiple times), it's getting stuck at step 6 as above.

    Any idea why this might be happening? I am new to this, so bear with me if my question sounds noob.

    opened by shalabhsingh 8
  • Failure while creating instance

    Failure while creating instance

    At step 16/25 the script fails with perhaps some permission issue. I used the policy.json attached in repo

    [INFO] 2021-02-09 18:25:45,871 ec2-spot-converter - [STEP 14/25] Terminate instance...
    [INFO] 2021-02-09 18:25:45,978 ec2-spot-converter -   => SUCCESS. Successfully terminated instance i-0g6j3gaeda57a3d.
    [INFO] 2021-02-09 18:25:45,998 ec2-spot-converter - [STEP 15/25] Wait resource release...
    [INFO] 2021-02-09 18:25:46,089 ec2-spot-converter - Waiting for detached ENIs to become 'available'...
    [INFO] 2021-02-09 18:25:53,259 ec2-spot-converter -   => SUCCESS. All resources released : ['eni-018kf47ke05c84'].
    [INFO] 2021-02-09 18:25:53,277 ec2-spot-converter - [STEP 16/25] Create new instance...
    Traceback (most recent call last):
      File "./ec2-spot-converter", line 1471, in <module>
        sys.exit(main(sys.argv))
      File "./ec2-spot-converter", line 1437, in main
        return_code, reason, keys = step["Function"]()
      File "./ec2-spot-converter", line 939, in create_new_instance
        response = ec2_client.run_instances(**launch_specifications)
      File "/usr/local/lib/python3.6/dist-packages/botocore/client.py", line 357, in _api_call
        return self._make_api_call(operation_name, kwargs)
      File "/usr/local/lib/python3.6/dist-packages/botocore/client.py", line 676, in _make_api_call
        raise error_class(parsed_response, operation_name)
    botocore.exceptions.ClientError: An error occurred (UnauthorizedOperation) when calling the RunInstances operation: You are not authorized to perform this operation.
    

    The script gave an encoded message. I'll try to figure out decoding it

    opened by IvanNoronha-TomTom 7
  • region not specified error

    region not specified error

    When trying to run the tool, I get an exception:

    > ./ec2-spot-converter --generate-dynamodb-table
    Traceback (most recent call last):
      File "./ec2-spot-converter", line 58, in <module>
        ec2_client               = boto3.client("ec2",               config=config)
      File "/usr/lib/python3.6/site-packages/boto3/__init__.py", line 93, in client
        return _get_default_session().client(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/boto3/session.py", line 263, in client
        aws_session_token=aws_session_token, config=config)
      File "/usr/lib/python3.6/site-packages/botocore/session.py", line 838, in create_client
        client_config=config, api_version=api_version)
      File "/usr/lib/python3.6/site-packages/botocore/client.py", line 87, in create_client
        verify, credentials, scoped_config, client_config, endpoint_bridge)
      File "/usr/lib/python3.6/site-packages/botocore/client.py", line 328, in _get_client_args
        verify, credentials, scoped_config, client_config, endpoint_bridge)
      File "/usr/lib/python3.6/site-packages/botocore/args.py", line 73, in get_client_args
        endpoint_url, is_secure, scoped_config)
      File "/usr/lib/python3.6/site-packages/botocore/args.py", line 154, in compute_client_args
        s3_config=s3_config,
      File "/usr/lib/python3.6/site-packages/botocore/args.py", line 220, in _compute_endpoint_config
        return self._resolve_endpoint(**resolve_endpoint_kwargs)
      File "/usr/lib/python3.6/site-packages/botocore/args.py", line 303, in _resolve_endpoint
        service_name, region_name, endpoint_url, is_secure)
      File "/usr/lib/python3.6/site-packages/botocore/client.py", line 402, in resolve
        service_name, region_name)
      File "/usr/lib/python3.6/site-packages/botocore/regions.py", line 134, in construct_endpoint
        partition, service_name, region_name)
      File "/usr/lib/python3.6/site-packages/botocore/regions.py", line 148, in _endpoint_for_partition
        raise NoRegionError()
    botocore.exceptions.NoRegionError: You must specify a region.
    

    Need to add to readme an explanation on how to configure it (you can see the options here)

    opened by regevbr 7
  • Invalid option error for r6g.medium spot conversion

    Invalid option error for r6g.medium spot conversion

    @jcjorel Perhaps it is due to the new instance type but when I tried converting an r6g.medium from on demand to spot it gave me this error

    [INFO] 2021-08-29 08:01:06,276 ec2-spot-converter - [STEP 14/26] Terminate instance...
    [INFO] 2021-08-29 08:01:06,424 ec2-spot-converter -   => SUCCESS. Successfully terminated instance i-08da23413cc50235a.
    [INFO] 2021-08-29 08:01:06,442 ec2-spot-converter - [STEP 15/26] Wait resource release...
    [INFO] 2021-08-29 08:01:06,635 ec2-spot-converter - Waiting for instance 'terminated' state...
    [INFO] 2021-08-29 08:01:11,686 ec2-spot-converter - Waiting for instance 'terminated' state...
    [INFO] 2021-08-29 08:01:18,748 ec2-spot-converter -   => SUCCESS. All resources released : ['eni-0315f33b44b37eade'].
    [INFO] 2021-08-29 08:01:18,766 ec2-spot-converter - [STEP 16/26] Create new instance...
    Traceback (most recent call last):
      File "./ec2-spot-converter", line 1570, in <module>
        sys.exit(main(sys.argv))
      File "./ec2-spot-converter", line 1536, in main
        return_code, reason, keys = step["Function"]()
      File "./ec2-spot-converter", line 953, in create_new_instance
        response = ec2_client.run_instances(**launch_specifications)
      File "/usr/local/lib/python3.6/dist-packages/botocore/client.py", line 357, in _api_call
        return self._make_api_call(operation_name, kwargs)
      File "/usr/local/lib/python3.6/dist-packages/botocore/client.py", line 676, in _make_api_call
        raise error_class(parsed_response, operation_name)
    botocore.exceptions.ClientError: An error occurred (UnsupportedOperation) when calling the RunInstances operation: The r6g.medium instance type does not support specifying CpuOptions.
    
    

    Since the original instance is terminated is there a quick way to roll back? Or I will need to re-create the machine from backed up AMI

    opened by IvanNoronha-TomTom 6
  • Tag Keys starting with aws: error with reserved word

    Tag Keys starting with aws: error with reserved word

    When instances are created with CloudFormation or Service Catalog, the services will create their own tags on instances. These tags all start with "aws:". When trying to convert, the error comes up that these are reserved tags.....

    The tag keys maybe just renamed to something like changing "aws:cloudformation" to "AWScloudformation".

    botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the RunInstances operation: Tag keys starting with 'aws:' are reserved for internal use

    opened by kruule69 5
  • ELB target group retrieval issue

    ELB target group retrieval issue

    I'm using the the script for an on-demand to spot conversion with the invocation

    ./ec2-spot-converter --stop-instance --review-conversion-result --instance-id <id> --update-cw-alarms --check-targetgroups * --wait-for-tg-states
    

    Output:

    [INFO] 2021-02-28 06:07:19,059 ec2-spot-converter - [STEP 1/26] Read DynamoDB state table...
    [INFO] 2021-02-28 06:07:19,116 ec2-spot-converter -   => SUCCESS. Record '<id>' read succesfully.
    [INFO] 2021-02-28 06:07:19,142 ec2-spot-converter - [STEP 2/26] Discover instance state...
    [ERROR] 2021-02-28 06:07:19,631 ec2-spot-converter - Failed to list target groups: An error occurred (ValidationError) when calling the DescribeTargetGroups operation: 'ec2-spot-converter' is not a valid target group ARN.
    [ERROR] 2021-02-28 06:07:19,631 ec2-spot-converter - Failed to perform step 'DiscoverInstanceState'! Reason=Failed to retrieve ELB target groups!
    
    

    I've used the latest policy.json attached as an IAM role. Not sure if it needs the * to be in quotes?

    Update: The load balancer in use is an application load balancer

    opened by IvanNoronha-TomTom 3
  • A Way to change VPC/Network/Zone

    A Way to change VPC/Network/Zone

    Just a Suggestion, options to change vpc / network-id . We faced a problem where was not availability of a instance type in the current zone and we had to change network id changing zone

    opened by bittix 2
  • Copying tags for volumes when DeleteOnTermination is false

    Copying tags for volumes when DeleteOnTermination is false

    While using the script for an on-demand to spot conversion I noticed the tags on original volume doesn't get copied to the new volume created. In my case the DeleteOnTermination was originally false so there was an extra diff for volume, image

    Impact: I generally keep a backup schedule based on tags. Since the new volume won't have tag there's a requirement to manually add it, else the backup schedule will use the old volume. image

    No biggie. But wanted to know your view

    opened by IvanNoronha-TomTom 2
Owner
jcjorel
jcjorel
A job launching library for docker, EC2, GCP, etc.

doodad A library for packaging dependencies and launching scripts (with a focus on python) on different platforms using Docker. Currently supported pl

Justin Fu 55 Aug 27, 2022
Let's learn how to build, release and operate your containerized applications to Amazon ECS and AWS Fargate using AWS Copilot.

?? Welcome to AWS Copilot Workshop In this workshop, you'll learn how to build, release and operate your containerised applications to Amazon ECS and

Donnie Prakoso 15 Jul 14, 2022
Ralph is the CMDB / Asset Management system for data center and back office hardware.

Ralph Ralph is full-featured Asset Management, DCIM and CMDB system for data centers and back offices. Features: keep track of assets purchases and th

Allegro Tech 1.9k Jan 1, 2023
A honey token manager and alert system for AWS.

SpaceSiren SpaceSiren is a honey token manager and alert system for AWS. With this fully serverless application, you can create and manage honey token

null 287 Nov 9, 2022
Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Arie Bregman 35.1k Jan 2, 2023
Prometheus exporter for AWS Simple Queue Service (SQS)

Prometheus SQS Exporter Prometheus exporter for AWS Simple Queue Service (SQS) Metrics Metric Description ApproximateNumberOfMessages Returns the appr

Gabriel M. Dutra 0 Jan 31, 2022
Cado Response Integration with Amazon GuardDuty using AWS Lambda

Cado Response Integration with Amazon GuardDuty using AWS Lambda This repository contains a simple example where: An alert is triggered by GuardDuty T

Cado Security 4 Mar 2, 2022
CDK Template of Table Definition AWS Lambda for RDB

CDK Template of Table Definition AWS Lambda for RDB Overview This sample deploys Amazon Aurora of PostgreSQL or MySQL with AWS Lambda that can define

AWS Samples 5 May 16, 2022
Inferoxy is a service for quick deploying and using dockerized Computer Vision models.

Inferoxy is a service for quick deploying and using dockerized Computer Vision models. It's a core of EORA's Computer Vision platform Vision Hub that runs on top of AWS EKS.

null 94 Oct 10, 2022
a CLI that provides a generic automation layer for assessing the security of ML models

Counterfit About | Getting Started | Learn More | Acknowledgments | Contributing | Trademarks | Contact Us -------------------------------------------

Microsoft Azure 575 Jan 2, 2023
Ganeti is a virtual machine cluster management tool built on top of existing virtualization technologies such as Xen or KVM and other open source software.

Ganeti 3.0 =========== For installation instructions, read the INSTALL and the doc/install.rst files. For a brief introduction, read the ganeti(7) m

null 395 Jan 4, 2023
IP address management (IPAM) and data center infrastructure management (DCIM) tool.

NetBox is an IP address management (IPAM) and data center infrastructure management (DCIM) tool. Initially conceived by the network engineering team a

NetBox Community 11.8k Jan 7, 2023
Oncall is a calendar tool designed for scheduling and managing on-call shifts. It can be used as source of dynamic ownership info for paging systems like http://iris.claims.

Oncall See admin docs for information on how to run and manage Oncall. Development setup Prerequisites Debian/Ubuntu - sudo apt-get install libsasl2-d

LinkedIn 928 Dec 22, 2022
MagTape is a Policy-as-Code tool for Kubernetes that allows for evaluating Kubernetes resources against a set of defined policies to inform and enforce best practice configurations.

MagTape is a Policy-as-Code tool for Kubernetes that allows for evaluating Kubernetes resources against a set of defined policies to inform and enforce best practice configurations. MagTape includes variable policy enforcement, notifications, and targeted metrics.

T-Mobile 143 Dec 27, 2022
This is a tool to develop, build and test PHP extensions in Docker containers.

Develop, Build and Test PHP Extensions This is a tool to develop, build and test PHP extensions in Docker containers. Installation Clone this reposito

Suora GmbH 10 Oct 22, 2022
More than 130 check plugins for Icinga and other Nagios-compatible monitoring applications. Each plugin is a standalone command line tool (written in Python) that provides a specific type of check.

Python-based Monitoring Check Plugins Collection This Enterprise Class Check Plugin Collection offers a package of more than 130 Python-based, Nagios-

Linuxfabrik 119 Dec 27, 2022
A Blazing fast Security Auditing tool for Kubernetes

A Blazing fast Security Auditing tool for kubernetes!! Basic Overview Kubestriker performs numerous in depth checks on kubernetes infra to identify th

Vasant Chinnipilli 934 Jan 4, 2023
A cron monitoring tool written in Python & Django

Healthchecks Healthchecks is a cron job monitoring service. It listens for HTTP requests and email messages ("pings") from your cron jobs and schedule

Healthchecks 5.8k Jan 2, 2023
A declarative Kubeflow Management Tool inspired by Terraform

?? KRSH is Alpha version, so many bugs can be reported. If you find a bug, please write an Issue and grow the project together! A declarative Kubeflow

Riiid! 128 Oct 18, 2022