Skip to content

spawn dns and spawn cost still sign with the ambient AWS profile, ignoring --profile #967

Closed

Description

@scttfrdmn

Found while fixing #939 (PR #966).

#966 adds a gate (TestCommandsLoadAWSConfigThroughTheSharedLoader) that forbids package cmd from calling the SDK's config.LoadDefaultConfig directly, and routes every such site through the shared loader. The gate covers cmd only. Two pkg/ constructors that CLI commands call still load the ambient config themselves, so the root --profile (and SPORE_PROFILE) do not reach them:

  1. dns.NewClient (pkg/dns/client.go). spawn dns register and spawn dns deregister (cmd/dns.go) resolve the instance and account ID with a client that honours --profile. They then sign the DNS API request with the ambient credentials. With --profile other-account and a different ambient profile, the record is computed for one account and the request is signed by another. The signing region comes from the endpoint hostname, so region is fine. Only the identity is wrong.
  2. The pkg/cost default on-demand pricer (onDemandPricerOrDefault, pkg/cost/cost.go). spawn cost builds its DynamoDB client through the shared loader since Make spawn burst and every other command honour --region and --profile (#939) #966, but the lazy pricer loads its own ambient config. With only --profile credentials available, compute costs are reported as unpriced.

Not affected: the on-instance callers of dns.NewClient (spored), which have no flags.

Suggested: let both take an aws.Config (or a credentials provider) from the caller, as #966 did for registry.EnsureTable. Then consider extending the gate to pkg/ functions that cmd calls, if that can be discovered rather than listed.

Verified by reading the code only. Nothing was run against AWS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions