Example #1
0
func DownloadState(config *terraform_config.AwsConfig, environment string) {

	fmt.Println("Syncing project state with S3")

	tfState := terraform_config.TerraformState(environment)
	s3Key := S3Key(config.S3_key, environment)
	fmt.Printf("Downloading project state: %s/%s to: %s\n", cyan(config.S3_bucket), cyan(s3Key), cyan(tfState))

	err := sync.Download(config.Aws_region, config.S3_bucket, s3Key, tfState)
	fmt.Println()
	if err != nil {
		command.Warn("Failed to download", err)
	} else {
		color.Green("Downloaded successfully from S3")
		fmt.Println()
	}
}
Example #2
0
func DownloadState(config *terraform_config.TerraformConfig, environment string) {

	fmt.Println("Syncing project state with S3")

	tfState := config.State_path
	s3Key := S3Key(config.S3_key, environment)
	fmt.Printf("Downloading project state: %s/%s to: %s\n", command.Cyan(config.S3_bucket), command.Cyan(s3Key), command.Cyan(tfState))

	err := sync.Download(config.Aws_region, config.S3_bucket, s3Key, tfState)
	fmt.Println()
	if err != nil {
		command.Warn("Failed to download", err)
		if !command.InputAffirmative("Continue without using syncronised state?") {
			fmt.Println(command.Cyan("Operation cancelled"))
			os.Exit(0)
		}
	} else {
		fmt.Println(command.Green("Downloaded successfully from S3"))
	}
	fmt.Println()
}