Skip to content

Commit

Permalink
Add some Terraform to describe the dynamodb table
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
rtyler committed Nov 12, 2023
1 parent 6667870 commit 927e348
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
dynamodb lock
=============
# dynamodb lock

Dynamodb based distributed lock implemented in pure Rust. The design is largely
inspired by
Expand All @@ -10,8 +9,7 @@ implement PUT if absence semantic for concurrent S3 writes. It is considered
production ready and battle tested through the
[kafka-delta-ingest](https://github.com/delta-io/kafka-delta-ingest) project.

Usage
-----
## Usage

```rust
let region = dynamodb_lock::Region::default();
Expand All @@ -32,3 +30,38 @@ lock_client.release_lock(&lock).await?;

For real world example, see
https://github.com/delta-io/delta-rs/blob/main/rust/src/storage/s3/mod.rs.

## Deployment

Using the DynamoDb lock requires a DynamoDb table to have already been created
in AWS. The following Terraform code is an example which will create table
named "lock_example",.


```terraform
resource "aws_dynamodb_table" "oxbow_locking" {
name = "lock_example"
billing_mode = "PROVISIONED"
# Default name of the partition key hard-coded in delta-rs
hash_key = "key"
read_capacity = 10
write_capacity = 10
attribute {
name = "key"
type = "S"
}
# The leaseDuration is used by dynamodb-lock-rs and *must* be a Number type
attribute {
name = "leaseDuration"
type = "N"
}
ttl {
attribute_name = "leaseDuration"
enabled = true
}
}
```

The locking code should then be configured with the environment variable
`DYNAMO_LOCK_TABLE_NAME` set to "lock_example"

0 comments on commit 927e348

Please sign in to comment.