Skip to content
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

Add aws-smithy-wasm crate with WASI http client #3409

Merged
merged 90 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
4e4fd4a
feat: make outgoing request based on wasi-http proposal
eduardomourar Mar 24, 2023
04c76bd
feat: support wasi in default configuration
eduardomourar Mar 31, 2023
e3547ca
chore: use bytes body with wasi-http
eduardomourar Apr 4, 2023
7c33972
chore: load credentials from environment variables
eduardomourar Apr 4, 2023
528d0f8
chore: run wasm integration tests
eduardomourar Apr 4, 2023
1ddbd45
chore: prepare git folder within cargo
eduardomourar Apr 4, 2023
c4c306f
chore(ci): update wasmtime to v8.0.0
eduardomourar Apr 23, 2023
3482726
chore: update to latest commit in wasi-http crate
eduardomourar Apr 23, 2023
17927d9
chore: separate variable for listed buckets
eduardomourar Apr 23, 2023
4691918
chore: set aws credentials env variables to empty string
eduardomourar Apr 23, 2023
24a56f0
chore: update wasi-http crate
eduardomourar Apr 27, 2023
d91a56b
chore: set component-model feature flag
eduardomourar Apr 27, 2023
dfe6aa0
chore: use wasi-preview2-prototype crate
eduardomourar Apr 29, 2023
904f002
chore: remove wasi dependency
eduardomourar Apr 29, 2023
cba7b09
chore: install wasmtime with component model feature
eduardomourar May 3, 2023
f6cb13a
chore: use default credentials provider chain
eduardomourar May 25, 2023
99418c1
feat: move logic to aws-smithy-wasm crate
eduardomourar May 25, 2023
77a4ac8
chore: use wasm crate in aws config
eduardomourar May 25, 2023
ee489fe
chore: re-enable timeout and retry config
eduardomourar May 25, 2023
ad01461
chore(smithy-async): compile to wasi with rt-tokio feature
eduardomourar May 25, 2023
0e93edb
chore: update wasi-preview2-prototype to v0.0.2
eduardomourar Aug 19, 2023
a5e858f
chore: run list objects instead
eduardomourar Aug 19, 2023
46e0c85
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar Aug 19, 2023
53e84df
chore: fix misconfigured imports
eduardomourar Aug 29, 2023
ea29d56
chore: simplify wasm tests
eduardomourar Aug 29, 2023
bd15545
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar Aug 29, 2023
a16bcc1
chore: remove cargo-wasi references
eduardomourar Aug 29, 2023
7d8638c
chore: remove unnecessary sparse registry config
eduardomourar Aug 29, 2023
b9028f3
chore: use temporarily wasmtime from git
eduardomourar Aug 29, 2023
69f50fe
chore: remove wasi sleep
eduardomourar Aug 29, 2023
f8d14af
feat(wasm): define top level setter for connector
eduardomourar Aug 29, 2023
0ac58ea
chore: remove default wasi connector from aws-config
eduardomourar Aug 29, 2023
f371193
chore: update wasm integration tests
eduardomourar Aug 29, 2023
1318f9a
chore: setup tracing in aws-smithy-wasm
eduardomourar Aug 29, 2023
5ca6108
chore: some extra clean up
eduardomourar Aug 29, 2023
d8bde29
Merge branch 'main' into feat/default-wasi-http
eduardomourar Aug 29, 2023
044d37a
chore: document wasi connector function
eduardomourar Aug 30, 2023
917e001
chore: ensure webassembly test can compile to non-wasm target
eduardomourar Aug 30, 2023
96c4e4e
Merge branch 'main' into feat/default-wasi-http
eduardomourar Aug 30, 2023
853e538
Merge branch 'main' into feat/default-wasi-http
eduardomourar Sep 6, 2023
6d6cfdb
chore: remove unnecessary tracing in adapter
eduardomourar Sep 8, 2023
46f6bf8
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar Sep 8, 2023
93f7ffc
chore: update wasmtime to v13
eduardomourar Sep 20, 2023
db6e371
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar Sep 20, 2023
3e5ad29
Revert "chore: prepare git folder within cargo"
eduardomourar Sep 21, 2023
00872d1
Merge branch 'main' into feat/default-wasi-http
eduardomourar Sep 21, 2023
ee71a78
Merge branch 'main' into feat/default-wasi-http
eduardomourar Sep 27, 2023
8f4d186
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar Sep 28, 2023
1aacca3
Merge branch 'main' into feat/default-wasi-http
eduardomourar Sep 29, 2023
023ba22
Merge branch 'main' into feat/default-wasi-http
eduardomourar Oct 4, 2023
f98b4cb
Merge branch 'main' into feat/default-wasi-http
ysaito1001 Oct 9, 2023
843a4d7
Apply fixes for breaking changes introduced by the HttpClient refactor
jdisanti Oct 10, 2023
8bf2c15
Merge branch 'main' of github.com:smithy-lang/smithy-rs into feat/def…
rcoh Jan 11, 2024
086f557
Merge branch 'main' into landonxjames/wasi-2-http
landonxjames Feb 9, 2024
8a32aff
Reimplemented SDK's HttpConnector with WASI types
landonxjames Feb 11, 2024
83f079a
Wasm connector is building now
landonxjames Feb 12, 2024
a6cdb9f
Adding http-1x feature to runtime-api dependency
landonxjames Feb 12, 2024
e5feef2
Updating tests for wasi http connector
landonxjames Feb 12, 2024
f621e61
Updating wasi http to drop child resources
landonxjames Feb 13, 2024
b102e2b
Basic test setup for wasi should work in CI
landonxjames Feb 13, 2024
bb8bb4d
Update CHANGELOG.next.toml
landonxjames Feb 14, 2024
6d39c43
Merge branch 'main' into landonxjames/wasi-2-http
landonxjames Feb 14, 2024
d0feecb
Update cargo-component to install nightly for MSRV
landonxjames Feb 14, 2024
9a653b3
Lint updates
landonxjames Feb 14, 2024
2701297
CI updates
landonxjames Feb 14, 2024
02632f2
Update CHANGELOG.next.toml
landonxjames Feb 14, 2024
1df0bf6
Update rust-runtime/aws-smithy-wasm/Cargo.toml
landonxjames Feb 14, 2024
23db87e
Update rust-runtime/aws-smithy-wasm/Cargo.toml
landonxjames Feb 14, 2024
b2134c7
Update rust-runtime/aws-smithy-wasm/src/wasi.rs
landonxjames Feb 14, 2024
1005865
Update rust-runtime/aws-smithy-wasm/src/wasi.rs
landonxjames Feb 14, 2024
68ae686
Apply suggestions from code review
landonxjames Feb 14, 2024
a38ef6b
Updating build scripts with PR feedback
landonxjames Feb 14, 2024
b2ff222
Updating error handling
landonxjames Feb 15, 2024
bf14237
Update WASI HTTP client
landonxjames Feb 16, 2024
cd091fb
First pass at a wasm canary
landonxjames Feb 19, 2024
43f9525
Merge branch 'smithy-lang:main' into landonxjames/wasi-2-http
landonxjames Feb 19, 2024
42c3b4f
Slightly farther in getting wasmtime to run
landonxjames Feb 19, 2024
3fc1aa8
Wasm canary test works locally
landonxjames Feb 20, 2024
352cdfd
Add WasmSleep struct to wasm crate
landonxjames Feb 20, 2024
ade60da
Cleaning up some of the canary committed
landonxjames Feb 20, 2024
7eeb60d
Added wasm_canary to the canary runner
landonxjames Feb 20, 2024
3d1b9b4
Fixing canary builder tests
landonxjames Feb 21, 2024
147a26a
Increase canary timeouts wasm canary is slow
landonxjames Feb 21, 2024
0c41440
Apply suggestions from code review
landonxjames Feb 26, 2024
bd2006f
Merge branch 'main' into landonxjames/wasi-2-http
landonxjames Feb 26, 2024
c883aad
Updates from PR feedback
landonxjames Feb 26, 2024
a778a18
Bump version of wasmtime-cli in Dockerfile
landonxjames Feb 26, 2024
6a174b3
Adding allowed external types to aws-smity-wasm
landonxjames Feb 27, 2024
f6720a3
Update rust-runtime/aws-smithy-wasm/src/wasi.rs
landonxjames Feb 27, 2024
778bfb0
Update CHANGELOG.next.toml
jdisanti Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@
# meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"}
# author = "rcoh"

[[aws-sdk-rust]]
message = "The MSRV has been increase to 1.74.1"
references = ["smithy-rs#3410"]
meta = { "bug" = false, "breaking" = false, tada = false }
author = "rcoh"

[[aws-sdk-rust]]
message = "EKS Pod Identity is now supported as part of the default ECS credential provider."
references = ["smithy-rs#3416"]
meta = { "breaking" = false, "bug" = false, "tada" = true }
author = "jackkleeman"

[[smithy-rs]]
message = "Add aws-smithy-wasm crate to enable SDK use in wasi compliant environments"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we call the crate aws-smithy-wasi, or do you envision this being used for all WASM runtime environments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the moment everything in here is wasi related, but I can see a future where more wasm tooling is published and keeping both wasm/wasi functionality in the same crate makes sense to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up adding an AsyncSleep impl in this crate too and that should work for any Wasm environment, WASI compliant or not. Its under a wasm module in the crate, so now I think keep the name definitely makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up adding an AsyncSleep impl in this crate too and that should work for any Wasm environment, WASI compliant or not. Its under a wasm module in the crate, so now I think keep the name definitely makes sense

references = ["smithy-rs#2087", "smithy-rs#2520", "smithy-rs#3409"]
meta = { "breaking" = false, "tada" = true, "bug" = false, "target" = "client"}
author = "landonxjames"
5 changes: 4 additions & 1 deletion aws/rust-runtime/aws-config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[package]
name = "aws-config"
version = "0.0.0-smithy-rs-head"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>", "Russell Cohen <rcoh@amazon.com>"]
authors = [
"AWS Rust SDK Team <aws-sdk-rust@amazon.com>",
"Russell Cohen <rcoh@amazon.com>",
]
description = "AWS SDK config and credential provider implementations."
edition = "2021"
exclude = ["test-data/*", "integration-tests/*"]
Expand Down
1 change: 1 addition & 0 deletions aws/sdk/integration-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Cargo.lock
target/
webassembly/src/bindings.rs
8 changes: 7 additions & 1 deletion aws/sdk/integration-tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ for f in *; do
echo
echo "Testing ${f}..."
echo "###############"
cargo test --manifest-path "${f}/Cargo.toml" --all-features
if [ "$f" != "webassembly" ]; then
cargo test --manifest-path "${f}/Cargo.toml" --all-features
else
# The webassembly tests use a custom runner set in config.toml that
# is not picked up when running the tests outside of the package
cd webassembly && cargo component test --all-features --all-targets && cd ..
fi
fi
done
6 changes: 6 additions & 0 deletions aws/sdk/integration-tests/webassembly/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ target = "wasm32-wasi"

[target.wasm32-wasi]
rustflags = ["-C", "opt-level=1"]
runner = [
"wasmtime",
"-C", "cache=n",
"-S", "preview2=y",
"-S", "http=y"
]
34 changes: 25 additions & 9 deletions aws/sdk/integration-tests/webassembly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
[package]
name = "webassembly"
version = "0.1.0"
authors = ["Eduardo Rodrigues <16357187+eduardomourar@users.noreply.github.com>"]
authors = [
"Eduardo Rodrigues <16357187+eduardomourar@users.noreply.github.com>",
]
description = """
These tests ensure that things will fail (or not fail) as expected
when target is set to wasm32-wasi for all SDK and runtime crates.
Expand All @@ -12,20 +14,34 @@ license = "Apache-2.0"
repository = "https://github.com/smithy-lang/smithy-rs"
publish = false

[lib]
crate-type = ["cdylib"]

[features]
default = ["test-util"]
test-util = []
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
aws-config = { path = "../../build/aws-sdk/sdk/aws-config", default-features = false, features = ["rt-tokio", "behavior-version-latest"]}
[target.'cfg(target_family = "wasm")'.dependencies]
aws-config = { path = "../../build/aws-sdk/sdk/aws-config", default-features = false, features = [
"rt-tokio",
"behavior-version-latest"
] }
aws-credential-types = { path = "../../build/aws-sdk/sdk/aws-credential-types", features = ["hardcoded-credentials"] }
aws-sdk-s3 = { path = "../../build/aws-sdk/sdk/s3", default-features = false }
aws-smithy-http = { path = "../../build/aws-sdk/sdk/aws-smithy-http" }
aws-smithy-runtime = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime", features = ["client"] }
aws-smithy-runtime-api = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["client"] }
aws-smithy-types = { path = "../../build/aws-sdk/sdk/aws-smithy-types" }
aws-types = { path = "../../build/aws-sdk/sdk/aws-types" }
http = "0.2.8"
tokio = { version = "1.24.2", features = ["macros", "rt"] }
tower = "0.4.13"
aws-smithy-wasm = { path = "../../build/aws-sdk/sdk/aws-smithy-wasm" }
http = "0.2.9"
tokio = { version = "1.32.0", features = ["macros", "rt"] }

[target.'cfg(all(target_family = "wasm", target_os = "wasi"))'.dependencies]
wit-bindgen = { version = "0.16.0", features = ["macros", "realloc"] }


[lib]
crate-type = ["cdylib"]

# metadata used by cargo-component to identify which wit world to embed in the binary
[package.metadata.component]
package = "aws:component"
32 changes: 0 additions & 32 deletions aws/sdk/integration-tests/webassembly/src/default_config.rs

This file was deleted.

62 changes: 0 additions & 62 deletions aws/sdk/integration-tests/webassembly/src/http.rs

This file was deleted.

54 changes: 54 additions & 0 deletions aws/sdk/integration-tests/webassembly/src/http_client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

use aws_config::retry::RetryConfig;
use aws_sdk_s3::operation::list_objects_v2::builders::ListObjectsV2FluentBuilder;
use aws_sdk_s3::Client;
use aws_smithy_types::timeout::TimeoutConfig;
use aws_smithy_wasm::wasi::WasiHttpClientBuilder;

pub(crate) async fn get_default_wasi_config() -> aws_config::SdkConfig {
let http_client = WasiHttpClientBuilder::new().build();
aws_config::from_env()
.region("us-east-2")
.timeout_config(TimeoutConfig::disabled())
.retry_config(RetryConfig::disabled())
.no_credentials()
.http_client(http_client)
.load()
.await
}

#[tokio::test]
pub async fn test_default_config() {
let shared_config = get_default_wasi_config().await;
let client = aws_sdk_s3::Client::new(&shared_config);
assert_eq!(client.config().region().unwrap().to_string(), "us-east-2")
}

async fn s3_list_objects_operation() -> ListObjectsV2FluentBuilder {
let shared_config = get_default_wasi_config().await;
let client = Client::new(&shared_config);
let operation = client
.list_objects_v2()
.bucket("nara-national-archives-catalog")
.delimiter("/")
.prefix("authority-records/organization/")
.max_keys(5);

operation
}

// Test constructing an operation using an SdkConfig with a WASI http client
// We do not send the request to keep these tests sandboxable, a full test of
// the client is in the SDK canary.
#[tokio::test]
pub async fn test_operation_construction() {
let operation = s3_list_objects_operation().await;
assert_eq!(
operation.get_bucket(),
&Some("nara-national-archives-catalog".to_string())
);
}
12 changes: 5 additions & 7 deletions aws/sdk/integration-tests/webassembly/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

mod default_config;
mod http;
mod list_buckets;
#![allow(dead_code)]

#[tokio::main(flavor = "current_thread")]
pub async fn main() {
crate::list_buckets::s3_list_buckets().await
}
#[cfg(target_family = "wasm")]
mod http_client;
#[cfg(all(target_family = "wasm", target_os = "wasi"))]
mod wasi;
20 changes: 0 additions & 20 deletions aws/sdk/integration-tests/webassembly/src/list_buckets.rs

This file was deleted.

32 changes: 32 additions & 0 deletions aws/sdk/integration-tests/webassembly/src/wasi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// Needed for WASI-compliant environment as it expects specific functions
// to be exported such as `cabi_realloc`, `_start`, etc.

wit_bindgen::generate!({
inline: "
package aws:component;

interface run {
run: func() -> result;
}

world main {
export run;
}
",
exports: {
"aws:component/run": Component
}
});

struct Component;

impl exports::aws::component::run::Guest for Component {
fn run() -> Result<(), ()> {
Ok(())
}
}
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/CrateSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ object CrateSet {
"aws-smithy-runtime-api",
"aws-smithy-types",
"aws-smithy-types-convert",
"aws-smithy-wasm",
"aws-smithy-xml",
).map { Crate(it, version(it)) }

Expand Down
1 change: 1 addition & 0 deletions rust-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ members = [
"aws-smithy-runtime-api",
"aws-smithy-types",
"aws-smithy-types-convert",
"aws-smithy-wasm",
"aws-smithy-mocks-experimental",
"aws-smithy-xml",
]
29 changes: 29 additions & 0 deletions rust-runtime/aws-smithy-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "aws-smithy-wasm"
version = "0.1.0"
authors = [
"AWS Rust SDK Team <aws-sdk-rust@amazon.com>",
"Eduardo Rodrigues <16357187+eduardomourar@users.noreply.github.com>",
]
description = "Smithy WebAssembly configuration for smithy-rs."
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/awslabs/smithy-rs"

[dependencies]
aws-smithy-runtime-api = { path = "../aws-smithy-runtime-api", features = ["http-1x"]}
aws-smithy-http = { path = "../aws-smithy-http" }
aws-smithy-types = { path = "../aws-smithy-types" }
bytes = "1"
http = "1.0.0"
tracing = "0.1.40"
# Note the wasi crate will only build for target wasm32-wasi, but having a target
# statement here breaks some of the CI tests, so we leave it with the rest of the deps
wasi = "0.12.0+wasi-0.2.0"

[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata
Loading
Loading