Skip to content

Commit 809e0c5

Browse files
committed
fix: avoid Fn::Sub parsing in password log
Compute password length with wc to avoid Bash length expansion that cfn-lint interprets as a Sub variable in CloudFormation UserData.
1 parent 0653ae6 commit 809e0c5

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

infra/aws/cloudformation/opencode-cloud-quick.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,17 @@ Resources:
680680
signal_result 1 "opencode-cloud service did not become reachable on port 3000"
681681
fi
682682
683-
log "opencode-cloud setup: set user password"
683+
log "opencode-cloud setup: create user password"
684684
OPENCODE_PASSWORD="$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 24)"
685-
echo "$OPENCODE_USERNAME:$OPENCODE_PASSWORD" | docker exec -i "$OPENCODE_CONTAINER_NAME" chpasswd
686-
log "opencode-cloud setup: user password set"
685+
pass_len="$(printf '%s' "$OPENCODE_PASSWORD" | wc -c | tr -d ' ')"
686+
printf 'user=%q pass_len=%s\n' "$OPENCODE_USERNAME" "$pass_len"
687+
# Check if chpasswd hangs
688+
# docker exec -u root -i "$OPENCODE_CONTAINER_NAME" sh -lc 'echo testuser:testpass | chpasswd; echo "rc=$?"'
689+
# log "opencode-cloud setup: chpasswd test completed $?"
690+
log "opencode-cloud setup: setting user password"
691+
# echo "$OPENCODE_USERNAME:$OPENCODE_PASSWORD" | docker exec -i "$OPENCODE_CONTAINER_NAME" chpasswd
692+
docker exec -u root -i "$OPENCODE_CONTAINER_NAME" sh -lc "echo $OPENCODE_USERNAME:$OPENCODE_PASSWORD | chpasswd"
693+
log "opencode-cloud setup: user password set successfully"
687694
688695
log "opencode-cloud setup: write secrets payload"
689696
secret_payload="$(jq -n \

0 commit comments

Comments
 (0)