Using the terraform-aws-modules/lambda/aws//modules/alias module

Hi All. I am losing my mind trying to do what i expected to be simple(ish).

I effectively have a Lambda with a couple of versions and two alias - preProd and Prod. when i initially run my tf apply, it correctly creates a new version of the lambda, updates the alias to this and all is good. I dont want it to update prod alias yet as want to run tests first but it does (on the first run only), create the prod alias with the initial version.

Now i tried everything but couldnt get it to work such that i could run the same apply with a param such as -var “alias=prod” and it would update my prod alias without killing my preProd one but eventually gave up.

So i decided to create a sub-project and have a separate state file that used a datasource to pull the version and update prod. But doing this always tells me its tring to re-create the alias which exists in aws now (but not in my other state file).

So i stumbled on terraform-aws-modules/lambda/aws//modules/alias. But i struggle to understand the documentation on this. If i read correctly, a combination of the two flags

refresh_alias and use_existing_alias should do what i want. I want to refresh the version of an alias but i dont want it to re-create the the alias.

But sadly this doesnt work either. with only refresh_alias, i get the error “alias exists” and if i include “use_existing_alias”, it does nothing !

Any ideas?