Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sudohikumar/sample-tf-provider
This is a basic terraform provider that reads/writes/deletes keys to/from Redis.
https://github.com/sudohikumar/sample-tf-provider
go golang redis terraform terraform-provider
Last synced: 13 days ago
JSON representation
This is a basic terraform provider that reads/writes/deletes keys to/from Redis.
- Host: GitHub
- URL: https://github.com/sudohikumar/sample-tf-provider
- Owner: sudohikumar
- Created: 2020-07-15T16:50:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-21T08:07:16.000Z (over 4 years ago)
- Last Synced: 2023-02-28T10:06:56.660Z (over 1 year ago)
- Topics: go, golang, redis, terraform, terraform-provider
- Language: Go
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
NOTES:
---
## Assumption:- There is a REST API running to perform tasks on redis such as addition, deletion etc.
- API is of the following format (All are `GET` method)
- Required Headers:
- `redis_host`- Redis Instance address to connect to
- `redis_port`- Redis Instance port to connect to
- `/add/:key/:value` - Adds key to the redis
- `/delete/:key` - Deletes key from redis
- `/get/:key` - Gets key from redis## How to run:
- Build the provider in root project as- ```bash
# Format is terraform--
# here type is `provider` and name is `redis-object` which we reference later
go build -o terraform-provider-redis-object
```
- Create `variables.tfvars` as follows (example):- ```hcl
redis_host = "http://0.0.0.0"
redis_port = "6379"
```
- Create `variables.tf` as follows (example):- ```hcl
variable "redis_host" {
description = "redis host"
}
variable "redis_port" {
description = "redis port"
}
```
- Create `main.tf` as follows (example):
- ```hcl
resource "redis-object" "my-redis-object-1" {
key = "k1"
value = "v1"
}
```
- Run the following
- ```bash
# Initialize the terraform
terraform init
# Plan
terraform plan -var-file=variables.tfvars
# Apply
terraform apply -var-file=variables.tfvars -auto-approve
# For cleanup
terraform destroy -var-file=variables.tfvars -auto-approve
```
## Debug:
- Set `set TF_LOG=DEBUG`. As per the warning, `TRACE` should be used and other log types will be removed in the future.## References:
- https://github.com/justsimplify/sample-redis-api - (For sample Redis API)