// packer-wrapper will get secrets from your pass password store, // setup an environment containing secrets and execute packer, // passing command-line arguments to terraform as-is func main() { config := config.ParseDefaultCloudConfig() secEnv := wrapper.GetEnvironmentVariablesForSecrets(config.SecretVariables[:]) env := wrapper.GetEnvironmentVariablesForValues(config.Variables[:]) wrapper.ExecuteCommand("packer", os.Args[1:], append(secEnv, env...)) }
// terraform-wrapper will get secrets from your pass password store, // setup an environment containing secrets and execute terraform, // passing command-line arguments to terraform as-is func main() { config := config.ParseDefaultCloudConfig() if !isRequiredTerraformVersion(config.TerraformVersion) { fmt.Fprintf(os.Stderr, "Bad Terraform version - cloud-config.yml requires %s\n", config.TerraformVersion) os.Exit(1) } start := time.Now() fmt.Println("Started terraform operation at:", start) secEnv := wrapper.GetEnvironmentVariablesForSecrets(config.SecretVariables[:]) env := wrapper.GetEnvironmentVariablesForValues(config.Variables[:]) wrapper.ExecuteCommand("terraform", os.Args[1:], append(secEnv, env...)) stop := time.Now() fmt.Println("Started terraform operation at:", start) fmt.Println("Finished terraform operation at:", stop) duration := stop.Unix() - start.Unix() fmt.Println("Total duration (seconds): ", duration) }