I am trying to update an existing AWS autoscaling group (which is already created manually long back) with new Launch configuration using terraform.
provider "aws" {
access_key = <Access_key>
secret_key = <Secret_key>
region = <REGION>
data "aws_autoscaling_groups" "asgpoc" {
filter {
name = "key"
values = ["Name"]
}
filter {
name = "value"
values = ["asgpoc"]
}
}
output "asgname" {
value = "${data.aws_autoscaling_groups.asgpoc.names}"
}
resource "aws_autoscaling_group" "tf-dl-poc-asg" {
availability_zones = ["us-west-2"]
name = "${data.aws_autoscaling_groups.asgpoc.names[0]}"
max_size = 2
min_size = 1
health_check_grace_period = 300
health_check_type = "EC2"
desired_capacity = 1
force_delete = false
launch_configuration = "tf_dl_asg_lc"
}
when I do terraform apply, I am getting error,
aws_autoscaling_group.tf-dl-poc-asg: Error creating AutoScaling Group: AlreadyExists: AutoScalingGroup by this name already exists - A group with the name asgpoc already exists status code: 400, request id: ba011d22-2624-s1ea-ace8-fbc37028ec9c
How to solve this issue? Is there any alternate way to update existing AWS ASG with terraform?