Follow this guide to deploy your first function in minutes
Start by installing the Faasta CLI tool using cargo:
cargo install cargo-faasta
This will install the cargo-faasta
subcommand that you'll use to create, build, and deploy your functions.
Authenticate with your GitHub account to deploy functions:
cargo faasta login
This will open a browser window to authenticate with GitHub. Once authenticated, you'll be able to deploy functions to Faasta.
Create a new Faasta function project:
cargo faasta new my-function
This will generate a new directory with a basic Faasta function template. Alternatively, you can initialize an existing directory:
mkdir my-function
cd my-function
cargo faasta init
Edit the src/lib.rs
file to customize your function:
use spin_sdk::http::{IntoResponse, Response};
use spin_sdk::http_component;
#[http_component]
fn hello_world(req: http::Request<()>) -> anyhow::Result<impl IntoResponse> {
Ok(Response::builder()
.status(200)
.header("content-type", "text/plain")
.body("Hello from Faasta!")
.build())
}
Build your function for WebAssembly:
cargo faasta build
This compiles your Rust code to a WebAssembly module that can be deployed to Faasta.
Deploy your function to Faasta:
cargo faasta deploy
Once deployed, your function will be available at https://my-function.faasta.xyz
(where "my-function" is the name of your function).