unoverse 0.1.101 → 0.1.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/operator/infra/aws/main.tf +15 -0
- package/operator/lib/deploy.sh +30 -1
- package/package.json +1 -1
|
@@ -11,6 +11,9 @@ terraform {
|
|
|
11
11
|
aws = { source = "hashicorp/aws", version = ">= 5.83, < 6.0" }
|
|
12
12
|
random = { source = "hashicorp/random", version = "~> 3.6" }
|
|
13
13
|
archive = { source = "hashicorp/archive", version = "~> 2.4" }
|
|
14
|
+
# For the IAM propagation wait below. IAM is eventually consistent and Lambda is the
|
|
15
|
+
# one resource here that reliably outruns it.
|
|
16
|
+
time = { source = "hashicorp/time", version = "~> 0.11" }
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
19
|
|
|
@@ -369,7 +372,19 @@ resource "aws_iam_role_policy_attachment" "pretoken_logs" {
|
|
|
369
372
|
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
|
|
370
373
|
}
|
|
371
374
|
|
|
375
|
+
# IAM IS EVENTUALLY CONSISTENT, AND LAMBDA OUTRUNS IT. The role is created, Lambda is
|
|
376
|
+
# created two seconds later, and AWS answers "The role defined for the function cannot be
|
|
377
|
+
# assumed by Lambda" — the role is correct and simply not visible yet. Terraform's
|
|
378
|
+
# dependency graph is satisfied because the role exists; AWS's own propagation is not.
|
|
379
|
+
#
|
|
380
|
+
# Ten seconds is the usual advice and it costs ten seconds on a first apply only.
|
|
381
|
+
resource "time_sleep" "iam_propagation" {
|
|
382
|
+
depends_on = [aws_iam_role.pretoken, aws_iam_role_policy_attachment.pretoken_logs]
|
|
383
|
+
create_duration = "10s"
|
|
384
|
+
}
|
|
385
|
+
|
|
372
386
|
resource "aws_lambda_function" "pretoken" {
|
|
387
|
+
depends_on = [time_sleep.iam_propagation]
|
|
373
388
|
function_name = "${var.name}-pretoken"
|
|
374
389
|
role = aws_iam_role.pretoken.arn
|
|
375
390
|
runtime = "nodejs20.x"
|
package/operator/lib/deploy.sh
CHANGED
|
@@ -366,6 +366,35 @@ _ensure_ground_config() {
|
|
|
366
366
|
esac
|
|
367
367
|
fi
|
|
368
368
|
|
|
369
|
+
# CAN THIS MACHINE ACTUALLY REACH WHAT IT IS ABOUT TO BUILD?
|
|
370
|
+
#
|
|
371
|
+
# An EC2 key pair the operator does not hold applies perfectly and then fails at the ship
|
|
372
|
+
# step: eleven minutes of RDS and ElastiCache provisioning, then "Permission denied
|
|
373
|
+
# (publickey)". Generating the ground correctly is not enough — tfvars is the developer's
|
|
374
|
+
# file and `unoverse update` never rewrites it, so a ground made before this check keeps
|
|
375
|
+
# its unusable key forever and fails the same way every time.
|
|
376
|
+
#
|
|
377
|
+
# Checked here, before the plan, because the cost of being wrong is money and eleven
|
|
378
|
+
# minutes, and the fix is one line in a file this command already edits.
|
|
379
|
+
if [ "$cloud" = "aws" ]; then
|
|
380
|
+
local named_key pub_key
|
|
381
|
+
named_key=$(grep -E '^ssh_key_name[[:space:]]*=' "$tfv" 2>/dev/null | sed -E 's/.*"([^"]*)".*/\1/')
|
|
382
|
+
if [ -n "$named_key" ] && ! grep -qE '^operator_public_key[[:space:]]*=[[:space:]]*"ssh-' "$tfv" 2>/dev/null; then
|
|
383
|
+
for pub_key in "$HOME/.ssh/id_ed25519.pub" "$HOME/.ssh/id_rsa.pub" ""; do
|
|
384
|
+
[ -n "$pub_key" ] && [ -f "$pub_key" ] && break
|
|
385
|
+
done
|
|
386
|
+
if [ -n "$pub_key" ]; then
|
|
387
|
+
node -e 'const fs=require("fs");const[f,v]=process.argv.slice(1);let s=fs.readFileSync(f,"utf8");
|
|
388
|
+
s=s.replace(/^ssh_key_name\s*=.*$/m,"ssh_key_name = \"\" # empty = terraform uploads operator_public_key below\noperator_public_key = "+JSON.stringify(v)+" # your key: the deploy ssh-es from this machine");
|
|
389
|
+
fs.writeFileSync(f,s)' "$tfv" "$(cat "$pub_key")"
|
|
390
|
+
ok "SSH key: your own ${DIM}($(basename "$pub_key") — replacing '"'"'$named_key'"'"', whose private half is not on this machine)${NC}"
|
|
391
|
+
else
|
|
392
|
+
warn "No ssh key on this machine. The deploy will build, then fail to reach the server"
|
|
393
|
+
info "Make one with ${BOLD}ssh-keygen -t ed25519${NC} and run this again"
|
|
394
|
+
fi
|
|
395
|
+
fi
|
|
396
|
+
fi
|
|
397
|
+
|
|
369
398
|
_tf_fill docr_token DOCR_TOKEN "Registry access token (from your Unoverse admin)"
|
|
370
399
|
_tf_fill openai_api_key OPENAI_API_KEY "OPENAI_API_KEY (powers the platform's AI)"
|
|
371
400
|
if grep -q '^auth_issuer[[:space:]]*=[[:space:]]*"FILL_ME"' "$tfv" 2>/dev/null; then
|
|
@@ -534,7 +563,7 @@ _ground_apply() {
|
|
|
534
563
|
echo ""
|
|
535
564
|
info "Building. Managed databases take a few minutes on the provider's side"
|
|
536
565
|
echo ""
|
|
537
|
-
terraform -chdir="$dir" apply -input=false "$planfile" || { fail "The build did not finish.
|
|
566
|
+
terraform -chdir="$dir" apply -input=false "$planfile" || { fail "The build did not finish. Nothing already built is lost — re-run: unoverse deploy $cloud"; rm -rf "$tmp"; return 1; }
|
|
538
567
|
rm -rf "$tmp"
|
|
539
568
|
return 0
|
|
540
569
|
}
|
package/package.json
CHANGED