在过去的几周里,我能够很好地创建SpotFleetRequests(通过Java)。但是从昨天起我收到以下错误:
com.amazonaws.services.ec2.model.AmazonEC2Exception: Tag specification resource type must have a value (Service: AmazonEC2; Status Code: 400; Error Code: InvalidSpotFleetRequestConfig; Request ID: ef69f477-e8f3-4d86-aa91-1646c4067d68)
我没有真正改变任何事情甚至更奇怪:我已经在我的 SpotFleetLaunchSpecification 中添加了 SpotFleetTagSpecification EM> SpotFleetRequestConfigData
这是我的代码:
List<Tag> tags = new ArrayList<>();
tags.add(new Tag("TEAM", "CROCODILE"));
SpotFleetTagSpecification tagSpec = new SpotFleetTagSpecification().withTags(tags);
SpotFleetLaunchSpecification launchSpec = new SpotFleetLaunchSpecification()
.withSecurityGroups(new GroupIdentifier().withGroupId(securityGroupId))
.withIamInstanceProfile(new IamInstanceProfileSpecification().withArn(instanceProfileArn))
.withImageId(imageId)
.withInstanceType(InstanceType.M3Xlarge)
.withSubnetId(subnetIds)
.withUserData(getUserDataToConfigureECSCluster(ecsClusterName))
.withTagSpecifications(tagSpec);
// Configure the actual request
SpotFleetRequestConfigData config = new SpotFleetRequestConfigData()
.withIamFleetRole(fleetRoleArn)
.withLaunchSpecifications(launchSpec)
.withAllocationStrategy(AllocationStrategy.LowestPrice)
.withTargetCapacity(targetCapacity)
.withType(FleetType.Maintain)
.withClientToken(spotFleetToken);
RequestSpotFleetRequest request = new RequestSpotFleetRequest()
.withSpotFleetRequestConfig(config);
RequestSpotFleetResult result = ec2.requestSpotFleet(request);
LOG.info("Created spot fleet request with ID {}", result.getSpotFleetRequestId());
更改或删除标签也不起作用,无论如何,错误仍然存在。有没有人知道我做错了什么?
答案 0 :(得分:1)
似乎文档有点令人困惑。它提到 ResourceType 不是必需的,但我必须将其明确设置为 instance 才能成功创建我的SpotFleetRequest。