在 AWS Spot Fleet Request 中,可能会出现以下错误:“由于标记失败,无法启动实例”。这个问题通常是通过错误的标记键或缺少必要的标记键而导致的。在这种情况下,一种解决方法是通过使用 EC2 脚本(User Data)来向实例发送必要的标记。下面是一个示例脚本:
#!/bin/bash
# Replace this value with the instance ID for the EC2 instance
INSTANCE_ID=i-1234567890abcdef0
# Replace these values with the desired tag key-value pairs
TAG_KEY_1=MyTagKey
TAG_VALUE_1=MyTagValue
TAG_KEY_2=MyOtherTagKey
TAG_VALUE_2=MyOtherTagValue
aws ec2 create-tags --resources $INSTANCE_ID --tags Key=$TAG_KEY_1,Value=$TAG_VALUE_1 Key=$TAG_KEY_2,Value=$TAG_VALUE_2 --region us-west-2
将此脚本传递给 EC2 实例作为 User Data,然后启动实例。实例启动后,将应用所有必要的标记,允许 AWS Spot Fleet Request 正确地启动实例。