Log in to access Rust Adventure videos!

Lesson Details

Create a new directory.

mkdir aws-dynamo-pokemon

We’ll use this directory to start a cargo workspace, keeping our Rust code in ./crates and our CDK code in ./infra.

mkdir crates

In the root of our project we’ll create a new Cargo.toml that points at any new directory we put in ./crates.

[workspace]
members = ["crates/*"]

Then we’ll make a new crate using Cargo.

cargo new crates/upload-pokemon-data

This will leave you with a directory structure that looks like this.

❯ tree .
.
├── Cargo.toml
└── crates
    └── upload-pokemon-data
        ├── Cargo.toml
        └── src
            └── main.rs

3 directories, 3 files

From the root of our project we can build and run the upload-pokemon-data binary. As long as upload-pokemon-data is the only binary in our workspace, we can run cargo run and cargo will know what to do. As soon as we have more than that, we’ll need to specify the binary to run which we can do with --bin.

❯ cargo run --bin upload-pokemon-data
   Compiling upload-pokemon-data v0.1.0 (/aws-dynamo-pokemon/crates/upload-pokemon-data)
    Finished dev [unoptimized + debuginfo] target(s) in 0.58s
     Running `target/debug/upload-pokemon-data`
Hello, world!

Finally, we’ll need to get the pokemon.csv file. Download it from here on GitHub and put it in the upload-pokemon-data directory. We’ll include it in our binary later.