Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/lint-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
if: steps.changed-files.outputs.any_changed == 'true'
with:
toolchain: "1.80.1"
toolchain: "1.81.0"
components: clippy, rustfmt
- name: Set Environment
if: steps.changed-files.outputs.any_changed == 'true'
Expand Down
4 changes: 4 additions & 0 deletions rustv1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ hosted on [Amazon Elastic Container Registry (ECR)](https://docs.aws.amazon.com/
with all Rust examples with dependencies pre-resolved, allowing you to explore
these examples in an isolated environment.

## Updating Rust Version

If a rust version releases (most likely) a clippy or has some other breaking change, the Weathertop dashboard will go red. The easiest way to handle this is to run `./tools/set_rust_version.py [rust_version]` (using a venv with the appropriate requirements), creating a commit with those updates, and then running `cargo clippy --fix` in the appropriate folder before making a second commit with those fixes. Line numbers will certainly change, so don't forget to run WRITEME - `./.tools/readmes/.venv/bin/python ./.tools/readmes/writeme.py --languages Rust:1`.

## Contributing

When adding or modifying Rust code examples, follow common Rust best practices.
Expand Down
2 changes: 1 addition & 1 deletion rustv1/cross_service/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This should be kept in sync with https://github.com/awslabs/aws-sdk-rust#supported-rust-versions-msrv
[toolchain]
channel = "1.80.1"
channel = "1.81.0"
2 changes: 1 addition & 1 deletion rustv1/examples/aurora/src/aurora_scenario/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ async fn test_scenario_clean_up_errors() {
assert!(clean_up.is_err());
let errs = clean_up.unwrap_err();
assert_eq!(errs.len(), 2);
assert_matches!(errs.get(0), Some(ScenarioError {message, context: _}) if message == "Failed to check instance state during deletion");
assert_matches!(errs.first(), Some(ScenarioError {message, context: _}) if message == "Failed to check instance state during deletion");
assert_matches!(errs.get(1), Some(ScenarioError {message, context: _}) if message == "Failed to check cluster state during deletion");
});

Expand Down
46 changes: 23 additions & 23 deletions rustv1/examples/iam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,30 @@ Code examples that show you how to perform the essential operations within a ser

Code excerpts that show you how to call individual service functions.

- [AttachRolePolicy](src/iam-service-lib.rs#L221)
- [AttachUserPolicy](src/iam-service-lib.rs#L236)
- [CreateAccessKey](src/iam-service-lib.rs#L270)
- [AttachRolePolicy](src/iam-service-lib.rs#L190)
- [AttachUserPolicy](src/iam-service-lib.rs#L205)
- [CreateAccessKey](src/iam-service-lib.rs#L239)
- [CreatePolicy](src/iam-service-lib.rs#L18)
- [CreateRole](src/iam-service-lib.rs#L65)
- [CreateServiceLinkedRole](src/iam-service-lib.rs#L417)
- [CreateUser](src/iam-service-lib.rs#L87)
- [DeleteAccessKey](src/iam-service-lib.rs#L294)
- [DeletePolicy](src/iam-service-lib.rs#L338)
- [DeleteRole](src/iam-service-lib.rs#L160)
- [DeleteServiceLinkedRole](src/iam-service-lib.rs#L176)
- [DeleteUser](src/iam-service-lib.rs#L191)
- [DeleteUserPolicy](src/iam-service-lib.rs#L349)
- [DetachRolePolicy](src/iam-service-lib.rs#L321)
- [DetachUserPolicy](src/iam-service-lib.rs#L253)
- [GetAccountPasswordPolicy](src/iam-service-lib.rs#L436)
- [GetRole](src/iam-service-lib.rs#L113)
- [ListAttachedRolePolicies](src/iam-service-lib.rs#L446)
- [ListGroups](src/iam-service-lib.rs#L398)
- [ListPolicies](src/iam-service-lib.rs#L366)
- [ListRolePolicies](src/iam-service-lib.rs#L467)
- [ListRoles](src/iam-service-lib.rs#L95)
- [ListSAMLProviders](src/iam-service-lib.rs#L486)
- [ListUsers](src/iam-service-lib.rs#L123)
- [CreateRole](src/iam-service-lib.rs#L34)
- [CreateServiceLinkedRole](src/iam-service-lib.rs#L386)
- [CreateUser](src/iam-service-lib.rs#L56)
- [DeleteAccessKey](src/iam-service-lib.rs#L263)
- [DeletePolicy](src/iam-service-lib.rs#L307)
- [DeleteRole](src/iam-service-lib.rs#L129)
- [DeleteServiceLinkedRole](src/iam-service-lib.rs#L145)
- [DeleteUser](src/iam-service-lib.rs#L160)
- [DeleteUserPolicy](src/iam-service-lib.rs#L318)
- [DetachRolePolicy](src/iam-service-lib.rs#L290)
- [DetachUserPolicy](src/iam-service-lib.rs#L222)
- [GetAccountPasswordPolicy](src/iam-service-lib.rs#L405)
- [GetRole](src/iam-service-lib.rs#L82)
- [ListAttachedRolePolicies](src/iam-service-lib.rs#L415)
- [ListGroups](src/iam-service-lib.rs#L367)
- [ListPolicies](src/iam-service-lib.rs#L335)
- [ListRolePolicies](src/iam-service-lib.rs#L436)
- [ListRoles](src/iam-service-lib.rs#L64)
- [ListSAMLProviders](src/iam-service-lib.rs#L455)
- [ListUsers](src/iam-service-lib.rs#L92)


<!--custom.examples.start-->
Expand Down
64 changes: 33 additions & 31 deletions rustv1/examples/iam/src/iam-service-lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,6 @@ pub async fn create_policy(
}
// snippet-end:[rust.example_code.iam.service.create_policy]

#[cfg(test)]
mod test_create_policy {
use crate::create_policy;
use http::StatusCode;
use sdk_examples_test_utils::single_shot_client;

#[tokio::test]
async fn test_create_policy_success() {
let client = single_shot_client!(
sdk: aws_sdk_iam,
status: StatusCode::OK,
response: include_str!("../testing/test_create_policy_response_success.xml")
);

let response = create_policy(&client, "{}", "test_role").await;
assert!(response.is_ok());
}

#[tokio::test]
async fn test_create_policy_failed() {
let client = single_shot_client!(
sdk: aws_sdk_iam,
status: StatusCode::BAD_REQUEST,
response: include_str!("../testing/test_create_policy_response_malformed.xml")
);

let response = create_policy(&client, "{}", "test_role").await;
assert!(response.is_err());
}
}

// snippet-start:[rust.example_code.iam.service.create_role]
pub async fn create_role(
client: &iamClient,
Expand Down Expand Up @@ -493,4 +462,37 @@ pub async fn list_saml_providers(
}
// snippet-end:[rust.example_code.iam.service.list_saml_providers]

// snippet-start:[rust.example_code.iam.service.create_policy.test]
#[cfg(test)]
mod test_create_policy {
use crate::create_policy;
use http::StatusCode;
use sdk_examples_test_utils::single_shot_client;

#[tokio::test]
async fn test_create_policy_success() {
let client = single_shot_client!(
sdk: aws_sdk_iam,
status: StatusCode::OK,
response: include_str!("../testing/test_create_policy_response_success.xml")
);

let response = create_policy(&client, "{}", "test_role").await;
assert!(response.is_ok());
}

#[tokio::test]
async fn test_create_policy_failed() {
let client = single_shot_client!(
sdk: aws_sdk_iam,
status: StatusCode::BAD_REQUEST,
response: include_str!("../testing/test_create_policy_response_malformed.xml")
);

let response = create_policy(&client, "{}", "test_role").await;
assert!(response.is_err());
}
}
// snippet-end:[rust.example_code.iam.service.create_policy.test]

// snippet-end:[rust.example_code.iam.scenario_getting_started.lib]
2 changes: 1 addition & 1 deletion rustv1/examples/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This should be kept in sync with https://github.com/awslabs/aws-sdk-rust#supported-rust-versions-msrv
[toolchain]
channel = "1.80.1"
channel = "1.81.0"
Loading