Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/spot_fleet_request - add import support #12767

Merged
merged 7 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1202,6 +1207,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