project build: skip STS GetCallerIdentity when every deployment target already has an account
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- aws, typescript
- Ambito
- build-system, cli
Direzione di ricerca
Inizia in lib/schemas/io/config-io.ts nella libreria construct e riproduci il caso AWS_PROFILE con account espliciti in aws-targets.json. Controlla resolveRegionFallback() nello stesso metodo, poi verifica il pin in src/assets/cdk/package.json ed esegui scripts/sync-template-cdk.mjs insieme a src/assets/tests/cdk-schema-compat.test.ts. È completato quando i targets completamente popolati non attivano STS durante la build.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
agentcore project build is meant to be fully offline: it runs cdk synth only, and every stack's environment comes from agentcore/aws-targets.json. It currently isn't, when AWS_PROFILE is set.
Found by @aidandaly24 in review of #1970 (comment):
Non-blocking and fine as a follow-up: synthesis succeeds without credentials, but
AWS_PROFILEcurrently causes the pinnedConfigIO.readAWSDeploymentTargets()to call STS even when every target already has an account. I confirmed this by redirecting STS locally. The build still succeeded, but made sixGetCallerIdentityattempts and inherited the retry latency. Could we avoid that fallback when account values are already present so build is fully offline?
Cause
In @aws/agentcore-cdk@0.1.0-alpha.45, lib/schemas/io/config-io.ts:
// Only resolve account for targets that don't already have one saved
if (process.env.AWS_PROFILE) {
const account = await detectAwsAccount(); // <-- STS GetCallerIdentity
if (account) {
targets = targets.map(t => (t.account ? t : { ...t, account }));
}
}
The t.account ? t : ... guard is applied to the result. The STS call itself is gated only on AWS_PROFILE being set, so it fires even when it cannot change anything. detectAwsAccount() swallows failures, which is why the build still succeeds — but the SDK's default retry policy is paid first (the six attempts Aidan measured).
Suggested fix
Hoist the guard so the call is skipped when it would be a no-op:
if (process.env.AWS_PROFILE && targets.some(t => !t.account)) {
...
}
Worth reviewing resolveRegionFallback() in the same method too — it reads shared config files rather than calling a service, so it's cheap, but it runs unconditionally for the same reason.
Notes
- The fix lives in the construct library (
@aws/agentcore-cdk), not this CLI. Landing it here is then a version bump of the exact pin insrc/assets/cdk/package.json(currently0.1.0-alpha.45), whichscripts/sync-template-cdk.mjsandsrc/assets/__tests__/cdk-schema-compat.test.tscover. - No CLI-side workaround is needed in the meantime: build still succeeds, it's latency plus an unnecessary credential dependency.
- Repro: set
AWS_PROFILE, fill inaws-targets.jsonwith explicitaccountvalues, blackholests.*.amazonaws.com, then runagentcore project build.
cc @notgitika
- Lingua principale
- TypeScript
- Stelle
- 291
- Fork
- 96
- Merge medio
- 21h 31m
- PR unite (30g)
- 217
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws/agentcore-cli
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
aws/agentcore-cli#2395 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
aws/agentcore-cli#2392 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
aws/agentcore-cli#2267 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
aws/agentcore-cli#2258 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
aws/agentcore-cli#2176 ·
Tutte le issue di aws/agentcore-cli
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
bcgov/bc-wallet-mobile#4761 · 1 commento ·
-
external-issue to-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
area-deployment area-integrations triage:bot-seen
Difficoltà 2/5 Mezza giornata Idoneità per principianti 86/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100