diff --git a/RELEASE b/RELEASE index 825b635623..fdda7628d4 100644 --- a/RELEASE +++ b/RELEASE @@ -1,4 +1,4 @@ -tag: v0.45.0 +tag: v0.45.2 releaseNoteGenerator: showCommitter: false diff --git a/pkg/app/piped/platformprovider/lambda/client.go b/pkg/app/piped/platformprovider/lambda/client.go index 1987da5b46..35ee06a011 100644 --- a/pkg/app/piped/platformprovider/lambda/client.go +++ b/pkg/app/piped/platformprovider/lambda/client.go @@ -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), @@ -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) } @@ -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")