-
Notifications
You must be signed in to change notification settings - Fork 23
Add resource-based permissions support for Lambda aliases #161
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
Add resource-based permissions support for Lambda aliases #161
Conversation
b2a38c6
to
1ecb947
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 @a-hilaly..left a few nits.
mainly about the yaml indent changes
Other than that lgtm 💯
apis/v1alpha1/generator.yaml
Outdated
- CreateCodeSigningConfigInput.Tags | ||
- CreateEventSourceMappingInput.DocumentDBEventSourceConfig | ||
- CreateEventSourceMappingInput.KMSKeyArn | ||
- CreateEventSourceMappingInput.MetricsConfig | ||
- CreateEventSourceMappingInput.ProvisionedPollerConfig | ||
- CreateEventSourceMappingInput.Tags | ||
- CreateEventSourceMappingOutput.FilterCriteriaError | ||
- CreateEventSourceMappingOutput.DocumentDBEventSourceConfig | ||
- CreateEventSourceMappingOutput.KMSKeyArn | ||
- CreateEventSourceMappingOutput.MetricsConfig | ||
- CreateEventSourceMappingOutput.ProvisionedPollerConfig | ||
- FunctionCode.SourceKMSKeyArn | ||
- CreateFunctionInput.LoggingConfig | ||
- CreateFunctionOutput.RuntimeVersionConfig | ||
- CreateFunctionOutput.LoggingConfig | ||
- CreateFunctionUrlConfigInput.InvokeMode | ||
- CreateFunctionUrlConfigOutput.InvokeMode | ||
- PublishVersionOutput.LoggingConfig | ||
- PublishVersionOutput.RuntimeVersionConfig | ||
- VpcConfig.Ipv6AllowedForDualStack | ||
- AddPermissionInput.FunctionName # We grab this from the Alias resource | ||
- AddPermissionInput.Qualifier # We grab this from the Alias resource |
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.
nit: why indent?
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 just got a new yaml linter..
pkg/resource/alias/hooks.go
Outdated
continue | ||
} | ||
rlog.Debug("removing permission", "statement_id", *p.StatementID) | ||
if err = rm.removePermission(ctx, desired, *p.StatementID); err != 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.
nit: why dereference StatementID here and change it back to pointer in removePermission?
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.
good catch, changed.
9749a48
to
6577d49
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.
Awesome @a-hilaly ! left one minor comment
// get the policy for the function using the alias name as the qualifier. now we don't | ||
// have to worry about function versions.. | ||
input := &svcsdk.GetPolicyInput{ | ||
FunctionName: aws.String(functionName), |
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.
nice!
pkg/resource/alias/hooks.go
Outdated
// Yes the API doesn't support updating permissions directly... yikes. | ||
func comparePermissions( | ||
desired []*svcapitypes.AddPermissionInput, | ||
existing []*svcapitypes.AddPermissionInput, |
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 []*svcapitypes.AddPermissionInput, | |
latest []*svcapitypes.AddPermissionInput, |
nit: can we call this latest for consistency
rlog := ackrtlog.FromContext(ctx) | ||
exit := rlog.Trace("rm.removePermission") | ||
var err error | ||
defer func() { exit(err) }() |
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.
nice!
this commit adds support for managing Lambda resource based permissions directly on aliases. Now users can declaratively define, update, and remove permissions for Lambda functions accessed through aliases. The implementation leverages the AWS::Lambda `AddPermission` and `RemovePermission` APIs to synchronize the desired permissions state defined in the CRD with the actual alias permisions in AWS.
6577d49
to
52a04eb
Compare
@a-hilaly: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
thanks @a-hilaly 🚀 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: a-hilaly, michaelhtm, rushmash91 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
this commit adds support for managing Lambda resource based permissions directly
on aliases. Now users can declaratively define, update, and remove permissions
for Lambda functions accessed through aliases.
The implementation leverages the AWS::Lambda
AddPermission
andRemovePermission
APIs to synchronize the desired permissions state defined in the CRD with the
actual alias permisions in AWS.
Example alias:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.