Skip to content
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

provider/aws: Require cookies for Cloudfront Distributions #6505

Merged
merged 1 commit into from
May 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
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