-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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: implement CloudFront Lambda Function Associations (supersedes #10985) #11291
Conversation
Solid work - this LGTM! Nice to see this coming in - it should unblock some people :) |
Thanks! |
@@ -44,6 +49,35 @@ func trustedSignersConf() []interface{} { | |||
return []interface{}{"1234567890EX", "1234567891EX"} | |||
} | |||
|
|||
func lambdaSetHash(v interface{}) int { |
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 is essentially where my PR was at 9c5a25d on Jan 5. I was derailed by the comment from @apparentlymart asking to remove the hash function.
Sorry this got delayed 2 weeks as a result 🤓
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.
Sorry this got delayed 2 weeks as a result
Nah it's not your fault.
@apparentlymart was correct in that the manually added Set
function should be omitted, unless there's a really good reason.
That doesn't make it his fault either 😄
The problem here was reconstructing "sets" in code in the test instead of configuration. All the previous examples I found in the codebase were simple set's of strings
which is trivial to reconstruct, but NewSet
is more difficult with sets that have a more complicated schema.
Like I said you did 99% of the work here I just needed to do some battlefield surgery 😄
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.
Roger. Thanks again 😄
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.
@MrGossett So.... funny enough, I had to reinstate that lambda set hash you were asked to remove 😆
From Martin's comment:
We only really continue to support explicit Set for compatibility with schemas that predate the automatic hashing.
This is true, but unfortunately lambda_function_association
is being added as a sub param to two params that do themselves have custom hash function for the IDs.
So, I had to add lambda_function_association
to the two CacheBehaviorHash
(?) method(s), but to do so, I'd need to hash them... so I needed that method 😐
So anyway it's re-added
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.
👍
Ran some test:
|
Hold off on this - need to investigate something |
…t (including limits)
I added documentation and the |
Hey @stack72 when you get a chance can you look this over? Not sure about the TravisCI error 🤔 |
handles query strings, cookies and headers (maximum one). | ||
|
||
* `lambda_function_association` (Optional) - A complext config that triggers a lambda function with |
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.
Typo on complext
Lambda@Edge](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/what-is-lambda-at-edge.html) | ||
for more information | ||
|
||
* `event_type` (Required) - The specific event to trigger this functionon. |
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.
Typo on functionon
@catsby the travis fail is because of this
|
…nctions may be a set or an []interface{}
for more information | ||
|
||
* `event_type` (Required) - The specific event to trigger this function. | ||
Valid values: `viewwer-request`, `origin-request`, `viewer-response`, |
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.
typo: viewwer-request
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.
fixed, thanks!
@@ -294,6 +311,9 @@ func flattenCacheBehavior(cb *cloudfront.CacheBehavior) map[string]interface{} { | |||
if len(cb.TrustedSigners.Items) > 0 { | |||
m["trusted_signers"] = flattenTrustedSigners(cb.TrustedSigners) | |||
} | |||
if len(cb.LambdaFunctionAssociations.Items) > 0 { | |||
m["lambda_function_association"] = flattenLambdaFunctionAssociations(cb.LambdaFunctionAssociations) |
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.
is this supposed to be plural? lambda_function_associations
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.
no, it's a key in the schema. If it were plural then the config to use it would be
lambda_funcation_associations {
event_type = "blah"
arn = "blah"
}
lambda_funcation_associations {
event_type = "blah"
arn = "blah"
}
...
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.
Makes sense.
@@ -337,6 +363,9 @@ func TestCloudFrontStructure_flattenCacheBehavior(t *testing.T) { | |||
if out["target_origin_id"] != "myS3Origin" { | |||
t.Fatalf("Expected out[target_origin_id] to be myS3Origin, got %v", out["target_origin_id"]) | |||
} | |||
if reflect.DeepEqual(out["lambda_function_associations"], in["lambda_function_associations"]) != true { |
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.
I have a feeling this is passing because reflect.DeepEqual
is comparing nil
to nil
. The singular version is used in defaultCacheBehaviorConf, so the plural lambda_function_associations
doesn't exist.
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.
makes sense, I'll investigate
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.
fixed in fd3f4bb
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Continue the work done in #10985 with just a few tweaks to restore the
TypeSet
inlambda_function_association
.Should also fix #11295