-
Notifications
You must be signed in to change notification settings - Fork 15
add wstd-aws crate, for integration with aws-sdk #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yoshuawuyts
approved these changes
Oct 30, 2025
Member
yoshuawuyts
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked this over; looks great! Tysm!
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
wstd-aws crate
This crate provides support for using the AWS Rust SDK for the
wasm32-wasip2target using the
wstdcrate.In many wasi settings, its necessary or desirable to use the wasi-http
interface to make http requests. Wasi-http interfaces provide an http
implementation, including the sockets layer and TLS, outside of the user's
component.
wstdprovides user-friendly async Rust interfaces to all of thestandardized wasi interfaces, including wasi-http.
The AWS Rust SDK, by default, depends on
tokio,hyper, and eitherrustlsor
s2n_tls, and makes http requests over sockets (which can be provided aswasi-sockets). Those dependencies may not work correctly under
wasm32-wasip2,and if they do, they will not use the wasi-http interfaces. To avoid using
http over sockets, make sure to set the
default-features = falsesettingwhen depending on any
aws-*crates in your project.To configure
wstd's wasi-http client for the AWS Rust SDK, providewstd_aws::sleep_impl()andwstd_aws::http_client()to youraws_config::ConfigLoader:Example
An example s3 client is provided as a wasi cli command. It accepts command
line arguments with the subcommand
listto list a bucket's contents, andget <key>to get an object from a bucket and write it to the filesystem.This example must be compiled in release mode - in debug mode, the aws
sdk's generated code will overflow the maximum permitted wasm locals in
a single function.
Compile it with:
When running this example, you will need AWS credentials provided in environment
variables.
Run it with:
wasmtime run -Shttp \ --env AWS_ACCESS_KEY_ID \ --env AWS_SECRET_ACCESS_KEY \ --env AWS_SESSION_TOKEN \ --dir .::. \ target/wasm32-wasip2/release/examples/s3.wasmor alternatively run it with:
which uses the wasmtime cli, as above, via configuration found in this
workspace's
.cargo/config.By default, this script accesses the
wstd-example-bucketinus-west-2.To change the bucket or region, use the
--bucketand--regioncliflags before the subcommand.
CI
The example is tested in CI, which means CI needs aws credentials. I have configured a role and bucket on my AWS account to use a OIDC-based authentication which trusts GitHub Actions run on the
bytecodealliance/wstdrepo. If the CI workflow is run locally, or on other repos where this authentication fails, thetest-programscrate has featureno-awsthat will #[ignore] the tests which require aws credentials.