* Keeping awsr in sync with new AWS CLI v2 releases through a daily GitHub Actions workflow :properties: :export_file_name: generated/contents/blog/2026/0fe13b :export_date: 2026-11-27 18:26 :export_updated: 2026-11-27 18:26 :export_lang: en :export_original: /blog/2026/7fe084 :export_tags: rust aws aws-cli github-actions nix ci differential-testing rust-awscli :end: =awsr=, the Rust CLI from [[https://s.conao3.com/blog/2026/87e5cb][my previous post]], returns output byte for byte identical to the AWS CLI v2, so to keep returning the same output, =awsr= has to move to each new AWS CLI version as it comes out. The AWS CLI [[https://github.com/aws/aws-cli/tags][released 20 times]] in the 36 days from 2026-09-30 to 2026-11-05, with a new version almost every weekday, so I set up GitHub Actions to run this update every day. For each new version, the workflow makes the change that bumps the version, compares =awsr= with the AWS CLI, and opens a PR with the results. [[github:conao3/rust-awscli::Rust][A fast, output-compatible Rust reimplementation of the AWS CLI v2]] The image below shows the [[https://github.com/conao3/rust-awscli/pull/6][PR that the workflow created]] when 2.39.5 came out, with a table of the comparison results before I ported anything. [[./resources/public/img/7fe084-pr.png]] ** What changes when you bump the version =awsr= follows one fixed AWS CLI version. I write that version number in =models/VERSION=, and =flake.nix= pulls in the AWS CLI source and the official Linux installer of the same version with Nix. Bumping the AWS CLI version therefore changes three things: - botocore models: the service and operation definitions that =awsr= embeds in its binary. - Expected test values: the command table, the hashes of the argument tables, the help documents, and the waiter descriptions, which I generate from the AWS CLI models and source. - AWS CLI code changes: changes to commands with their own logic and to authentication. In the AWS CLI [[https://github.com/aws/aws-cli/blob/2.39.5/CHANGELOG.rst][changelog]], these are the entries other than =api-change=, such as =enhancement= and =bugfix=. A script can regenerate the models and expected values from the AWS CLI, but I have to port code changes to Rust. ** The version bump script [[https://github.com/conao3/rust-awscli/blob/master/scripts/update-reference.sh][=scripts/update-reference.sh=]] regenerates the models and expected values. #+begin_src console $ scripts/update-reference.sh 2.39.5 #+end_src The script runs these steps in order: 1. Fetch the hashes of the AWS CLI source and installer with =nix-prefetch-url=, and update the version and hashes in =flake.nix=. 2. Enter the devShell of the new version, re-import the models with =scripts/vendor-models.sh=, and set the three data crates that hold the models to the AWS CLI version. 3. Regenerate the command table, the hashes of the argument tables, the help documents, and the waiter descriptions from the AWS CLI source. 4. Format the code with =nix fmt=. Before I relied on the scripts that generate the expected values, I ran them on the 2.39.3 source from before the update and checked that they reproduced the committed expected values. ** The daily workflow The [[https://github.com/conao3/rust-awscli/blob/master/.github/workflows/reference.yml][=Reference= workflow]] looks up the latest AWS CLI tag every day at 12:00 UTC. If it finds a version newer than =models/VERSION=, it bumps the version with the script above and runs these four checks: - =make check=: runs fmt, clippy, and the tests. - [[https://github.com/conao3/rust-awscli/tree/master/difftest][Differential tests]]: run every operation of the services whose models changed in both =awsr= and the AWS CLI, and compare the output and the requests. - Help comparison: on the help pages of the services whose models changed, replace the name =awsr= with =aws= and compare byte for byte. On pages where the longer name moved the line wrapping, compare with the wrapping removed. - Scenario and authentication comparison: compare hand-written scenarios, scenarios for the =s3= commands, and authentication commands such as =configure= and =sso login=. After the checks, the workflow pushes the =reference/= branch and opens a PR with the results table. The PR body also lists the AWS CLI changelog entries other than =api-change=. If any check fails, or if =scripts/classify-reference-changes.sh= finds files to port in the diff of the AWS CLI source, the workflow marks the PR as a draft. If nothing needs porting and all checks pass, the workflow merges the PR and starts the =Release= workflow as well. [[./resources/public/img/7fe084-flow.svg]] ** Comparing only the services that changed A differential test run over all services compares more than 230,000 combinations against the AWS CLI, and without a cache of AWS CLI results it took about 100 minutes on my 14-core PC. The =ubuntu-latest= runner that GitHub Actions gives public repositories has [[https://docs.github.com/en/actions/reference/runners/github-hosted-runners#standard-github-hosted-runners-for-public-repositories][4 cores]], so I can't run the full set every day. The daily comparison covers only the services whose models changed. From 2.39.3 to 2.39.5, the models of 34 services changed, and their operations came to 48,504 combinations. The [[https://github.com/conao3/rust-awscli/actions/runs/42182624705][run]] that bumped =awsr= to 2.39.5 took about 71 minutes in total: about 44 minutes for the differential tests including the release build, and about 18 minutes for comparing 4,189 help pages. ** What I ported in 2.39.5 The PR from 2.39.3 to 2.39.5 is [[https://github.com/conao3/rust-awscli/pull/6][conao3/rust-awscli#6]], and the [[https://github.com/aws/aws-cli/blob/2.39.5/CHANGELOG.rst][changelog]] of 2.39.4 and 2.39.5 had nine entries other than =api-change=. I ported these four of them to =awsr=: - Stop sending Bearer authentication tokens to endpoints other than HTTPS. - Accept =--tags= on =s3 cp=, =s3 mv=, and =s3 sync= for transfers from local files to S3. - Count a transfer that fails with =PreconditionFailed= as a skipped existing file only if the transfer has =--no-overwrite=. - Set the permissions of the config file that =deploy install= writes to 600. The AWS CLI =s3= commands have two transfer implementations, classic in Python and crt on the AWS Common Runtime (CRT), and you pick one with [[https://docs.aws.amazon.com/cli/latest/topic/s3-config.html#preferred-transfer-client][the preferred_transfer_client setting]]. The other five entries cover the CRT transfer client and =aws update= on Windows. =awsr= implements only the classic transfer client and has no =update= command yet, so those five need no porting. The differential tests for =account-access-runtime=, a service added in 2.39.5, caught the Bearer authentication change. 24 cases for this service didn't match: the AWS CLI stopped with =Bearer authorization requires an HTTPS endpoint.=, while =awsr= sent the request. If I merged this change into master first, a different service that uses Bearer authentication would stop matching the 2.39.3 AWS CLI, so I port changes that depend on the AWS CLI version inside the version bump PR. I merged master into the PR branch, added the porting commits on top, and merged the PR after all comparisons passed on my machine. The existing scenarios can't compare =--tags=, so I added six =s3= scenarios. If I take out the tagging code in =awsr= for a moment, the four upload scenarios among the six fail, so the scenarios do compare the tags. ** A difference that showed up only on the runner In the [[https://github.com/conao3/rust-awscli/actions/runs/42182624705][run]] that created the 2.39.5 PR, three =deploy install= and =deploy uninstall= scenarios failed, while the same scenarios matched on my PC. =deploy install= refuses to run on EC2 instances, and it asks the metadata service at =169.254.169.254= to find out whether it runs on EC2. [[https://docs.github.com/en/actions/concepts/runners/github-hosted-runners#cloud-hosts-used-by-github-hosted-runners][GitHub Actions runners]] run on Azure or AWS, and the [[https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service#security-and-authentication][Azure metadata service]] uses the same address, but it rejects requests without the =Metadata: true= header. The AWS CLI [[https://github.com/aws/aws-cli/blob/2.39.5/awscli/customizations/codedeploy/utils.py#L105-L121][sends an HTTP GET with Python's urlopen]] and concludes it isn't on EC2 when it gets an error response. =awsr= only checked whether a TCP connection succeeded, so on a runner where something answered at this address, it concluded it was on EC2. I changed =awsr= to [[https://github.com/conao3/rust-awscli/commit/3b5e3b9][send an HTTP GET]] too and to treat the host as EC2 only when the response status is below 400. To test this on my machine, I started a server that returns 400 or 200 at =169.254.169.254= inside a user namespace made with =unshare -rnm=, and replaced =/etc/lsb-release= with Ubuntu's. With either status, the AWS CLI and =awsr= print the same output.