(ctx context.Context, functionName string, zipData []byte)
| 168 | } |
| 169 | |
| 170 | func (d *LambdaDeployer) updateFunction(ctx context.Context, functionName string, zipData []byte) (*LambdaDeployResult, error) { |
| 171 | log.Printf("Updating existing Lambda function...") |
| 172 | |
| 173 | // Update function code |
| 174 | codeInput := &lambda.UpdateFunctionCodeInput{ |
| 175 | FunctionName: aws.String(functionName), |
| 176 | ZipFile: zipData, |
| 177 | } |
| 178 | |
| 179 | _, err := d.clients.Lambda.UpdateFunctionCodeWithContext(ctx, codeInput) |
| 180 | if err != nil { |
| 181 | return nil, fmt.Errorf("failed to update function code: %w", err) |
| 182 | } |
| 183 | |
| 184 | // Wait for update to complete |
| 185 | if err := d.waitForFunctionUpdated(ctx, functionName); err != nil { |
| 186 | return nil, fmt.Errorf("function code update failed: %w", err) |
| 187 | } |
| 188 | |
| 189 | // Update function configuration if needed |
| 190 | modeConfig := config.GetModeConfigs()[d.cfg.Deployment.Mode] |
| 191 | |
| 192 | configInput := &lambda.UpdateFunctionConfigurationInput{ |
| 193 | FunctionName: aws.String(functionName), |
| 194 | Timeout: aws.Int64(int64(modeConfig.LambdaTimeout)), |
| 195 | MemorySize: aws.Int64(int64(modeConfig.LambdaMemory)), |
| 196 | Environment: &lambda.Environment{ |
| 197 | Variables: map[string]*string{ |
| 198 | "MODE": aws.String(string(d.cfg.Deployment.Mode)), |
| 199 | }, |
| 200 | }, |
| 201 | } |
| 202 | |
| 203 | configResult, err := d.clients.Lambda.UpdateFunctionConfigurationWithContext(ctx, configInput) |
| 204 | if err != nil { |
| 205 | return nil, fmt.Errorf("failed to update function configuration: %w", err) |
| 206 | } |
| 207 | |
| 208 | // Wait for configuration update to complete |
| 209 | if err := d.waitForFunctionUpdated(ctx, functionName); err != nil { |
| 210 | return nil, fmt.Errorf("function configuration update failed: %w", err) |
| 211 | } |
| 212 | |
| 213 | log.Printf("Lambda function updated successfully") |
| 214 | |
| 215 | // Return the configuration result since it's more recent |
| 216 | return d.extractFunctionInfo(configResult), nil |
| 217 | } |
| 218 | |
| 219 | func (d *LambdaDeployer) functionExists(ctx context.Context, functionName string) (bool, error) { |
| 220 | input := &lambda.GetFunctionInput{ |
no test coverage detected