Skip to content
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
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tag: v0.45.0
tag: v0.45.2

releaseNoteGenerator:
showCommitter: false
Expand Down
37 changes: 14 additions & 23 deletions pkg/app/piped/platformprovider/lambda/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ func (c *client) CreateFunctionFromSource(ctx context.Context, fm FunctionManife
}

func (c *client) UpdateFunction(ctx context.Context, fm FunctionManifest) error {
// UpdateFunctionConfiguration must be called before UpdateFunctionCode.
// Lambda has named by state.
// If Lambda's state is pending, UpdateFunctionConfiguration is failed. This error is explained as a ResourceConflictException.
// ref: https://docs.aws.amazon.com/lambda/latest/dg/troubleshooting-invocation.html
// Update function configuration.
if err := c.updateFunctionConfiguration(ctx, fm); err != nil {
return err
}
// Update function code.
codeInput := &lambda.UpdateFunctionCodeInput{
FunctionName: aws.String(fm.Spec.Name),
Expand All @@ -214,29 +222,6 @@ func (c *client) UpdateFunction(ctx context.Context, fm FunctionManifest) error
return fmt.Errorf("failed to update function code for Lambda function %s: %w", fm.Spec.Name, err)
}

// Update lambda function configuration
// TODO: @sivchari
// I focused on the vpc configuration, now. But, I think we should update all the configuration.
// So, I will update this part later.
if fm.Spec.VPCConfig != nil {
cfgInput := &lambda.UpdateFunctionConfigurationInput{
FunctionName: aws.String(fm.Spec.Name),
VpcConfig: &types.VpcConfig{
SecurityGroupIds: fm.Spec.VPCConfig.SecurityGroupIDs,
SubnetIds: fm.Spec.VPCConfig.SubnetIDs,
},
}
_, err = c.client.UpdateFunctionConfiguration(ctx, cfgInput)
if err != nil {
return fmt.Errorf("failed to update function configuration for Lambda function %s: %w", fm.Spec.Name, err)
}
}

// Update function configuration.
if err = c.updateFunctionConfiguration(ctx, fm); err != nil {
return err
}

// Tag/Untag function if necessary.
return c.updateTagsConfig(ctx, fm)
}
Expand Down Expand Up @@ -293,6 +278,12 @@ func (c *client) updateFunctionConfiguration(ctx context.Context, fm FunctionMan
if fm.Spec.Handler != "" {
configInput.Handler = aws.String(fm.Spec.Handler)
}
if fm.Spec.VPCConfig != nil {
configInput.VpcConfig = &types.VpcConfig{
SecurityGroupIds: fm.Spec.VPCConfig.SecurityGroupIDs,
SubnetIds: fm.Spec.VPCConfig.SubnetIDs,
}
}
_, err = c.client.UpdateFunctionConfiguration(ctx, configInput)
if err != nil {
c.logger.Error("Failed to update function configuration")
Expand Down