A cli to store and retrieve tfstate to/from S3
go run main.go -s3-op=up -s3-bucket=resources-stage-us -s3-region=us-east-1 -s3-filename=terraform.tfstate
Command line flags
get cmd line vars from env variables
get variable from ENV_variable if set, then from command line args anf parse to a structure.
option 1
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`\bsecret_\w+":"\w+",$`)
fmt.Println(re.ReplaceAllString(`"secret_master_password":"abcdefgh3242",`, "secret_master_password\":\"pass\""))
}
re := regexp.MustCompile(`(?m)\bsecret_\w+":( |\t)*"\w+",$`)
option 2
var or = `
"iam_roles": null,
"id": "abntest-service",
"kms_key_id": "arn:aws:kms:us-east-1:dd:key/db",
"master_password": "secret_abc1234_end",
"master_username": "masteruser",
"port": 5432,`
re := regexp.MustCompile(`\bsecret_\w+_end`)
fmt.Println(re.ReplaceAllString(or, "pass"))