-
Notifications
You must be signed in to change notification settings - Fork 249
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
WebAssembly support #59
Comments
Having S3, DynamoDB, and RDS clients available directly in WASM could allow many classes of web application to avoid having a dynamic backend entirely. |
We're building a GraphQL API in Rust that we deploy using server-side WebAssembly. Having native support for WASM in the AWS Rust SDK would be great. |
Are you interested in using the Rust SDK in Web Assembly? Please comment on this issue with more details about your potential use case! |
We are working on a sports league app and are interested in using communication and streaming services from AWS for a WebAssembly client. |
I am trying write a SPA backed by S3, similar to one that I have written in JavaScript using Rust and WASM. |
Wouldn't need the full AWS SDK, but being able to generate pre-signed S3 URLs for PUT/GET would probably cover a lot of my use cases (read/write key values from a private bucket for a WASM based edge function). |
We are interested in developing a set of basic operations using the AWS SDK (specially CloudFormation and Service Catalog). Those will be imported by the teams that use different programming languages. Therefore we believe that Webassembly is a perfect fit for that situation. Now that we have the Webassembly Component Model, it should be possible to use a tool such as wit-bindgen combined with Smithy itself to generate the bidings for the languages that we want to support. Additionally, the work that has been happening from the WASI sockets front in the context of Tokio should allow basic networking capabilities to the generated clients. |
Hello, We are working with a wasm-based plugin system (with a couple custom runtime hosts and bindings) where we would like to use the SDK to handle with connections to AWS. To be honest our use case is quite close to being fulfilled thanks to the ability to define our own The root cause seems to be this Cheers, |
I'm also interested in using s3 when targeting Thanks! |
We have a library that makes heavy use of the AWS SDK and we want to package/distribute it for multiple languages. WASM running in something like the Wasmer runtimes seems like our best bet for distributing it in a language agnostic way. We don't really have any need for browser support since we generally expect the library to be running in Lambdas or ECS, so |
I'm also interested in this. Anyone had any success interacting with RDS through a Wasm backend? |
+1 |
Please! |
In my experience, it is actually quite difficult to convert and existing library that does not support wasm targets to start supporting wasm targets. Dependencies that rely on the system (e.g. system clock), anything that requires multiple threads, dependencies written in C, C++ or Assembly will generally not be able to compile to to wasm targets. So converting the existing AWS SDK to support wasm is likely a very large ask. The other option we have is to use the AWS Rest APIs directly for the particular AWS service that one is interested in. It is relatively straightforward to construct arbitrary Http requests using wasm-bindgen and web-sys. Deserialization of responses is also straightforward using a serde for XML. The main difficulty with using the REST APIs is construction the [AWS V4 signature:] (https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html) for use in the Authorization header. There is at least one existing crate for V4 signatures https://crates.io/crates/aws-sign-v4, however it does not compile to a wasm target. In particular, ring, chrono, and url, do not compile to wasm. It does seem that the existing code could be forked with wasm compatible dependencies:
Such a project would then provide a path for those of us who want to call AWS APIs from the browser to have a path forward, with a reasonable amount of custom code required. |
If you use For the record, I ended up redoing a client from mostly scratch, as the types in the SDK arent public (so I can't just import the SDK to have It is a little messy, but you can find everything in that repo, with the custom signing code and a lot of manual "read the docs and rewrite structs" code |
I think we've been bad maintainers by not keeping everyone in the loop here, so here's an update to try and rectify that. In the last year, people have made significant contributions (shout out to @eduardomourar! ❤️) and we've also done some refactors that bring us closer to realizing WASM support. The SDK now compiles against We're a small team, and we're primarily focused on getting this SDK to 1.0 right now, so this feature hasn't been getting the love it deserves. However, it is on our minds. We opportunistically chip away at it as time permits, and we try not to write any code that will prohibit it in the future. This is something we would really like to support, and contributions in smithy-rs, the SDK's code generator, are welcome if someone wants to help out. I've created the aws-sdk-rust/next branch with the latest (unreleased) version of the SDK that has a configurable Also, regarding the lack of Thanks for all the feedback, everyone! |
I've gotten it working in smithy-lang/smithy-rs#2868! Very hopeful that this will be included in our next release. |
The August 3rd release should fix most of the major issues with getting the SDK to work in WebAssembly. It should compile against |
Update: I have read the example and fixed it. It occurs if the time_source is not be set.I'm encountering an issue while using bedrock_runtime SDK without default features and target on wasm: use aws_config::{
defaults, identity::IdentityCache, retry::RetryConfig, timeout::TimeoutConfig, BehaviorVersion,
};
use aws_sdk_bedrockruntime::{
config::{Credentials, StalledStreamProtectionConfig},
primitives::Blob,
Client,
};
// ...
let key = env.secret("AWS_ACCESS_KEY_ID").unwrap().to_string();
let secret = env.secret("AWS_SECRET_ACCESS_KEY").unwrap().to_string();
let cred = Credentials::new(key, secret, None, None, "default");
let config = aws_config::defaults(BehaviorVersion::latest())
.region("us-east-1")
.credentials_provider(cred)
.timeout_config(TimeoutConfig::disabled())
.retry_config(RetryConfig::disabled())
.stalled_stream_protection(StalledStreamProtectionConfig::disabled())
.identity_cache(IdentityCache::no_cache())
.load()
.await;
let client = Client::new(&config); It panics with:
|
@yuchanns you can configure a custom time source with let epoch = (js_sys::Date::now() / 1_000.0) as u64;
aws_config::defaults(aws_config::BehaviorVersion::v2023_11_09())
…
.time_source(aws_smithy_async::time::StaticTimeSource::from_secs(epoch)) But you can also provide a value of your own type implementing the |
I've been trying to get this working, without a lot of luck. Is anybody successfully using this with wasip2? If so, perhaps we could have a "hello world" example using, e.g., |
@jeffparsons there is a WASI 0.2 compliant HTTP connector in the I have used it successfully in both Wasmtime and in Node (with |
❗ Are you interested in using the Rust SDK in Web Assembly? Please comment on this issue with more details about your potential use case! ❗
Community Note
Tell us about your request
The AWS SDK should be usable from a Rust WebAssembly program.
Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?
I'm building a web application with core logic written in Rust and compiled to Wasm, and I'd like to connect with AWS APIs such as S3 from my Rust program without having to drop down to JavaScript too often (if ever).
Are you currently working around this issue?
Since I'm targeting the web and there's already an extensive AWS SDK for JavaScript, I can delegate all the AWS bits to JavaScript.
The text was updated successfully, but these errors were encountered: