Skip to content

fix(aws): grant exact runtime capability actions - #1357

Open
aryasaatvik wants to merge 4 commits into
alchemy-run:mainfrom
aryasaatvik:fix/runtime-iam-actions
Open

fix(aws): grant exact runtime capability actions#1357
aryasaatvik wants to merge 4 commits into
alchemy-run:mainfrom
aryasaatvik:fix/runtime-iam-actions

Conversation

@aryasaatvik

Copy link
Copy Markdown
Contributor

Summary

Align runtime IAM policies with the exact AWS capabilities used by the S3 and Secrets Manager bindings.

Policy mapping

Binding Runtime actions Source
HeadObjectHttp s3:GetObject, s3:GetObjectVersion, plus s3:ListBucket for missing-key 404 semantics HeadObject API, S3 permissions
PresignGetObjectHttp s3:GetObject Presigned URLs
GetSecretValueHttp secretsmanager:GetSecretValue GetSecretValue API, Secrets Manager authorization

HeadObjectHttp supports version-aware metadata reads, so both current-object and version-object read actions remain available. ListBucket is kept for AWS's documented 404 versus 403 behavior when a key is missing. The presigned binding signs an unversioned GET, and DescribeSecret is not needed because it returns metadata rather than secret contents. Customer-managed KMS permissions remain conditional on the configured key and are intentionally not added to the generic binding.

Validation

  • mise exec bun@1.3.13 -- bun node_modules/alchemy-test/bin/alchemy-test.ts --sequential test/AWS/S3/HeadObjectHttp.test.ts test/AWS/S3/PresignGetObjectHttp.test.ts test/AWS/SecretsManager/GetSecretValueHttp.test.ts
  • Result: 0 failed | 3 passed
  • The same focused suite fails against origin/main with 3 failed | 0 passed, covering all three policy regressions.

Scope

This narrows generated runtime grants and keeps policy definitions inline with the existing binding implementations.

Link each affected binding to the authoritative AWS permission documentation and explain the deliberate version, missing-key, presigning, and KMS behavior in source JSDoc.
Comment on lines +56 to +61
Effect.provide(HeadObjectHttp),
Effect.provide(Credentials.mock),
Effect.provide(Region.of("us-east-1")),
Effect.provide(FetchHttpClient.layer),
Effect.provide(Layer.succeed(Self, host)),
Effect.provide(Layer.succeed(RuntimeContext, runtime)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never do subsequent Effect.provide. You need to provide once, use Layer.* to build the layer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests should be in fixtures that actually exercise the binding through a lambda function

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't locally mock. Actually test it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have the pattern established, just add tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the mocks and moved coverage into the existing Lambda fixtures, including HeadObject. Pushed in 46ebfa1; targeted tests pass

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.

2 participants