---
title: Using Spot Instances with VMware Tanzu Application Service for VMs 6.0 (Small Footprint Edition) on AWS
tags: ["AWS", "Cloud Foundry", "Pivotal Cloud Foundry", "Ops Manager", "TAS", "Spot Instance"]
categories: ["Dev", "PaaS", "CloudFoundry", "PCF"]
date: 2024-07-01T07:26:31Z
updated: 2024-07-01T07:27:12Z
---

> ⚠️ This article was automatically translated by OpenAI (gpt-4o).
> It may be edited eventually, but please be aware that it may contain incorrect information at this time.

[Previous article](/entries/802) covered the installation of VMware Tanzu Application Service for VMs (TAS) on AWS.
In this article, we will introduce a method to significantly reduce EC2 instance usage costs by using Spot Instances.

**Table of Contents**
<!-- toc -->

### Creating a VM Extension

Whether to use Spot Instances for VMs in TAS can be configured with a [VM Extension](https://bosh.io/docs/aws-cpi/#resource-pools).

Define the use of spot instances in `vm-extension-spot-instance.yml`. The `spot_bid_price` is the maximum price (USD/hour) for the Spot Instance auction. Here, we set it to $1.0.
For VMs used in TAS, it is assumed that any price will win the auction since it won't reach $1.0.

```yaml
cat <<EOF > vm-extension-spot-instance.yml
---
vm-extension-config:
  name: spot-instance
  cloud_properties:
    spot_bid_price: 1.0
    spot_ondemand_fallback: true
---
EOF
```

Register the VM Extension with Ops Manager.

```
om --env env.yml create-vm-extension -c vm-extension-spot-instance.yml
```

Next, configure the application of this VM Extension to each VM in TAS in `additional-vm-extensions-cf.yml`.
Make sure to aggregate and configure all the VM Extensions you use.

```yaml
cat <<EOF > additional-vm-extensions-cf.yml
---
product-name: cf
resource-config:
  compute:
    additional_vm_extensions:
    - spot-instance
  control:
    additional_vm_extensions:
    - ssh-lb-security-groups
    - cloud-controller-iam
    - spot-instance
  database:
    additional_vm_extensions:
    - spot-instance
  router:
    additional_vm_extensions:
    - web-lb-security-groups
    - spot-instance
---
EOF
```

Apply this configuration to Ops Manager.

```
om --env env.yml configure-product -c additional-vm-extensions-cf.yml
```

### Apply Changes

Click "REVIEW PENDING CHANGES" from the Ops Manager dashboard.

Check the "SEE CHANGES" for both "BOSH Director" and "Small Footprint VMware Tanzu Application Service".

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/d1568871-e965-4a57-ad81-08be3d64163b">

If the Diff looks like the following, it's OK.

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/5ddc8569-bcbe-4717-a635-cfd329b3840d">

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/683009dc-5845-4efd-b5bb-18bb198dd902">

After confirming, return to the original page and click the "APPLY CHANGES" button.

Once the settings are applied, check that the "Instance Lifecycle" of the TAS VM is `spot` from the list of EC2 instances.

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/6564682a-5d58-4fb3-93b4-e2cdd85d8736">

You can also check the four requests from the list of spot requests.

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/a3fcef59-614a-4d5b-acb0-86a6daeb4635">

As of July 1, 2024, the prices are as follows:

| VM Type      | On-Demand Price | Spot Price |
|--------------|-----------------|------------|
| r5a.large    | $0.1370         | $0.0484    |
| t3a.micro    | $0.0122         | $0.0042    |
| t3a.medium   | $0.0490         | $0.0170    |

This results in approximately 65% cost savings.

If a Spot Instance VM is deleted, BOSH Director will rejoin the auction and automatically create a new VM at the new price.
