private SA_Stack ConvertStack(Stack awsStack) { try { var saStack = ModelTransformer <Stack, SA_Stack> . TransformAwsModelToSafeArrivalModel(awsStack); //saListener.Rule = awsListener.DefaultActions[0].Type.ToString() + // " to " + awsListener.DefaultActions[0].TargetGroupArn; if (awsStack.Tags.Count > 0 && awsStack.Tags.Find(o => o.Key == "Name") != null) { saStack.DisplayName = awsStack.Tags.Find(o => o.Key == "Name").Value; } else { saStack.DisplayName = awsStack.StackName; } return(saStack); } catch (Exception ex) { var x = awsStack; throw; } }
private SA_Subnet ConvertSubnet(Subnet awsSubnet) { SA_Subnet saSubnet = ModelTransformer <Subnet, SA_Subnet> .TransformAwsModelToSafeArrivalModel(awsSubnet); saSubnet.DisplayName = awsSubnet.Tags.Find(o => o.Key == "Name").Value; return(saSubnet); }
private SA_Listener ConvertListener(Listener awsListener) { var saListener = ModelTransformer <Listener, SA_Listener> . TransformAwsModelToSafeArrivalModel(awsListener); //saListener.Rule = awsListener.DefaultActions[0].Type.ToString() + // " to " + awsListener.DefaultActions[0].TargetGroupArn; saListener.TargetArn = awsListener.DefaultActions[0].TargetGroupArn; return(saListener); }
public async Task <List <SA_LoadBalancer> > GetLoadBalancerList() { var request = new DescribeLoadBalancersRequest(); var response = await client.DescribeLoadBalancersAsync(request); var lstLoadBalancers = ModelTransformer <LoadBalancer, SA_LoadBalancer> . TransformAwsModelListToSafeArrivalModelList(response.LoadBalancers); lstLoadBalancers = lstLoadBalancers.FindAll(o => o.LoadBalancerName.Contains($"{environment}-")); return(lstLoadBalancers); }
private SA_SecurityGroup ConvertSecurityGroup(SecurityGroup awsSecurityGroup) { try { SA_SecurityGroup saSecurityGroup = ModelTransformer <SecurityGroup, SA_SecurityGroup> .TransformAwsModelToSafeArrivalModel(awsSecurityGroup); saSecurityGroup.DisplayName = awsSecurityGroup.Tags.Find(o => o.Key == "Name").Value; return(saSecurityGroup); } catch (Exception ex) { throw ex; } }
public async Task <SA_TargetGroup> CreateTargetGroup( string name, string vpcId, string protocol, int port) { var request = new CreateTargetGroupRequest() { Name = name, VpcId = vpcId, Protocol = new ProtocolEnum(protocol), Port = 80 }; var response = await client.CreateTargetGroupAsync(request); return(ModelTransformer <TargetGroup, SA_TargetGroup> .TransformAwsModelToSafeArrivalModel(response.TargetGroups[0])); }
//public async Task<string> CreateLoadBalancer( // string name, List<string> securityGroups, List<string> subnets) //{ // var request = new CreateLoadBalancerRequest() // { // LoadBalancerName = name, // SecurityGroups = securityGroups, // Subnets = subnets, // IpAddressType = IpAddressType.Ipv4, // Scheme = LoadBalancerSchemeEnum.InternetFacing, // //Type = LoadBalancerTypeEnum.Application // }; // var response = await client.CreateLoadBalancerAsync(request); // return response.LoadBalancers[0].LoadBalancerArn; //} public async Task <List <SA_LoadBalancer> > GetLoadBalancerList() { List <SA_LoadBalancer> lstLoadBalancers = new List <SA_LoadBalancer>(); var request = new DescribeLoadBalancersRequest(); var response = await client.DescribeLoadBalancersAsync(request); var lstSourceELBs = response.LoadBalancerDescriptions; var reqTags = new DescribeTagsRequest() { LoadBalancerNames = response.LoadBalancerDescriptions.Select(o => o.LoadBalancerName).ToList() }; var respTags = await client.DescribeTagsAsync(reqTags); //LoadBalancer name like "awseb-e-c-AWSEBLoa-G25T4NILK22Q", need to get name from tag. foreach (var sourceELB in lstSourceELBs) { string tagName = string.Empty; //try //{ // var tags = respTags.TagDescriptions.Find // (o => o.LoadBalancerName == sourceELB.LoadBalancerName).Tags.Find(o => o.Key == "Name").Value; //} //catch //{ // continue; //} var tags = respTags.TagDescriptions.Find (o => o.LoadBalancerName == sourceELB.LoadBalancerName).Tags; var nameTag = tags.Find(o => o.Key == "Name"); if (nameTag == null) { continue; } tagName = nameTag.Value; if (!(tagName.IndexOf($"{environment}-{color}") == 0)) //check { continue; } var elb = ModelTransformer <LoadBalancerDescription, SA_LoadBalancer> . TransformAwsModelToSafeArrivalModel(sourceELB); elb.LoadBalancerName = tagName; lstLoadBalancers.Add(elb); } //lstLoadBalancers = lstLoadBalancers.FindAll(o => o.LoadBalancerName.Contains($"{environment}-")); return(lstLoadBalancers); }
//public async Task<PipelineDeclaration> Get() public async Task <List <SA_PipelineSummary> > GetCodePipelineList() { var response = await client.ListPipelinesAsync(); var lst = ModelTransformer <PipelineSummary, SA_PipelineSummary> . TransformAwsModelListToSafeArrivalModelList(response.Pipelines).FindAll(o => (o.Name.IndexOf($"{environment.ToString()}-") == 0 && (o.Name.Contains(color) || (!o.Name.Contains("green") && (!o.Name.Contains("blue")))))); lst.Sort((a, b) => b.Created.CompareTo(a.Created)); //foreach (var codePipeline in lst) //{ // var request = new ListPipelineExecutionsRequest() { PipelineName = codePipeline.Name }; // var x = client.ListPipelineExecutions(request); //} return(lst.ToList()); }
public async Task <List <SA_TargetGroup> > GetTargetGroupList(bool ignorColor = false) { var request = new DescribeTargetGroupsRequest(); var response = await client.DescribeTargetGroupsAsync(request); var lstTargetGroups = ModelTransformer <TargetGroup, SA_TargetGroup> . TransformAwsModelListToSafeArrivalModelList(response.TargetGroups); if (ignorColor) { lstTargetGroups = lstTargetGroups.FindAll(o => o.TargetGroupName.Contains($"{environment}-")); } else { lstTargetGroups = lstTargetGroups.FindAll(o => o.TargetGroupName.Contains($"{environment}-{color}-")); } return(lstTargetGroups); }
public async Task <List <ConfigurationOptionSettingModel> > GetScheduledActionSettingItems() { var ret = new List <ConfigurationOptionSettingModel>(); var requestSettings = new DescribeConfigurationSettingsRequest() { ApplicationName = $"Safe-Arrival-{ environment.ToString()}-{GlobalVariables.Color}", EnvironmentName = $"{ environment.ToString()}-{GlobalVariables.Color}-API", }; var response = await client.DescribeConfigurationSettingsAsync(requestSettings); var sourceSettings = response.ConfigurationSettings[0].OptionSettings.FindAll( o => o.Namespace == "aws:autoscaling:scheduledaction"); foreach (var settings in sourceSettings) { ret.Add(ModelTransformer <ConfigurationOptionSetting, ConfigurationOptionSettingModel> . TransformAwsModelToSafeArrivalModel(settings)); } return(ret); }