Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karl-cardenas-coding/dynamodb-local-example
This is an example project to showcase how to use DynamoDB locally while leveraging Terraform, localstack, and noSQL Workbench for DynamoDB 💻
https://github.com/karl-cardenas-coding/dynamodb-local-example
dynamodb-local go localstack nosql-workbench terraform
Last synced: 11 days ago
JSON representation
This is an example project to showcase how to use DynamoDB locally while leveraging Terraform, localstack, and noSQL Workbench for DynamoDB 💻
- Host: GitHub
- URL: https://github.com/karl-cardenas-coding/dynamodb-local-example
- Owner: karl-cardenas-coding
- License: mit
- Created: 2020-08-12T02:33:14.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-01T22:21:35.000Z (over 1 year ago)
- Last Synced: 2024-10-15T18:41:08.779Z (23 days ago)
- Topics: dynamodb-local, go, localstack, nosql-workbench, terraform
- Language: HCL
- Homepage:
- Size: 4.6 MB
- Stars: 8
- Watchers: 2
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Go version](https://img.shields.io/github/go-mod/go-version/karl-cardenas-coding/dynamodb-local-example?filename=upload-tool%2Fgo.mod)](https://golang.org/dl/)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/karl-cardenas-coding/dynamodb-local-example.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/karl-cardenas-coding/dynamodb-local-example/alerts/)# DynamoDB-local-example
This is an example project to showcase how to use DynamoDB locally while leveraging Terraform, localstack, and noSQL Workbench for DynamoDB. An in-depth explanation is provided in the following Medium article, ["How to use DynamoDB locally.."](https://medium.com/@cardenas88karl/how-to-use-aws-dynamodb-locally-ad3bb6bd0163#92fe-53da0f183cd6)## Changing JSON Content
You can either replace the JSON content inside the file `static/raw-data.json` OR provide your own file. Just make sure you change the variable value `json-file-path` in the `terraform.tfvars` file. If you want to leverage the AWS CLI approach then follow the same steps, either replace `static/formatted-data.json` OR change the content inside. Just ensure that the content is in the correct format that DynamoDB expects (DynamoDB JSON).## Customizing the upload script
Customizing the upload script is pretty easy. The only file that that needs to be modified is the `upload-tool/internal/upload.go`. Simply replace the content of the `Model` struct. Keep the same name `Model` please, otherwise the program will fail.Example ( - = *Removal*, + = *Addition* )
```go
type Model struct {
- OrderID string `json:"orderId"`
- CustomerID string `json:"customerId"`
- Shipped string `json:"shipped,omitempty"`
- Email string `json:"email"`
- Address string `json:"address"`
- Cost string `json:"cost"`
}// New example struct
type Model struct {
+ EmployeeId string `json:"employeeId"`
+ Division string `json:"Division"`
+ HiringDate string `json:"HiringDate"`
+ Email string `json:"email"`
+ PayGrade string `json:"payGrade"`
+ HRCode string `json:"hrCode"`
}```
## Compiling Binary
Once you have the required change to the `Model` struct all that is required of you is to compile the binary for the operating system you need it for. If you have Go installed on your environment, simply execute the `go build` command.I have included build commands for the most common operating systems. Should you need to compile for other opearting systems please visit the Golang documentation for the proper `GOOS` and `GOARCH` [values](https://golang.org/doc/install/source). Place the compiled binary in the root of the project structure.
### Windows 64 bit
```bash
env GOOS=windows GOARCH=amd64 go build -o=upload-logic.exe
```### Linux 64 bit
```bash
env GOOS=linux GOARCH=amd64 go build -o=upload-logic
```### Darwin (Mac) 64 bit
```bash
env GOOS=darwin GOARCH=amd64 go build -o=upload-logic
```