This example shows how to deploy a simple Rust webserver on Fly and AWS.
Warning the Fly Terraform provider is largely unmaintained and has numerous bugs at the moment. The initial deploy should hopefully work, but if you run into issues you may need to look for patches in the pull requests there.
The Terraform stack generation is done in build.rs
.
This requires the musl
target to create binary to add to the docker image. You can set up that target by running rustup target add x86_64-unknown-linux-musl
.
To deploy the example:
-
Do
cargo build
if the stack file isn't already generated -
Move to
deploy/tf
-
Create
input.json
with the following contents:{ "aws_region": "us-east-1", "fly_region": "ord", "domain": "helloworld.example.com", "domain_zone_id": "Z...", "aws_public_key": "AKIA...", "aws_secret_key": "...", "fly_token": "..." }
(replacing the example values above with your own)
-
Run
terraform init
thenterraform apply --var-file input.json
To update the deployment, just run terraform apply ...
again. To destroy the website do terraform destroy ...
.