package aws import ( "fmt" "log" "strings" "github.com/hashicorp/terraform/terraform" ) func resourceAwsCodebuildMigrateState( v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { switch v { case 0: log.Println("[INFO] Found AWS Codebuild State v0; migrating to v1") return migrateCodebuildStateV0toV1(is) default: return is, fmt.Errorf("Unexpected schema version: %d", v) } } func migrateCodebuildStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) { if is.Empty() { log.Println("[DEBUG] Empty InstanceState; nothing to migrate.") return is, nil } log.Printf("[DEBUG] Attributes before migration: %#v", is.Attributes) if is.Attributes["timeout"] != "" { is.Attributes["build_timeout"] = strings.TrimSpace(is.Attributes["timeout"]) } log.Printf("[DEBUG] Attributes after migration: %#v", is.Attributes) return is, nil }