-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[terraform] Add random variables to terrraform resource names #12385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2201f5a
to
0fd7460
Compare
fcf0922
to
6fad33f
Compare
6fad33f
to
68e3e38
Compare
0fd7460
to
3ecbe48
Compare
9288929
to
a13f1bb
Compare
@@ -102,6 +110,7 @@ module "eks" { | |||
enable_bootstrap_user_data = true | |||
instance_types = [var.service_machine_type] | |||
name = "service-${var.cluster_name}" | |||
iam_role_name = format("%s-%s", substr("${var.cluster_name}-svc-ng", 0, 58), random_string.ng_role_suffix.result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct in reading that this it to make a string a max of 62 characters long, always ending -svc-ng-<4-random-chars>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is correct. I believe that is the max char limit.
export resource=$$(echo "$$TF_VAR_TEST_ID" | sed "s/[\\W\\-]//") && \ | ||
az aks get-credentials --name gitpod-test-nor-primary-$$resource --resource-group gitpod-test-nor-$$resource --file ${KUBECONFIG} || echo "No cluster present" | ||
export resource=$$(echo "$$TF_VAR_TEST_ID" | sed "s/[\\W\\-]//g") && \ | ||
az aks get-credentials --name test-cluster-$$resource --resource-group sh-test-$$resource --file ${KUBECONFIG} || echo "No cluster present" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the terraform output
command instead? Something like...
az aks get-credentials --name test-cluster-$$resource --resource-group sh-test-$$resource --file ${KUBECONFIG} || echo "No cluster present" | |
az aks get-credentials --name $(terraform output -json <name> | jq -r '.') --resource-group $(terraform output -json <name> | jq -r '.') --file ${KUBECONFIG} || echo "No cluster present" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would involve changing the AKS terraform module output too. Do you mind if I take this up on a follow-up? I have to refactor the AKS module soon once the reference architecture is out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/hold
Looks ok. Added a couple of questions, with a "hold" to see if you want to change anything. Remove hold at your convenience
3ecbe48
to
61a7be3
Compare
a13f1bb
to
fc9fc8c
Compare
/unhold The extraction of name from |
fc9fc8c
to
c5c9c9a
Compare
Description
This is basically the same changes @adrienthebo opened here #12321
The PR was unfortunately merged to a different branch, and this is an effort to split up the PR again to ease the review since it ended up becoming really big.
The main goal of this change is to make sure re-using the same state continues to work. So for starters things like database names cannot be re-used across most cloud providers for a week after the deletion, etc. Hence, the change @adrienthebo suggested adds a random variable to the end of resource names. Moreover, if a kubernetes cluster already exists by the name, the cluster creation is skipped and re-installation of KOTS is proceeded.
Related Issue(s)
Fixes #
How to test
Release Notes
Documentation
Werft options: