Bram Vandewalle
Bram Vandewalle

Reputation: 1654

SpotFleetRequest - Tag specification resource type must have a value

For the past few weeks I was able to create SpotFleetRequests just fine (via Java). However since yesterday I am getting the following error:

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)

I didn't really change anything and what's even weirder: I've already added a SpotFleetTagSpecification inside the SpotFleetLaunchSpecification of my SpotFleetRequestConfigData.

Here is my code:

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());

Changing or removing the tags doesn't work either, the error persists no matter what. Does anyone have a clue what I am doing wrong?

Upvotes: 2

Views: 2665

Answers (1)

Bram Vandewalle
Bram Vandewalle

Reputation: 1654

It seems like the documentation was a bit confusing. It mentions that ResourceType is not required, but I had to set it explicitly to instance to successfully create my SpotFleetRequest.

Upvotes: 9

Related Questions