Skip to content

ajitchahal/terraform-s3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-s3

A cli to store and retrieve tfstate to/from S3

How to use

go run main.go -s3-op=up -s3-bucket=resources-stage-us -s3-region=us-east-1 -s3-filename=terraform.tfstate

Command line flags

blog about cmd flags

git repo of the above project

get cmd line vars from env variables

Note: still not a proper solution of

get variable from ENV_variable if set, then from command line args anf parse to a structure.

Replacing password

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"))

About

A cli to store and retrieve tfstate to/from S3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages