I have a cloud formation template which creates a spot instance. It has the following basic structure:
AWSTemplateFormatVersion: 2010-09-09
Resources:
launchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateData:
IamInstanceProfile:
Arn: <my-role>
InstanceType: t2.micro
ImageId: <my-ami-image>
NetworkInterfaces:
- AssociatePublicIpAddress: false
DeviceIndex: 0
SubnetId: <my-subnet-id>
Groups:
- <my-security-group>
KeyName: <my-key>
spotInstance:
DependsOn:
- launchTemplate
Properties:
LaunchTemplate:
LaunchTemplateId:
Ref: launchTemplate
Version: 1
Type: AWS::EC2::Instance
When I create the stack, it has no issue creating the spot request, and the spot instance gets created. However, when I delete the stack, it deletes the spot instance without canceling the spot request. As a result, a new spot instance gets created shortly.
I was wondering what might be the reasons that spot requests did not get canceled?