Open trent-abc opened 1 year ago
Voting for Prioritization
Volunteering to Work on This Issue
same issue but with aws_ec2_fleet
resource with Terraform AWS Provider v5.5.0
Same issue with aws version = ">=5.41.0"
hi @trent-abc
Below snippet worked for me, with aws provider version 5.62.0:
resource "aws_spot_fleet_request" "spot_fleet_test" {
iam_fleet_role = "<ROLE_ARN>"
allocation_strategy = var.allocation_strategy #i used capacityOptimized
target_capacity = 1
terminate_instances_with_expiration = true
wait_for_fulfillment = true
fleet_type = "request"
target_capacity_unit_type = "units"
launch_template_config {
launch_template_specification {
id = aws_launch_template.test_template.id
version = aws_launch_template.test_template.latest_version
}
overrides {
subnet_id = "sub-xxxxxxxxxxxx"
weighted_capacity = 0
instance_requirements {
memory_mib {
max = 131072 # 128 Gb
min = 8192
}
vcpu_count {
max = 32
min = 4
}
}
}
}
timeouts {
create = "20m"
}
}
# Example Launch Template
resource "aws_launch_template" "test_template" {
name = "test-template"
image_id = "ami-xxxxxxxxxxxx"
key_name = var.key_name
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
http_put_response_hop_limit = 1
instance_metadata_tags = "enabled"
}
network_interfaces {
associate_public_ip_address = false
subnet_id = "sub-xxxxxxxxxxxx"
security_groups = ["sg-xxxxxxxxxxxx"]
}
tag_specifications {
resource_type = "instance"
}
}
Terraform Core Version
v1.4.3-dev
AWS Provider Version
v4.62.0
Affected Resource(s)
aws_spot_fleet_request
Expected Behavior
Success
Actual Behavior
Failed provisioning
Relevant Error/Panic Output Snippet
Terraform Configuration Files
Steps to Reproduce
terraform init terraform apply
Debug Output
Unnecessary
Panic Output
No response
Important Factoids
Ok, inside the aws_launch_template block I have parameter
instance_requirements
If this is set we get the error as described above. If instead I comment that block out and use:
instance_type = "t2.large"
The provisioning is successful.
Notice target_capacity = 0 in the aws_spot_fleet_request block, this is important, and I want a capacity of 0 because Jenkins is managing the fleet, provisioning additional nodes when it needs them. I tried to provision via AWS UI and import it later into the terraform config, the launch template was successful. but when I try to set 0 instances in the aws_spot_fleet_request I can-not launch it from the UI--the button is greyed out. I'm at a loss here, why does it work when I specify instance_type but I'm getting an availability zone error when I specify instance requirements?
This should be easy enough to reproduce, but just to be clear I'm trying to use ca-central-1 and my instances are provisioned on a private subnet.
References
https://github.com/hashicorp/terraform/issues/33040
Would you like to implement a fix?
No