-
Notifications
You must be signed in to change notification settings - Fork 378
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
fix(Cloudfront): LateInit missing fields #1298
fix(Cloudfront): LateInit missing fields #1298
Conversation
8666088
to
5c7a243
Compare
5c7a243
to
7d91fad
Compare
continue | ||
} | ||
// FunctionARN must be unique for each FunctionAssociation | ||
existing[awsclients.StringValue(o.FunctionARN)] = o |
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.
We have checked the API reference and the console UI for cache behavior with @ezgidemirel. It looks like the key for this resource should be the event type.
if o.FunctionARN == nil { | ||
continue | ||
} |
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.
Please see the comment below regarding the chosen key. We would not expect the key type to be a pointer but although in the console UI, it's not a pointer type, the SDK expects a pointer type. We did not check what happens if you call the SDK function with a nil EventType
but from what we observed from the console UI, this should not be allowed.
if o.FunctionARN == nil { | |
continue | |
} |
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.
As expected, AWS doesn't allow EventType
to be nil. Removing this nil check caused following error:
message: "update failed: cannot update Distribution in AWS: PreconditionFailed:
The request failed because it didn't meet the preconditions in one or more request-header
fields.\n\tstatus code: 412, request id: "
I added back with the EventType
.
continue | ||
} | ||
// FunctionARN must be unique for each FunctionAssociation | ||
existing[awsclients.StringValue(o.FunctionARN)] = o |
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.
existing[awsclients.StringValue(o.FunctionARN)] = o | |
existing[awsclients.StringValue(o.EventType)] = o |
} | ||
|
||
for _, il := range in.Items { | ||
if il.FunctionARN == 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.
if il.FunctionARN == nil { | |
if il.EventType != nil { |
continue | ||
} | ||
|
||
fl := existing[awsclients.StringValue(il.FunctionARN)] |
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.
fl := existing[awsclients.StringValue(il.FunctionARN)] | |
fl := existing[awsclients.StringValue(il.EventType)] |
7d91fad
to
0e27ceb
Compare
Signed-off-by: ezgidemirel <[email protected]>
0e27ceb
to
22f7401
Compare
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.
Thank you @ezgidemirel. We may consider opening a separate bug to track the issue spotted for the LambdaFunctionAssociation
s.
// If we have some lambda function associations, we need to late init each one of them | ||
existing := make(map[string]*svcsdk.LambdaFunctionAssociation) | ||
for i := range from.Items { | ||
o := from.Items[i] | ||
if o.LambdaFunctionARN == nil { | ||
continue | ||
} | ||
// TODO(ezgidemirel): Instead of using FunctionARNs, we should use EventTypes as keys |
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.
We may consider opening a bug in the repo. We may also consider switching back to dynamic late initialization.
Signed-off-by: ezgidemirel [email protected]
Description of your changes
This PR late initializes ResponseHeadersPolicyID and FunctionAssociation fields.
Fixes #1295
I have:
make reviewable test
to ensure this PR is ready for review.How has this code been tested
Created a distribution with ResponseHeadersPolicyID.