mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/aws: Change AWS ssm_maintenance_window Read func (#14665)
Fixes: #14653 I was originally calling the wrong API method and only some of the values were being persisted to state. By changing the API method, we can now get all of the values and therefore can detech manual drift ``` % make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSSSMMaintenanceWindow_' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/05/19 16:56:27 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSSSMMaintenanceWindow_ -timeout 120m === RUN TestAccAWSSSMMaintenanceWindow_basic --- PASS: TestAccAWSSSMMaintenanceWindow_basic (41.39s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 41.419s ```
This commit is contained in:
parent
11279963a3
commit
65283fb47c
@ -68,7 +68,6 @@ func resourceAwsSsmMaintenanceWindowCreate(d *schema.ResourceData, meta interfac
|
||||
}
|
||||
|
||||
d.SetId(*resp.WindowId)
|
||||
|
||||
return resourceAwsSsmMaintenanceWindowRead(d, meta)
|
||||
}
|
||||
|
||||
@ -114,38 +113,21 @@ func resourceAwsSsmMaintenanceWindowUpdate(d *schema.ResourceData, meta interfac
|
||||
func resourceAwsSsmMaintenanceWindowRead(d *schema.ResourceData, meta interface{}) error {
|
||||
ssmconn := meta.(*AWSClient).ssmconn
|
||||
|
||||
params := &ssm.DescribeMaintenanceWindowsInput{
|
||||
Filters: []*ssm.MaintenanceWindowFilter{
|
||||
{
|
||||
Key: aws.String("Name"),
|
||||
Values: []*string{aws.String(d.Get("name").(string))},
|
||||
},
|
||||
},
|
||||
params := &ssm.GetMaintenanceWindowInput{
|
||||
WindowId: aws.String(d.Id()),
|
||||
}
|
||||
|
||||
resp, err := ssmconn.DescribeMaintenanceWindows(params)
|
||||
resp, err := ssmconn.GetMaintenanceWindow(params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
found := false
|
||||
|
||||
for _, window := range resp.WindowIdentities {
|
||||
if *window.WindowId == d.Id() {
|
||||
found = true
|
||||
|
||||
d.Set("name", window.Name)
|
||||
d.Set("cutoff", window.Cutoff)
|
||||
d.Set("duration", window.Duration)
|
||||
d.Set("enabled", window.Enabled)
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
log.Printf("[INFO] Cannot find the SSM Maintenance Window %q. Removing from state", d.Get("name").(string))
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
d.Set("name", resp.Name)
|
||||
d.Set("cutoff", resp.Cutoff)
|
||||
d.Set("duration", resp.Duration)
|
||||
d.Set("enabled", resp.Enabled)
|
||||
d.Set("allow_unassociated_targets", resp.AllowUnassociatedTargets)
|
||||
d.Set("schedule", resp.Schedule)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user