(ctx context.Context, functionName string, zipData []byte, roleArn string)
| 119 | } |
| 120 | |
| 121 | func (d *LambdaDeployer) createFunction(ctx context.Context, functionName string, zipData []byte, roleArn string) (*LambdaDeployResult, error) { |
| 122 | log.Printf("Creating new Lambda function...") |
| 123 | |
| 124 | modeConfig := config.GetModeConfigs()[d.cfg.Deployment.Mode] |
| 125 | |
| 126 | input := &lambda.CreateFunctionInput{ |
| 127 | FunctionName: aws.String(functionName), |
| 128 | Runtime: aws.String(lambda.RuntimeProvidedAl2), |
| 129 | Role: aws.String(roleArn), |
| 130 | Handler: aws.String("bootstrap"), |
| 131 | Code: &lambda.FunctionCode{ |
| 132 | ZipFile: zipData, |
| 133 | }, |
| 134 | Timeout: aws.Int64(int64(modeConfig.LambdaTimeout)), |
| 135 | MemorySize: aws.Int64(int64(modeConfig.LambdaMemory)), |
| 136 | Description: aws.String(fmt.Sprintf("QUIC NAT Proxy Lambda (%s mode)", d.cfg.Deployment.Mode)), |
| 137 | Environment: &lambda.Environment{ |
| 138 | Variables: map[string]*string{ |
| 139 | "MODE": aws.String(string(d.cfg.Deployment.Mode)), |
| 140 | }, |
| 141 | }, |
| 142 | Tags: map[string]*string{ |
| 143 | "Project": aws.String("lambda-nat-proxy"), |
| 144 | "Component": aws.String("lambda-function"), |
| 145 | "Mode": aws.String(string(d.cfg.Deployment.Mode)), |
| 146 | "ManagedBy": aws.String("lambda-nat-proxy-cli"), |
| 147 | "Environment": aws.String("production"), |
| 148 | "CostCenter": aws.String("lambda-nat-proxy"), |
| 149 | "Owner": aws.String("lambda-nat-proxy-cli"), |
| 150 | "Runtime": aws.String(lambda.RuntimeProvidedAl2), |
| 151 | }, |
| 152 | } |
| 153 | |
| 154 | result, err := d.clients.Lambda.CreateFunctionWithContext(ctx, input) |
| 155 | if err != nil { |
| 156 | return nil, fmt.Errorf("failed to create function: %w", err) |
| 157 | } |
| 158 | |
| 159 | log.Printf("Function created. ARN: %s", *result.FunctionArn) |
| 160 | |
| 161 | // Wait for function to be active |
| 162 | if err := d.waitForFunctionActive(ctx, functionName); err != nil { |
| 163 | return nil, fmt.Errorf("function creation failed: %w", err) |
| 164 | } |
| 165 | |
| 166 | log.Printf("Lambda function created successfully") |
| 167 | return d.extractFunctionInfo(result), nil |
| 168 | } |
| 169 | |
| 170 | func (d *LambdaDeployer) updateFunction(ctx context.Context, functionName string, zipData []byte) (*LambdaDeployResult, error) { |
| 171 | log.Printf("Updating existing Lambda function...") |
no test coverage detected