Answers: <p>You should use <code>TimeoutDurationMinutes</code> in your code while requesting for spot instances via cloudformation.</p>
  
  <p>For more details: <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticmapreduce-instancefleetconfig-spotprovisioningspecification.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticmapreduce-instancefleetconfig-spotprovisioningspecification.html</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2019-07-15T06:54:42.843Z
Answers: I'm using it (that what I meant by "block duration") but if the request get accepted, everything works as expected. Otherwise the stack stay in "CREATE IN PROGRESS" state and I don't see the spot request in AWS.
Answers: Maxime C
Answers: CC BY-SA 4.0
Answers: 2019-08-28T23:48:16.553Z
Answers: This seems to be a common issue with cloudformation. However, please check step-7 in https://noise.getoto.net/tag/cloudformation/page/2/
  This should be helpful in fixing your issue.
Answers: Samit
Answers: CC BY-SA 4.0
Answers: 2019-07-12T16:51:59.010Z
Answers: 2019-07-12T16:51:59.010Z
Answers: Samit
Body: <p>I'm using AWS Cloudformation to create EC2 spot instance (with block duration). In order to do this in cloudformation I'm using a Launch Template where spot configuration is set. Then my cloudformation template create an EC2 resource which use the Launch Template.</p>
  
  <p>It work fine except when AWS refuse to create a spot instance. In that case, the cloudformation stack is still running.</p>
  
  <p>I'm wondering if there is a way to fail the stack when the spot request is refused ?</p>
  
  <p>Thanks</p>
  
Tags: <amazon-web-services><amazon-ec2><aws-cloudformation>
Title: How to fail stack when EC2 spot is refused?
UserDisplayName: Maxime C
ThreadText: # How to fail stack when EC2 spot is refused?
  
  (Asked by: username_0 on 2019-07-11)
  
  I'm using AWS Cloudformation to create EC2 spot instance (with block duration). In order to do this in cloudformation I'm using a Launch Template where spot configuration is set. Then my cloudformation template create an EC2 resource which use the Launch Template.
  
  It work fine except when AWS refuse to create a spot instance. In that case, the cloudformation stack is still running.
  
  I'm wondering if there is a way to fail the stack when the spot request is refused ?
  
  Thanks
  
  **Tags:** amazon-web-services, amazon-ec2, aws-cloudformation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-07-12. Score: 1
  
  You should use `TimeoutDurationMinutes` in your code while requesting for spot instances via cloudformation.
  
  For more details: <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticmapreduce-instancefleetconfig-spotprovisioningspecification.html>
  
  > **Comments:**
  > **username_0**: I'm using it (that what I meant by "block duration") but if the request get accepted, everything works as expected. Otherwise the stack stay in "CREATE IN PROGRESS" state and I don't see the spot request in AWS.  
  > **username_1**: This seems to be a common issue with cloudformation. However, please check step-7 in https://noise.getoto.net/tag/cloudformation/page/2/ This should be helpful in fixing your issue.  
  
  ---
  
  