github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/builtin/providers/aws/resource_aws_elastic_beanstalk_environment_migrate.go (about) 1 package aws 2 3 import ( 4 "fmt" 5 "log" 6 7 "github.com/hashicorp/terraform/terraform" 8 ) 9 10 func resourceAwsElasticBeanstalkEnvironmentMigrateState( 11 v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { 12 switch v { 13 case 0: 14 log.Println("[INFO] Found AWS Elastic Beanstalk Environment State v0; migrating to v1") 15 return migrateBeanstalkEnvironmentStateV0toV1(is) 16 default: 17 return is, fmt.Errorf("Unexpected schema version: %d", v) 18 } 19 } 20 21 func migrateBeanstalkEnvironmentStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) { 22 if is.Empty() || is.Attributes == nil { 23 log.Println("[DEBUG] Empty Elastic Beanstalk Environment State; nothing to migrate.") 24 return is, nil 25 } 26 27 log.Printf("[DEBUG] Attributes before migration: %#v", is.Attributes) 28 29 if is.Attributes["tier"] == "" { 30 is.Attributes["tier"] = "WebServer" 31 } 32 33 log.Printf("[DEBUG] Attributes after migration: %#v", is.Attributes) 34 return is, nil 35 }