amazon web services - How to update launch configuration for existing autoscaling group in terraform -


i trying update existing aws autoscaling group (which created manually long back) 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 terraform apply, getting error,

aws_autoscaling_group.tf-dl-poc-asg: error creating autoscaling group: alreadyexists: autoscalinggroup name exists - group name asgpoc exists status code: 400, request id: ba011d22-2624-s1ea-ace8-fbc37028ec9c

how solve issue? there alternate way update existing aws asg terraform?

the resource include data "aws_autoscaling_groups" "asgpoc" not under control terraform.

you should import exist resource first.

terraform import aws_autoscaling_group.tf-dl-poc-asg asgpoc 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -