private void CheckLambdaParams(LambdaOptions lambda) { if (string.IsNullOrWhiteSpace(lambda.Id)) { throw new ArgumentException($"All lambdas must have a {nameof(lambda.Id)}"); } if (string.IsNullOrWhiteSpace(lambda.FunctionName)) { throw new ArgumentException($"All lambdas must have a {nameof(lambda.FunctionName)}"); } if (string.IsNullOrWhiteSpace(lambda.Role)) { throw new ArgumentException($"The lambda {lambda.FunctionName} must have a role"); } if (string.IsNullOrWhiteSpace(lambda.FunctionHandler)) { throw new ArgumentException($"The lambda {lambda.FunctionName} must have a handler"); } if (string.IsNullOrWhiteSpace(lambda.Runtime)) { throw new ArgumentException($"The lambda {lambda.FunctionName} must have a runtime"); } CheckLambdaSourceCodeParams(lambda); }
private void GetLambdaResources(LambdaOptions lambda, out IRole role, out ISecurityGroup securityGroup, out IVpc vpc, out ISubnet[] subnets, out IBucket bucket, out Dictionary <string, string> environmentVariables) { // Locate role role = LocateRole(lambda.Role, $"The role {lambda.Role} of the lambda {lambda.FunctionName} was not found"); // Locate security group securityGroup = LocateSecurityGroup(lambda.SecurityGroupId, $"The security group {lambda.SecurityGroupId} of the lambda {lambda.FunctionName} was not found"); // Locate vpc vpc = LocateVpc(lambda.VpcId, $"The VPC {lambda.VpcId} of the lambda {lambda.FunctionName} was not found"); // Locate subnets if (lambda.SubnetIds?.Any() != true) { subnets = null; } else { var subnetList = new List <ISubnet>(lambda.SubnetIds.Length); foreach (var subnetId in lambda.SubnetIds) { subnetList.Add(LocateSubnet(subnetId, $"The subnet {subnetId} of the lambda {lambda.FunctionName} was not found", $"The subnet ids of the lambda {lambda.FunctionName} can not be empty")); } subnets = subnetList.ToArray(); } // Locate bucket bucket = LocateBucket(lambda.SourceCode?.CodeBucket?.BucketName, $"The bucket {lambda.SourceCode.CodeBucket.BucketName} of the lambda {lambda.FunctionName} was not found"); if (lambda.LambdaEnvironmentVariables?.Any() == true) { environmentVariables = new Dictionary <string, string>(); foreach (var environmentVariable in lambda.LambdaEnvironmentVariables) { environmentVariables.Add(environmentVariable.EnvironmentVariableName, environmentVariable.EnvironmentVariableValue); } } else { environmentVariables = null; } }
private void CheckLambdaSourceCodeParams(LambdaOptions lambda) { if (lambda.SourceCode == null) { throw new ArgumentException($"The source code options of the lambda {lambda.FunctionName} can not be null"); } if (string.IsNullOrWhiteSpace(lambda.SourceCode.CodeZipFilePath) && (lambda.SourceCode.CodeBucket == null || (string.IsNullOrWhiteSpace(lambda.SourceCode.CodeBucket.BucketName) && string.IsNullOrWhiteSpace(lambda.SourceCode.CodeBucket.FilePath)))) { throw new ArgumentException($"There must be at least one source code option in the code options of the lambda {lambda.SourceCode}"); } if (!string.IsNullOrWhiteSpace(lambda.SourceCode.CodeZipFilePath) && lambda.SourceCode.CodeBucket != null && !string.IsNullOrWhiteSpace(lambda.SourceCode.CodeBucket.BucketName) && !string.IsNullOrWhiteSpace(lambda.SourceCode.CodeBucket.FilePath)) { throw new ArgumentException($"There can not be two source code options in the code options of the lambda {lambda.SourceCode}"); } }
public void OnGet() { this.SampleRequests = new SampleRequestManager(LambdaOptions.GetPreferenceDirectory(false)).GetSampleRequests(); }