Skip to content

Commit

Permalink
provider/aws: Require cookies for Cloudfront Distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby committed May 5, 2016
1 parent 03bc54b commit 8129c05
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,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 {
Expand All @@ -385,7 +385,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func resourceAwsCloudFrontDistribution() *schema.Resource {
Schema: map[string]*schema.Schema{
"cookies": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Required: true,

This comment has been minimized.

Copy link
@VladRassokhin

VladRassokhin Jan 24, 2017

Contributor

@catsby should be also changed on line 219?

This comment has been minimized.

Copy link
@VladRassokhin

VladRassokhin Jan 24, 2017

Contributor
Set: cookiePreferenceHash,
MaxItems: 1,
Elem: &schema.Resource{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8129c05

Please sign in to comment.