claudie
claudie copied to clipboard
Bug: Unterminated template string
Current Behaviour
Getting the following error:
terraformer-8495c979b8-c8j59 terraformer 2024-03-14T02:34:09Z WRN ../go/internal/command/cmd.go:145 > Retrying command terraform apply --auto-approve --parallelism=8... (2/5) module=terraformer
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 ╷
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ Error: Invalid multi-line string
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ on vienna-2-fewhjx0-azure-1-provider.tf line 3, in provider "azurerm":
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ 3: subscription_id = "80839dc0-2dcc-4ed1-8c8b-f208da773517
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ 4: "
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ Quoted strings may not be split over multiple lines. To produce a
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ multi-line string, either use the \n escape to represent a newline
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ character or use the "heredoc" multi-line template syntax.
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 ╵
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 ╷
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ Error: Unterminated template string
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ on vienna-2-fewhjx0-azure-1-provider.tf line 3, in provider "azurerm":
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ 3: subscription_id = "80839dc0-2dcc-4ed1-8c8b-f208da773517
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ 4: "
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 │ No closing marker was found for the string.
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0 ╵
terraformer-8495c979b8-c8j59 terraformer 2024-03-14T02:34:09Z WRN ../go/internal/command/cmd.go:92 > Error encountered while executing terraform apply --auto-approve --parallelism=8 : exit status 1 module=terraformer
Expected Behaviour
The input manifest should be processed successfully
Steps To Reproduce
Applying the manifest:
apiVersion: claudie.io/v1beta1
kind: InputManifest
metadata:
name: vienna-2
namespace: claudie
labels:
app.kubernetes.io/part-of: claudie
spec:
providers:
- name: azure-1
providerType: azure
secretRef:
name: azure-secret-1
namespace: claudie
- name: oci-1
providerType: oci
secretRef:
name: oci-secret-1
namespace: claudie
nodePools:
dynamic:
- name: control-azure
providerSpec:
name: azure-1
region: West Europe
zone: "1"
count: 2
serverType: Standard_B2s
image: Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts:22.04.202212120
- name: compute-1-azure
providerSpec:
name: azure-1
region: Germany West Central
zone: "1"
count: 2
serverType: Standard_B2s
image: Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts:22.04.202212120
storageDiskSize: 50
- name: compute-2-azure
providerSpec:
name: azure-1
region: West Europe
zone: "1"
count: 2
serverType: Standard_B2s
image: Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts:22.04.202212120
storageDiskSize: 50
kubernetes:
clusters:
- name: vienna-2
version: v1.26.0
network: 192.168.2.0/24
pools:
control:
- control-azure
compute:
- compute-2-azure
- compute-1-azure
I now see where the issue is, the provider configuration - after the subscription ID there is a new line
@bernardhalas, this is more of a user error, you have created a secret that has a whitespace (newline) at the end of the subscription ID (input manifest that you posted is ok syntactically).
To minimize this kind of error we could trim the whitespace when reading the secrets
I'll validate if the newline was coming from the azure provider secret. @Despire thanks for the hint.
any updates @bernardhalas ?
This can be reproduced for examply by executing:
echo "....secret...." | base64
to correctly base64 the secret without the implicit newline from echo:
echo -n "...secret..." | base64
Hi, this was indeed a problem on the side of a user. While using Claudie recently it appeared a few more times. I'd like to propose trimming the secret values, to ensure copy/paste whitespace and newline chars don't create errors which are difficult to fix.
Btw, in case someone comes across an error and suspects the issue being caused by a trailing newline char, this helps:
kubectl get secret name-of-secret -o go-template='
{{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}'
(ref)