An open API service indexing awesome lists of open source software.

https://github.com/k-candidate/tf-module-dynamodb


https://github.com/k-candidate/tf-module-dynamodb

dynamodb gha github-actions python python-lambda python3 sqs sqs-queue terraform terraform-module tfsec

Last synced: 6 months ago
JSON representation

Awesome Lists containing this project

README

          

# tf-module-dynamodb

![Flow chart of how this works](/docs/assets/images/db.jpg)

- This has been made locally using localstack.
- To deploy, you can use a file `main.tf` with the following content:
```
module "tf-module-dynamodb" {
source = "git@github.com:k-candidate/tf-module-dynamodb.git"
table_name = "tf-test"
hash_key = "id"
hash_key_type = "N"
range_key = "name"
alias = "mykey"
}
```
- A GHA has been put in place to generate the docs for tf below.

### This a simple PoC. Possible improvements:
- [ ] If we are given data with defined schema, Aurora Serverless v2 would be the go-to solution, but it is not available in the community version of localstack. However DynamoDB is.
- [x] Locally, use `tfsec` to scan the tf code before making the commit. Or put it in the CD flow (possible to soft or hard fail). **DONE**: Added GitHub Action that will comment inside PRs using tfsec's output.
- [ ] Have a S3 bucket as backend to store the tf state.

## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| [archive](#provider\_archive) | n/a |
| [aws](#provider\_aws) | n/a |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_dynamodb_table.dynamodb-table](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table) | resource |
| [aws_iam_role.iam_for_lambda_tf](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_kms_alias.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_alias) | resource |
| [aws_kms_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
| [aws_lambda_event_source_mapping.lambda_sqs_trigger](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping) | resource |
| [aws_lambda_function.insert-into-dynamodb](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_sqs_queue.dev-sqs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource |
| [aws_ssm_parameter.foo](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
| [archive_file.lambda](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [alias](#input\_alias) | n/a | `string` | `"tf-cmk"` | no |
| [hash\_key](#input\_hash\_key) | n/a | `string` | `"UserId"` | no |
| [hash\_key\_type](#input\_hash\_key\_type) | n/a | `string` | `"S"` | no |
| [key\_spec](#input\_key\_spec) | n/a | `string` | `"SYMMETRIC_DEFAULT"` | no |
| [range\_key](#input\_range\_key) | n/a | `string` | `"FullName"` | no |
| [range\_key\_type](#input\_range\_key\_type) | n/a | `string` | `"S"` | no |
| [read\_capacity](#input\_read\_capacity) | n/a | `number` | `5` | no |
| [table\_name](#input\_table\_name) | n/a | `string` | n/a | yes |
| [write\_capacity](#input\_write\_capacity) | n/a | `number` | `5` | no |

## Outputs

No outputs.