Skip to content

Detached sweeps with --iam-role/--iam-policy/--instance-profile: the orchestrator cannot pass the profile, every member is refused #1331

Closed

Description

@scttfrdmn

Found while doing #1323. A detached sweep whose members use a custom instance profile is refused at RunInstances for every member. This was already true before #1323 and still is after it.

Evidence (code trace, not run on AWS)

  • applyCLIIAMToSweep (cmd/launch_sweep.go) handles --iam-role / --iam-policy / --iam-policy-file / --iam-managed-policies / --s3-read / --s3-write: it creates a spawn-instance-<hash> role and profile (pkg/aws/iam.go generateRoleName) and writes it to defaults.iam_role. --instance-profile X and a row's own iam_role: are passed through as given.
  • The orchestrator assumes SpawnSweepCrossAccountRole in the member account and calls RunInstances with that profile. Since Detached sweep members launch with no UserData, so spored never runs on them (#725 follow-up; blocks #1313) #1323, that role's only iam:PassRole grant (scripts/setup-sweep-cross-account-role.sh) is role/spored-instance-role and role/spawnd-role, conditioned on iam:PassedToService=ec2.amazonaws.com. Before Detached sweep members launch with no UserData, so spored never runs on them (#725 follow-up; blocks #1313) #1323 it was role/spawnd-role alone.
  • So for any other profile EC2 refuses with an authorization error. isCapacityError does not match that error, so the member fails immediately and the sweep records it as a failed row. The foreground path has no such limit, because it launches with the user's own credentials.

Options

  • Widen the grant to role/spawn-instance-*, which only spawn creates (its roles are tagged spawn:managed=true). Keep the EC2 condition and add an iam:ResourceTag-style condition if IAM supports one for PassRole; verify it with a real PutRolePolicy plus simulate allow/deny before relying on it.
  • And/or have the CLI refuse, before upload, a detached sweep whose profile the orchestrator cannot pass. Point the user at --no-detach, which works today, instead of a sweep where every member fails.

An arbitrary user-named --instance-profile cannot be covered by a scoped grant. It should get the refusal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions