Skip to content

fix(reverse-import): pass customer assume-role auth to the closure discoverer (presets#770)#198

Merged
sam-at-luther merged 1 commit into
mainfrom
chore/770-assume-role-wiring
Jun 10, 2026
Merged

fix(reverse-import): pass customer assume-role auth to the closure discoverer (presets#770)#198
sam-at-luther merged 1 commit into
mainfrom
chore/770-assume-role-wiring

Conversation

@sam-at-luther

Copy link
Copy Markdown
Member

What

Pass the customer-account assume-role identity to the reverse-import closure discoverer, completing the presets#739 credentials fix in the deployed (Mars job pod) context.

Why

  • The Mars reverse-import job pod runs as the platform Argo role; terraform reaches the customer account via generated assume_role { role_arn } blocks.
  • The closure/dep-chase discoverer (presets#770, wired here per Reverse-import job never wires a closure discoverer (selection_closure_unavailable; dep-chase skipped) #195) hits the AWS SDK directly. Without the same assume-role hop it runs as the wrong principal and the customer account returns AccessDenied (presets#739 defect 2).
  • presets#770 added a trailing reversedisco.AWSAssumeRole arg to reversedisco.New and exported reverseimport.ResolveAWSProviderAuth so the discoverer-construction site and the engine share one resolution path. This PR consumes that.

Changes

  • Bump insideout-terraform-presets to 6f2675350c14 (presets#770).
  • Resolve the customer auth eagerly at Main via ResolveAWSProviderAuth (cheap, network-free: TF_VAR_bootstrap_role / TF_VAR_aws_external_id env — present in the job pod env — then outputs/cloud-provision.json, then tf/auto-vars), and thread it through discovererFactory + lazyDiscoverer to reversedisco.New. The cloud is still dialed lazily, preserving the validate-before-dial ordering (codex P2 on fix(reverse-import): wire closure-capable discoverer into the job (#195) #196).
  • A resolve error (corrupt artifacts) is logged to stderr and downgraded to empty (ambient) auth: closure is best-effort and now degrades gracefully on the discoverer path, and the engine's own ResolveAWSProviderAuth inside Run surfaces the same error fatally if it matters for the provider blocks.

Tests

  • TestMainResolvesAndPassesAssumeRoleAuth: sets TF_VAR_* env, drives Main with a recording fake factory, asserts the factory received that RoleARN/ExternalID. Failing-proof verified (temporarily passing an empty struct makes it fail).
  • TestMainPassesEmptyAssumeRoleAuthWhenUnset: empty env → empty AWSAssumeRole (ambient).
  • Existing fake-factory signatures updated for the new trailing arg.
  • go build ./... && go vet ./... && go test ./... green (68 tests, 17 packages); gofmt clean.

Zero behavior change beyond the auth wiring + pin bump.

@socket-security

socket-security Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgolang/​github.com/​luthersystems/​insideout-terraform-presets@​v0.11.1-0.20260609165415-4669c80c4789 ⏵ v0.11.1-0.20260609234539-6f2675350c1475 +1100100100100

View full report

…scoverer (presets#770)

The Mars reverse-import job pod runs as the platform Argo role; terraform
reaches the customer account via generated assume_role { role_arn } blocks.
The closure/dep-chase discoverer hits the AWS SDK directly, so it must
adopt the SAME assume-role identity — otherwise its calls run as the wrong
principal and the customer account returns AccessDenied (presets#739
defect 2). Pre-#770 the discoverer used raw ambient pod creds.

- Bump insideout-terraform-presets to 6f2675350c14 (presets#770), which
  added the trailing reversedisco.AWSAssumeRole arg to reversedisco.New
  and exported reverseimport.ResolveAWSProviderAuth.
- Resolve the customer auth eagerly at Main via ResolveAWSProviderAuth
  (cheap, network-free: TF_VAR_bootstrap_role / TF_VAR_aws_external_id
  env, then outputs/cloud-provision.json, then tf/auto-vars) and thread
  it through discovererFactory + lazyDiscoverer to reversedisco.New. The
  cloud is still dialed lazily, preserving validate-before-dial ordering.
- A resolve error (corrupt artifacts) is logged and downgraded to empty
  (ambient) auth; the engine's own ResolveAWSProviderAuth in Run surfaces
  the same error fatally if it actually matters for the provider blocks.

Tests: assert Main threads the resolved RoleARN/ExternalID to the
factory, and that empty env yields empty (ambient) auth.
@sam-at-luther sam-at-luther force-pushed the chore/770-assume-role-wiring branch from 282d689 to 3f42386 Compare June 10, 2026 00:02
@sam-at-luther sam-at-luther merged commit 028a34e into main Jun 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant