-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
issue #5440 terraform crash in resource elasticsearch_domain #5451
Conversation
@@ -548,7 +548,7 @@ func resourceAwsElasticSearchDomainRead(d *schema.ResourceData, meta interface{} | |||
} | |||
if ds.SnapshotOptions != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This d.Set()
was incorrectly implemented before (notice the missing []
before the map) and we should probably fix it now. I think the AutomatedSnapshotStartHour value also needs to be wrapped in int()
. Something like the below could handle both for now and return an error if incorrect:
if err := d.Set("snapshot_options", flattenESSnapshotOptions(ds.SnapshotOptions)); err != nil {
return fmt.Errorf("error setting snapshot_options: %s": err)
}
func flattenESSnapshotOptions(snapshotOptions *elasticsearch.SnapshotOptions) []map[string]interface{} {
if snapshotOptions == nil {
return []map[string]interface{}{}
}
m := map[string]interface{}{
"automated_snapshot_start_hour": int(aws.Int64Value(snapshotOptions.AutomatedSnapshotStartHour)),
}
return []map[string]interface{}{m}
}
@bflad Done 👍 |
Looks like one more little thing if you have a chance, since we actually fixed the "container"
It should be okay if we tell the schema to ignore this difference as the underlying attributes are what really matter in this case. 👍 // In "snapshot_options" attribute definition:
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
if old == "1" && new == "0" {
return true
}
return false
}, Thanks so much! |
@bflad I added diffsuppress func. I think if we check the nil value for
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @saravanan30erd! LGTM 🚀
(Test failures unrelated)
=== RUN TestAccAWSElasticSearchDomain_duplicate
--- FAIL: TestAccAWSElasticSearchDomain_duplicate (551.56s)
=== RUN TestAccAWSElasticSearchDomain_encrypt_at_rest_specify_key
--- PASS: TestAccAWSElasticSearchDomain_encrypt_at_rest_specify_key (787.75s)
=== RUN TestAccAWSElasticSearchDomain_policy
--- PASS: TestAccAWSElasticSearchDomain_policy (820.13s)
=== RUN TestAccAWSElasticSearchDomain_importBasic
--- PASS: TestAccAWSElasticSearchDomain_importBasic (1017.47s)
=== RUN TestAccAWSElasticSearchDomain_v23
--- PASS: TestAccAWSElasticSearchDomain_v23 (1040.20s)
=== RUN TestAccAWSElasticSearchDomain_basic
--- PASS: TestAccAWSElasticSearchDomain_basic (1054.86s)
=== RUN TestAccAWSElasticSearchDomain_complex
--- PASS: TestAccAWSElasticSearchDomain_complex (1162.99s)
=== RUN TestAccAWSElasticSearchDomain_encrypt_at_rest_default_key
--- PASS: TestAccAWSElasticSearchDomain_encrypt_at_rest_default_key (1265.94s)
=== RUN TestAccAWSElasticSearchDomainPolicy_basic
--- PASS: TestAccAWSElasticSearchDomainPolicy_basic (1355.98s)
=== RUN TestAccAWSElasticSearchDomain_vpc
--- PASS: TestAccAWSElasticSearchDomain_vpc (1366.21s)
=== RUN TestAccAWSElasticSearchDomain_CognitoOptionsCreateAndRemove
--- PASS: TestAccAWSElasticSearchDomain_CognitoOptionsCreateAndRemove (1405.46s)
=== RUN TestAccAWSElasticSearchDomain_tags
--- PASS: TestAccAWSElasticSearchDomain_tags (1471.90s)
=== RUN TestAccAWSElasticSearchDomain_CognitoOptionsUpdate
--- PASS: TestAccAWSElasticSearchDomain_CognitoOptionsUpdate (1529.72s)
=== RUN TestAccAWSElasticSearchDomain_LogPublishingOptions
--- PASS: TestAccAWSElasticSearchDomain_LogPublishingOptions (1655.18s)
=== RUN TestAccAWSElasticSearchDomain_update
--- PASS: TestAccAWSElasticSearchDomain_update (2038.16s)
=== RUN TestAccAWSElasticSearchDomain_vpc_update
--- PASS: TestAccAWSElasticSearchDomain_vpc_update (2267.89s)
=== RUN TestAccAWSElasticSearchDomain_internetToVpcEndpoint
--- PASS: TestAccAWSElasticSearchDomain_internetToVpcEndpoint (2451.08s)
=== RUN TestAccAWSElasticSearchDomain_update_volume_type
--- FAIL: TestAccAWSElasticSearchDomain_update_volume_type (5347.53s)
This has been released in version 1.31.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Fixes #5440
Changes proposed in this pull request:
fixed panic nil pointer dereference error.
Properly dereferenced other attributes too.