- Notifications
You must be signed in to change notification settings - Fork5
Terraform State Storage API
License
tfstate/github-sls-rest-api
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
TFstate.dev is a freeTerraform State Provider andOpen Source Hosted Service for secure Terraform Remote State hosting using a GitHub Token, courtsey ofScaffoldly
Features:
- GitHub Token used for Authentication and Authorization to Terraform State
- Encrypted State in Amazon S3 using Amazon KMS
- State Locking
- Highly availableHosted API in AWS Lambda + API Gateway
- Plug and Play: Only a GitHub Token is needed to use TFstate.dev
✅ We do not store or save the provided GitHub token.
First, a GitHub token is needed. This can be aPersonal Access Token, aGitHub Actions Secret, or any other form ofGitHub Oauth Token. At a minimum, the token needsrepo:read access for the configured repository.
➡ See ourexample repository.
To use TFstate.dev in Terraform, add the followingbackend configuration to Terraform:
terraform {backend"http" {address="https://api.tfstate.dev/github/v1"lock_address="https://api.tfstate.dev/github/v1/lock"unlock_address="https://api.tfstate.dev/github/v1/lock"lock_method="PUT"unlock_method="DELETE"username="{your-github-org}/{your-github-repo}" }}
Then, Terraform can be configured to use the TFstate.dev backend using the GitHub token:
terraform init -backend-config="password={your-github-token}"terraform planterraform applyAlternatively, theTF_HTTP_PASSWORD environment variable can be set with the GitHub token:
export TF_HTTP_PASSWORD="{your-github-token}"terraform initterraform planterraform apply
For more information go toTFstate.dev!
We'd love contributions from the community to improve this API.
Requirements:
- NodeJS 14+
- Yarn
Running instructions:
- Fork and clone this repo
- Run
yarn - Run
yarn start(launches Serverless in Local mode)
The main controller isControllerV1. It contains the primary endpoints for State Storage.
Once running locally, the OpenAPI docs can be found at:
https://localhost:3000/github/swagger.html
While running the API locally, create a basic Terraform structure to test state functions:
terraform {backend"http" {address="http://localhost:3000/github/v1"lock_address="http://localhost:3000/github/v1/lock"unlock_address="http://localhost:3000/github/v1/lock"lock_method="PUT"unlock_method="DELETE"# Make sure this is a real repository that your token has access tousername="{your-github-user}/github-sls-rest-api" }}resource"null_resource""example" {}output"null_resource_id" {value=null_resource.example.id}
Then, run:
export TF_HTTP_PASSWORD={your-github-token}terraform initterraform planterraform applyOther command to verify with:
terraform state ...terraform force-unlock ...
SeeCONTRIBUTING
Copyright 2022 Scaffoldly LLC
Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
About
Terraform State Storage API
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.