mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-13 00:46:16 -06:00
Merge pull request #13101 from hashicorp/p-aws-opsworks-instance
Fixes TestAccAWSOpsworksInstance
This commit is contained in:
commit
8b1df456eb
@ -565,6 +565,10 @@ func resourceAwsOpsworksInstanceRead(d *schema.ResourceData, meta interface{}) e
|
||||
for _, v := range instance.LayerIds {
|
||||
layerIds = append(layerIds, *v)
|
||||
}
|
||||
layerIds, err = sortListBasedonTFFile(layerIds, d, "layer_ids")
|
||||
if err != nil {
|
||||
return fmt.Errorf("[DEBUG] Error sorting layer_ids attribute: %#v", err)
|
||||
}
|
||||
if err := d.Set("layer_ids", layerIds); err != nil {
|
||||
return fmt.Errorf("[DEBUG] Error setting layer_ids attribute: %#v, error: %#v", layerIds, err)
|
||||
}
|
||||
@ -820,7 +824,6 @@ func resourceAwsOpsworksInstanceUpdate(d *schema.ResourceData, meta interface{})
|
||||
|
||||
if v, ok := d.GetOk("layer_ids"); ok {
|
||||
req.LayerIds = expandStringList(v.([]interface{}))
|
||||
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("os"); ok {
|
||||
|
@ -1490,6 +1490,22 @@ func sortInterfaceSlice(in []interface{}) []interface{} {
|
||||
return b
|
||||
}
|
||||
|
||||
// This function sorts List A to look like a list found in the tf file.
|
||||
func sortListBasedonTFFile(in []string, d *schema.ResourceData, listName string) ([]string, error) {
|
||||
if attributeCount, ok := d.Get(listName + ".#").(int); ok {
|
||||
for i := 0; i < attributeCount; i++ {
|
||||
currAttributeId := d.Get(listName + "." + strconv.Itoa(i))
|
||||
for j := 0; j < len(in); j++ {
|
||||
if currAttributeId == in[j] {
|
||||
in[i], in[j] = in[j], in[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
return in, nil
|
||||
}
|
||||
return in, fmt.Errorf("Could not find list: %s", listName)
|
||||
}
|
||||
|
||||
func flattenApiGatewayThrottleSettings(settings *apigateway.ThrottleSettings) []map[string]interface{} {
|
||||
result := make([]map[string]interface{}, 0, 1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user