Skip to content

Commit

Permalink
fix: Write sensitive cloud-init user-data into /etc/cloud/cloud.cfg.d
Browse files Browse the repository at this point in the history
This allows cloud-init to read the user-data without using an #include,
which always fails when cloud-init first runs.
  • Loading branch information
dlipovetsky committed Mar 8, 2024
1 parent 5aa9d22 commit b21896e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 25 deletions.
5 changes: 0 additions & 5 deletions docs/book/src/topics/userdata-privacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ cloudInit:
cloud-init does not print boothook script errors to the systemd journal. Logs for the script, if it errored can be found in
`/var/log/cloud-init-output.log`

### Warning messages

Because cloud-init will attempt to read the final file at start, cloud-init will always print a `/etc/secret-userdata.txt cannot be found`
message. This can be safely ignored.

### Secrets manager console

The AWS secrets manager console should show secrets being created and deleted, with a lifetime of around a minute. No plaintext secret
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/services/secretsmanager/secret_fetch_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if [ "{{.Endpoint}}" != "" ]; then
fi
SECRET_PREFIX="{{.SecretPrefix}}"
CHUNKS="{{.Chunks}}"
FILE="/etc/secret-userdata.txt"
FILE="/etc/cloud/cloud.cfg.d/99_kubeadm_bootstrap.cfg"
FINAL_INDEX=$((CHUNKS - 1))
# Log an error and exit.
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/services/ssm/secret_fetch_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if [ "{{.Endpoint}}" != "" ]; then
fi
SECRET_PREFIX="{{.SecretPrefix}}"
CHUNKS="{{.Chunks}}"
FILE="/etc/secret-userdata.txt"
FILE="/etc/cloud/cloud.cfg.d/99_kubeadm_bootstrap.cfg"
FINAL_INDEX=$((CHUNKS - 1))
# Log an error and exit.
Expand Down
18 changes: 0 additions & 18 deletions pkg/internal/mime/mime.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@ import (
"strings"
)

const (
includePart = "file:///etc/secret-userdata.txt\n"
)

var (
includeType = textproto.MIMEHeader{
"content-type": {"text/x-include-url"},
}

boothookType = textproto.MIMEHeader{
"content-type": {"text/cloud-boothook"},
}
Expand Down Expand Up @@ -83,16 +75,6 @@ func GenerateInitDocument(secretPrefix string, chunks int32, region string, endp
return []byte{}, err
}

includeWriter, err := mpWriter.CreatePart(includeType)
if err != nil {
return []byte{}, err
}

_, err = includeWriter.Write([]byte(includePart))
if err != nil {
return []byte{}, err
}

if err := mpWriter.Close(); err != nil {
return []byte{}, err
}
Expand Down

0 comments on commit b21896e

Please sign in to comment.