private string AskUserForCloudApplicationName(ProjectDefinition project, List <CloudApplication> existingApplications) { var defaultName = ""; try { defaultName = _cloudApplicationNameGenerator.GenerateValidName(project, existingApplications); } catch { } var cloudApplicationName = ""; while (true) { _toolInteractiveService.WriteLine(); if (!existingApplications.Any()) { var title = "Name the AWS stack to deploy your application to" + Environment.NewLine + "(A stack is a collection of AWS resources that you can manage as a single unit.)" + Environment.NewLine + "--------------------------------------------------------------------------------"; cloudApplicationName = _consoleUtilities.AskUserForValue( title, defaultName, allowEmpty: false, defaultAskValuePrompt: Constants.CLI.PROMPT_NEW_STACK_NAME); } else { var title = "Select the AWS stack to deploy your application to" + Environment.NewLine + "(A stack is a collection of AWS resources that you can manage as a single unit.)"; var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew( existingApplications.Select(x => x.Name), title, askNewName: true, defaultNewName: defaultName, defaultChoosePrompt: Constants.CLI.PROMPT_CHOOSE_STACK_NAME, defaultCreateNewPrompt: Constants.CLI.PROMPT_NEW_STACK_NAME, defaultCreateNewLabel: Constants.CLI.CREATE_NEW_STACK_LABEL); cloudApplicationName = userResponse.SelectedOption ?? userResponse.NewName; } if (!string.IsNullOrEmpty(cloudApplicationName) && _cloudApplicationNameGenerator.IsValidName(cloudApplicationName)) { return(cloudApplicationName); } PrintInvalidStackNameMessage(); } }
public async Task <object> Execute(Recommendation recommendation, OptionSettingItem optionSetting) { var currentValue = recommendation.GetOptionSettingValue(optionSetting); var keyPairs = await _awsResourceQueryer.ListOfEC2KeyPairs(); var userInputConfiguration = new UserInputConfiguration <KeyPairInfo>( kp => kp.KeyName, kp => kp.KeyName.Equals(currentValue) ) { AskNewName = true, EmptyOption = true, CurrentValue = currentValue }; var settingValue = ""; while (true) { var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew(keyPairs, "Select key pair to use:", userInputConfiguration); if (userResponse.IsEmpty) { settingValue = ""; break; } else { settingValue = userResponse.SelectedOption?.KeyName ?? userResponse.NewName ?? throw new UserPromptForNameReturnedNullException("The user prompt for a new EC2 Key Pair name was null or empty."); } if (userResponse.CreateNew && !string.IsNullOrEmpty(userResponse.NewName)) { _toolInteractiveService.WriteLine(string.Empty); _toolInteractiveService.WriteLine("You have chosen to create a new key pair."); _toolInteractiveService.WriteLine("You are required to specify a directory to save the key pair private key."); var answer = _consoleUtilities.AskYesNoQuestion("Do you want to continue?", "false"); if (answer == YesNo.No) { continue; } _toolInteractiveService.WriteLine(string.Empty); _toolInteractiveService.WriteLine($"A new key pair will be created with the name {settingValue}."); var keyPairDirectory = _consoleUtilities.AskForEC2KeyPairSaveDirectory(recommendation.ProjectPath); await _awsResourceQueryer.CreateEC2KeyPair(settingValue, keyPairDirectory); } break; } return(settingValue ?? ""); }
public async Task <object> Execute(Recommendation recommendation, OptionSettingItem optionSetting) { var currentValue = recommendation.GetOptionSettingValue(optionSetting); var platformArns = await _awsResourceQueryer.GetElasticBeanstalkPlatformArns(); var userInputConfiguration = new UserInputConfiguration <PlatformSummary>( platform => $"{platform.PlatformBranchName} v{platform.PlatformVersion}", platform => platform.PlatformArn.Equals(currentValue)) { CreateNew = false }; var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew(platformArns, "Select the Platform to use:", userInputConfiguration); return(userResponse.SelectedOption?.PlatformArn !); }
public async Task <object> Execute(Recommendation recommendation, OptionSettingItem optionSetting) { var currentValue = recommendation.GetOptionSettingValue(optionSetting); var applicationOptionSetting = recommendation.GetOptionSetting(optionSetting.ParentSettingId); var applicationName = recommendation.GetOptionSettingValue(applicationOptionSetting) as string; var environments = await _awsResourceQueryer.ListOfElasticBeanstalkEnvironments(applicationName); var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew( options: environments.Select(env => env.EnvironmentName), title: "Select Elastic Beanstalk environment to deploy to:", askNewName: true, defaultNewName: currentValue.ToString() ?? ""); return(userResponse.SelectedOption ?? userResponse.NewName ?? throw new UserPromptForNameReturnedNullException("The user response for a new environment name was null.")); }
public async Task <object> Execute(Recommendation recommendation, OptionSettingItem optionSetting) { var loadBalancers = await _awsResourceQueryer.ListOfLoadBalancers(LoadBalancerTypeEnum.Application); var currentValue = recommendation.GetOptionSettingValue <string>(optionSetting); var userInputConfiguration = new UserInputConfiguration <LoadBalancer>( loadBalancer => loadBalancer.LoadBalancerName, loadBalancer => loadBalancer.LoadBalancerArn.Equals(currentValue)) { AskNewName = false }; var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew(loadBalancers, "Select Load Balancer to deploy to:", userInputConfiguration); return(userResponse.SelectedOption?.LoadBalancerArn ?? string.Empty); }
public async Task <object> Execute(Recommendation recommendation, OptionSettingItem optionSetting) { var typeHintData = optionSetting.GetTypeHintData <IAMRoleTypeHintData>(); var existingRoles = await _awsResourceQueryer.ListOfIAMRoles(typeHintData?.ServicePrincipal); var currentTypeHintResponse = recommendation.GetOptionSettingValue <IAMRoleTypeHintResponse>(optionSetting); var userInputConfiguration = new UserInputConfiguration <Role>( role => role.RoleName, role => currentTypeHintResponse.RoleArn?.Equals(role.Arn) ?? false); var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew(existingRoles, "Select an IAM role", userInputConfiguration); return(new IAMRoleTypeHintResponse { CreateNew = userResponse.CreateNew, RoleArn = userResponse.SelectedOption?.Arn }); }
public async Task <object> Execute(Recommendation recommendation, OptionSettingItem optionSetting) { var clusters = await _awsResourceQueryer.ListOfECSClusters(); var currentTypeHintResponse = recommendation.GetOptionSettingValue <ECSClusterTypeHintResponse>(optionSetting); var userInputConfiguration = new UserInputConfiguration <Cluster>( cluster => cluster.ClusterName, cluster => cluster.ClusterArn.Equals(currentTypeHintResponse?.ClusterArn), currentTypeHintResponse.NewClusterName) { AskNewName = true }; var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew(clusters, "Select ECS cluster to deploy to:", userInputConfiguration); return(new ECSClusterTypeHintResponse( userResponse.CreateNew, userResponse.SelectedOption?.ClusterArn ?? string.Empty, userResponse.NewName ?? string.Empty)); }
public async Task <object> Execute(Recommendation recommendation, OptionSettingItem optionSetting) { var applications = await _awsResourceQueryer.ListOfElasticBeanstalkApplications(); var currentTypeHintResponse = recommendation.GetOptionSettingValue <BeanstalkApplicationTypeHintResponse>(optionSetting); var userInputConfiguration = new UserInputConfiguration <ApplicationDescription>( app => app.ApplicationName, app => app.ApplicationName.Equals(currentTypeHintResponse?.ApplicationName), currentTypeHintResponse.ApplicationName) { AskNewName = true, }; var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew(applications, "Select Elastic Beanstalk application to deploy to:", userInputConfiguration); return(new BeanstalkApplicationTypeHintResponse( userResponse.CreateNew, userResponse.SelectedOption?.ApplicationName ?? userResponse.NewName ?? throw new UserPromptForNameReturnedNullException("The user response for a new application name was null.") )); }
public async Task <object> Execute(Recommendation recommendation, OptionSettingItem optionSetting) { var currentVpcTypeHintResponse = optionSetting.GetTypeHintData <VpcTypeHintResponse>(); var vpcs = await _awsResourceQueryer.GetListOfVpcs(); var userInputConfig = new UserInputConfiguration <Vpc>( vpc => { var name = vpc.Tags?.FirstOrDefault(x => x.Key == "Name")?.Value ?? string.Empty; var namePart = string.IsNullOrEmpty(name) ? "" : $" ({name}) "; var isDefaultPart = vpc.IsDefault ? " *** Account Default VPC ***" : ""; return($"{vpc.VpcId}{namePart}{isDefaultPart}"); }, vpc => !string.IsNullOrEmpty(currentVpcTypeHintResponse?.VpcId) ? vpc.VpcId == currentVpcTypeHintResponse.VpcId : vpc.IsDefault); var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew( vpcs, "Select a VPC", userInputConfig); return(new VpcTypeHintResponse( userResponse.SelectedOption?.IsDefault == true, userResponse.CreateNew, userResponse.SelectedOption?.VpcId ?? "" )); }