This repository has been archived by the owner on Jan 25, 2023. It is now read-only.
Allow configuration of aws_autoscaling_group name_prefix that is not dependent on the cluster_name in nomad_cluster module #174
Labels
Background
My goal is to be able to force the recreation of the ASG created in this module when the launch configuration changes. This is a configuration parameter supported by the terraform-aws-autoscaling module. See configuration parameter
recreate_asg_when_lc_changes
. This would enable terraform to detect when the launch configuration has a new AMI and associated with it, forcing the replacement of every ec2 instance in the ASG with the new AMI. This makes the question "how do you roll out updates"? Something that can be completely handled by Terraform.Suggested changes
I propose we add an optional variable called
asg_name_prefix
to the nomad-cluster module in this repository. I suggest we change the assignment of thename_prefix
variable on theautoscaling_group
resource toasg_name_prefix
if it is not provided, we can fall back to the existingcluster_name
variable using thecoalesce
function.In addition, I propose we enhance the "how do you roll out updates" documentation to show how to configure this module to recreate your ASG when your launch configuration changes. This documentation would contain the following example code snippet.
Note that this concept of using the
random_pet
resource to force the recreation of the ASG is 100% taken from the terraform-aws-autoscaling module. We could also consider modifying this module to use the terraform-aws-autoscaling instead of creating theaws_autoscaling_group
resource directly.Other notes:
Note that introducing a variable for the ASG name is not unprecedented in the Hashicorp terraform module ecosystem. The nomad-cluster module provides an optional
asg_name
variable which enables this deployment strategy.In addition, it's important to recognize that the sample code I supplied in the above section is currently not possible without this configuration variable. This is because the
cluster_name
variable is used in bothlaunch_configuration
's andaws_autoscaling_group
'sname_prefix
variables. As a result, introducing arandom_pet
whose keeper is thelaunch_configuration
's name and is used in thecluster_name
variable introduces a cyclic dependency.Curious to hear your thoughts. I'd be happy to take on this work immediately if we reach on consensus on a path forward. If there is another way to accomplish this with Terraform, let me know. I think this would simply the deployments of some systems which don't need 0 downtime and enable better use of this module without the need for scripts/lambdas which manage the consul server
The text was updated successfully, but these errors were encountered: