Skip to content

fix(#1537): allow s3 stores without static credentials - #1538

Open
dimitri-yatsenko wants to merge 1 commit into
masterfrom
fix/1537-s3-ambient-credentials
Open

fix(#1537): allow s3 stores without static credentials#1538
dimitri-yatsenko wants to merge 1 commit into
masterfrom
fix/1537-s3-ambient-credentials

Conversation

@dimitri-yatsenko

Copy link
Copy Markdown
Member

Closes #1537.

Makes access_key / secret_key optional for protocol: s3, so an ambient AWS identity (EC2 instance profile, EKS/IRSA service-account role, ECS task role, or a workstation with AWS_PROFILE/SSO) is used when no static keys are configured. This brings s3 in line with gcs and azure, which already fall through to their default credential chains — it removes an outlier rather than adding a mode.

Changes

  • settings.py — drop access_key/secret_key from required_keys["s3"] (endpoint/bucket/location stay required).
  • storage.py::_validate_spec — drop them from required; additionally reject exactly one of the pair, which botocore would otherwise accept and then fail late on with PartialCredentialsError at first object access.
  • storage.py::_create_filesystemself.spec["access_key"]self.spec.get("access_key") or None (same for secret_key). This is the easy-to-miss subscript that would raise KeyError after validation passes. The or None also coerces an empty string to absent: a forwarded "" survives s3fs's None-filter and botocore reads it as an explicit (invalid) credential.

Compatibility

Both-present behavior is exactly as today. Absence is the same signal s3fs itself uses for "automatic credentials", so no new config key is introduced (which would break older clients against the strict allowed_keys whitelist).

Tests

Unit tests for: ambient (no keys) validates and forwards neither kwarg; both-present forwarded unchanged; empty-string treated as absent; exactly-one rejected with a clear DataJointError; endpoint/bucket still required. Settings-level tests that the s3 spec no longer requires the credentials but still requires bucket.

s3 was the only storage protocol that mandated access_key/secret_key; gcs and
azure already fall through to their default credential chains. Make the two
optional so an ambient AWS identity (instance profile, IRSA, ECS task role, SSO)
is used when no static keys are configured.

- settings.py: drop access_key/secret_key from required_keys["s3"].
- storage.py::_validate_spec: drop them from required; reject exactly one of the
  pair (botocore would otherwise fail late with PartialCredentialsError).
- storage.py::_create_filesystem: self.spec["access_key"] -> .get(...) or None
  so a missing OR empty-string credential is dropped and botocore resolves the
  chain (a forwarded "" is read as an explicit, invalid credential).

Both-present behavior is unchanged; backward compatible. Adds unit tests for the
ambient, both-present, empty-string, and partial-credential cases.
@dimitri-yatsenko dimitri-yatsenko added this to the v2.3.3 milestone Aug 11, 2026
@dimitri-yatsenko dimitri-yatsenko added the enhancement Indicates new improvements label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Indicates new improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IMPR: allow s3 stores without static credentials, matching gcs/azure

1 participant