diff --git a/builtin/providers/aws/cloudfront_distribution_configuration_structure.go b/builtin/providers/aws/cloudfront_distribution_configuration_structure.go index 19e27fdf3..e6c2d998e 100644 --- a/builtin/providers/aws/cloudfront_distribution_configuration_structure.go +++ b/builtin/providers/aws/cloudfront_distribution_configuration_structure.go @@ -363,7 +363,7 @@ func expandForwardedValues(m map[string]interface{}) *cloudfront.ForwardedValues fv := &cloudfront.ForwardedValues{ QueryString: aws.Bool(m["query_string"].(bool)), } - if v, ok := m["cookies"]; ok { + if v, ok := m["cookies"]; ok && v.(*schema.Set).Len() > 0 { fv.Cookies = expandCookiePreference(v.(*schema.Set).List()[0].(map[string]interface{})) } if v, ok := m["headers"]; ok { @@ -390,7 +390,7 @@ func forwardedValuesHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%t-", m["query_string"].(bool))) - if d, ok := m["cookies"]; ok { + if d, ok := m["cookies"]; ok && d.(*schema.Set).Len() > 0 { buf.WriteString(fmt.Sprintf("%d-", cookiePreferenceHash(d.(*schema.Set).List()[0].(map[string]interface{})))) } if d, ok := m["headers"]; ok { diff --git a/builtin/providers/aws/resource_aws_cloudfront_distribution.go b/builtin/providers/aws/resource_aws_cloudfront_distribution.go index b70a1fba3..9fc333279 100644 --- a/builtin/providers/aws/resource_aws_cloudfront_distribution.go +++ b/builtin/providers/aws/resource_aws_cloudfront_distribution.go @@ -58,7 +58,7 @@ func resourceAwsCloudFrontDistribution() *schema.Resource { Schema: map[string]*schema.Schema{ "cookies": &schema.Schema{ Type: schema.TypeSet, - Optional: true, + Required: true, Set: cookiePreferenceHash, MaxItems: 1, Elem: &schema.Resource{ diff --git a/website/source/docs/providers/aws/r/cloudfront_distribution.html.markdown b/website/source/docs/providers/aws/r/cloudfront_distribution.html.markdown index 10b8edb8a..864e58943 100644 --- a/website/source/docs/providers/aws/r/cloudfront_distribution.html.markdown +++ b/website/source/docs/providers/aws/r/cloudfront_distribution.html.markdown @@ -186,7 +186,7 @@ of several sub-resources - these resources are laid out below. ##### Forwarded Values Arguments - * `cookies` (Optional) - The [forwarded values cookies](#cookies-arguments) + * `cookies` (Required) - The [forwarded values cookies](#cookies-arguments) that specifies how CloudFront handles cookies (maximum one). * `headers` (Optional) - Specifies the Headers, if any, that you want @@ -200,7 +200,8 @@ of several sub-resources - these resources are laid out below. * `forward` (Required) - Specifies whether you want CloudFront to forward cookies to the origin that is associated with this cache behavior. You can - specify `all`, `none` or `whitelist`. + specify `all`, `none` or `whitelist`. If `whitelist`, you must include the + subsequent `whitelisted_names` * `whitelisted_names` (Optional) - If you have specified `whitelist` to `forward`, the whitelisted cookies that you want CloudFront to forward to