If I recall correctly, "aws_volume_attachment" is used to describe the relationship between a volume and an instance that Terraform has an understanding of -- and more often than not that Terraform itself provisioned.
In this case, Terraform is provisioning the ASG, and it is the ASG that is provisioning the instance, the volume, and doing the attachment. In that situation, Terraform doesn't have a clear understanding of what the instances or volumes are without imports; nor is it the one responsible for attaching the volume as you're trying to do with the vol-attachment block.
I think what you want instead is for Terraform to provision your volumes, and then supply those volume-ids to a
template that will be imported into your ASG's user-data. Then your user-data needs to do two things:
1) on boot, take the volume id, grab the volume and attach it to itself, and mount it and;
2) setup a shutdown script to detach the volume from itself.
Alternatively, as it sounds like your baking amis, you can build the above scripts into your bake. Thereafter, have Terraform supply the
ASG with tags of the vol-id's you provisioned, and build into the scripts a function to either grab the volumes/ build new vols from snapshots of the ids/etc.
There are a bunch of ways to attack this, but volume-attachment with an ASG is going to be a difficult - though not impossible - mechanism. Unless you very specifically want Terraform to control the relationship, you're probably best served by having the instance manage the relationship itself.