Skip to content

Commit

Permalink
Merge pull request #12767 from DrFaust92/r/spot_fleet_request_import
Browse files Browse the repository at this point in the history
r/spot_fleet_request - add import support
  • Loading branch information
anGie44 authored Apr 30, 2020
2 parents a1cb3b7 + be31df2 commit c7220bc
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 1 deletion.
31 changes: 30 additions & 1 deletion aws/resource_aws_spot_fleet_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ func resourceAwsSpotFleetRequest() *schema.Resource {
Read: resourceAwsSpotFleetRequestRead,
Delete: resourceAwsSpotFleetRequestDelete,
Update: resourceAwsSpotFleetRequestUpdate,

Importer: &schema.ResourceImporter{
State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
d.Set("instance_pools_to_use_count", 1)
return []*schema.ResourceData{d}, nil
},
},
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(5 * time.Minute),
Expand Down Expand Up @@ -1203,6 +1208,30 @@ func resourceAwsSpotFleetRequestRead(d *schema.ResourceData, meta interface{}) e
}
}

if config.LoadBalancersConfig != nil {
lbConf := config.LoadBalancersConfig

if lbConf.ClassicLoadBalancersConfig != nil {
flatLbs := make([]*string, 0)
for _, lb := range lbConf.ClassicLoadBalancersConfig.ClassicLoadBalancers {
flatLbs = append(flatLbs, lb.Name)
}
if err := d.Set("load_balancers", flattenStringSet(flatLbs)); err != nil {
return fmt.Errorf("error setting load_balancers: %s", err)
}
}

if lbConf.TargetGroupsConfig != nil {
flatTgs := make([]*string, 0)
for _, tg := range lbConf.TargetGroupsConfig.TargetGroups {
flatTgs = append(flatTgs, tg.Arn)
}
if err := d.Set("target_group_arns", flattenStringSet(flatTgs)); err != nil {
return fmt.Errorf("error setting target_group_arns: %s", err)
}
}
}

return nil
}

Expand Down
Loading

0 comments on commit c7220bc

Please sign in to comment.