DeployLambdaFunction deploys or updates a Lambda function
(ctx context.Context, zipPath, roleArn string)
| 50 | |
| 51 | // DeployLambdaFunction deploys or updates a Lambda function |
| 52 | func (d *LambdaDeployer) DeployLambdaFunction(ctx context.Context, zipPath, roleArn string) (*LambdaDeployResult, error) { |
| 53 | functionName := d.getFunctionName() |
| 54 | |
| 55 | log.Printf("Deploying Lambda function: %s", functionName) |
| 56 | |
| 57 | // Read the deployment package |
| 58 | zipData, err := os.ReadFile(zipPath) |
| 59 | if err != nil { |
| 60 | return nil, fmt.Errorf("failed to read deployment package: %w", err) |
| 61 | } |
| 62 | |
| 63 | exists, err := d.functionExists(ctx, functionName) |
| 64 | if err != nil { |
| 65 | return nil, fmt.Errorf("failed to check if function exists: %w", err) |
| 66 | } |
| 67 | |
| 68 | if exists { |
| 69 | return d.updateFunction(ctx, functionName, zipData) |
| 70 | } |
| 71 | |
| 72 | return d.createFunction(ctx, functionName, zipData, roleArn) |
| 73 | } |
| 74 | |
| 75 | // DeleteLambdaFunction deletes a Lambda function |
| 76 | func (d *LambdaDeployer) DeleteLambdaFunction(ctx context.Context) error { |
no test coverage detected