Sorry I'm a little confused by the bug template, not sure where I'm supposed to explain the bug.
But v2.61.0 is creating invalid launch templates; it creates templates with partition_index 0 and no placement group, which results in this error from AWS when creating an EKS cluster:
Error creating AutoScaling Group: ValidationError: You must use a valid fully-formed launch template. You cannot use PartitionNumber with a Placement Group that does not exist. Specify a valid Placement Group and try again.
v2.60.0 works fine, the partition number is left empty. Seems to be caused by #11655.
Terraform v0.12.24
Sorry can't share our actual code, didn't create a minimal example.
See above.
None
Can create ASGs based on launch templates.
Creating an ASG based on a launch template created by v2.61.0 causes an error (see top of report).
Try to create an ASG with v2.61.0 and no placement group.
Minimal example:
resource "aws_launch_template" "this" {
name_prefix = "test"
image_id = "ami-011c865bf7da41a9d"
instance_type = "m5.large"
placement {
tenancy = "default"
group_name = aws_placement_group.test.id
}
}
resource "aws_autoscaling_group" "this" {
name_prefix = "test"
availability_zones = ["us-east-1a"]
desired_capacity = 1
min_size = 1
max_size = 3
launch_template {
id = aws_launch_template.this.id
version = "$Latest"
}
}
resource "aws_placement_group" "test" {
name = "test"
strategy = "cluster"
}
provider "aws" {
region = "us-east-1"
}
Output:
Terraform will perform the following actions:
# aws_autoscaling_group.this will be created
+ resource "aws_autoscaling_group" "this" {
+ arn = (known after apply)
+ availability_zones = [
+ "us-east-1a",
]
+ default_cooldown = (known after apply)
+ desired_capacity = 1
+ force_delete = false
+ health_check_grace_period = 300
+ health_check_type = (known after apply)
+ id = (known after apply)
+ load_balancers = (known after apply)
+ max_size = 3
+ metrics_granularity = "1Minute"
+ min_size = 1
+ name = (known after apply)
+ name_prefix = "test"
+ protect_from_scale_in = false
+ service_linked_role_arn = (known after apply)
+ target_group_arns = (known after apply)
+ vpc_zone_identifier = (known after apply)
+ wait_for_capacity_timeout = "10m"
+ launch_template {
+ id = (known after apply)
+ name = (known after apply)
+ version = "$Latest"
}
}
# aws_launch_template.this will be created
+ resource "aws_launch_template" "this" {
+ arn = (known after apply)
+ default_version = (known after apply)
+ id = (known after apply)
+ image_id = "ami-011c865bf7da41a9d"
+ instance_type = "m5.large"
+ latest_version = (known after apply)
+ name = (known after apply)
+ name_prefix = "test"
+ metadata_options {
+ http_endpoint = (known after apply)
+ http_put_response_hop_limit = (known after apply)
+ http_tokens = (known after apply)
}
+ placement {
+ group_name = (known after apply)
+ tenancy = "default"
}
}
# aws_placement_group.test will be created
+ resource "aws_placement_group" "test" {
+ id = (known after apply)
+ name = "test"
+ placement_group_id = (known after apply)
+ strategy = "cluster"
}
Plan: 3 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_placement_group.test: Creating...
aws_placement_group.test: Creation complete after 1s [id=test]
aws_launch_template.this: Creating...
aws_launch_template.this: Creation complete after 2s [id=lt-01059bd14a1f3f2d7]
aws_autoscaling_group.this: Creating...
Error: Error creating AutoScaling Group: ValidationError: You must use a valid fully-formed
launch template. You cannot use PartitionNumber with a Placement Group that does not
use the 'partition' strategy. Placement Group 'test' uses 'cluster' strategy. Specify a
different Placement Group and try again.
status code: 400, request id: 186d3713-b9e4-4d0b-8309-904d701a7ff5
on main.tf line 16, in resource "aws_autoscaling_group" "this":
16: resource "aws_autoscaling_group" "this" {
Terraform v0.12.24
+ provider.aws v2.61.0
Not sure if this is a provider or aws-sdk-go issue. Something is setting partition_number to 0 which is invalid in all use cases.
Trace: https://gist.github.com/dpiddockcmp/3e48d01bf8744467133b1734c98e87b8
Sorry for breaking this ๐
if i change the code at: https://github.com/terraform-providers/terraform-provider-aws/blob/6cf84739011aa60bb8aa0c501b08dfc280716af7/aws/resource_aws_launch_template.go#L1710
to disallow zero values it seems to fix it (at least the example given by @dpiddockcmp)
ill open a PR to address it
opened #13239 to address this, still running some tests but looks good so far
I am experiencing the same issue with aws provider version "~> 2.59" and eks module version "~> 10.0".
We already have a cluster running in production which did not have a placement group, but is working fine. I am in the midst of creating a testing cluster, with the above mentioned provider versions, and again with no placement groups defined. But I am getting the following errors:
Error: Error creating AutoScaling Group: ValidationError: You must use a valid fully-formed launch template. You cannot use PartitionNumber with a Placement Group that does not exist. Specify a valid Placement Group and try again.
status code: 400, request id: 8760f1ce-69ea-4457-83a3-37eee9e11804
on .terraform/modules/eks_cluster/terraform-aws-eks-10.0.0/workers_launch_template.tf line 3, in resource "aws_autoscaling_group" "workers_launch_template":
3: resource "aws_autoscaling_group" "workers_launch_template" {
@Murty0
There is a bug in the latest aws provider, version 2.61.0. Either upgrade the eks module to 12.0.0 or set your aws provider version to = 2.60.0. Setting the provider version like this is not recommended as it will break on a future version of that module.
hey @dpiddockcmp , thanks for your reply!
So I have pinned my aws provider version to =2.59 for now which has resolved this issue, and after doing some testing in this test cluster to see if the eks module upgrade breaks anything or not, will upgrade the eks module to 12.0.0 in our production environment!
The fix for this has been merged and will release with version 2.63.0 of the Terraform AWS Provider, late next week. Thanks to @DrFaust92 for the fix. ๐
It looks like the EC2 Launch Template API very recently added some form of returning validation warnings/errors. I will create a followup issue for that and prioritize it since this has been a recurring issue with this Terraform resource.
This has been released in version 2.63.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!
I dont see this issue addressed/fix released in version 2.63 of the Terraform AWS provider. Has this been released?
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
The fix for this has been merged and will release with version 2.63.0 of the Terraform AWS Provider, late next week. Thanks to @DrFaust92 for the fix. ๐
It looks like the EC2 Launch Template API very recently added some form of returning validation warnings/errors. I will create a followup issue for that and prioritize it since this has been a recurring issue with this Terraform resource.