private void CreateEcsAutoScalingGroups() { if (CdkOptions == null || CdkOptions.AutoScalingGroups?.Any() != true) { return; } foreach (var autoScalingGroup in CdkOptions.AutoScalingGroups) { var vpc = LocateVpc(autoScalingGroup.VpcId, $"The VPC name {autoScalingGroup.VpcId} in Auto Scaling Group {autoScalingGroup.AutoScalingGroupName} does not exist"); var securityGroup = StackResources.SecurityGroups?.FirstOrDefault(s => s.Key == autoScalingGroup.SecurityGroupId).Value; var role = LocateRole(autoScalingGroup.RoleId, $"The role {autoScalingGroup.RoleId} does not exists"); var subnets = new List <ISubnet>(); foreach (var subnetId in autoScalingGroup.SubnetsId) { subnets.Add(LocateSubnet(subnetId, $"The subnet {subnetId} does not exists.")); } var asgGroup = AwsCdkHandler.AddAutoScalingGroup(autoScalingGroup.Id, autoScalingGroup.AutoScalingGroupName, autoScalingGroup.InstanceTypeId, autoScalingGroup.MachineImage, autoScalingGroup.AmiId, vpc, autoScalingGroup.AllowAllOutbound, autoScalingGroup.MinCapacity, autoScalingGroup.MaxCapacity, autoScalingGroup.DesiredCapacity, autoScalingGroup.MachineImageRegion, securityGroup, autoScalingGroup.CreationTimeOut, role, subnets.ToArray(), autoScalingGroup.KeyPairName, autoScalingGroup.EnableProtectionFromScaleIn, autoScalingGroup.BlockDevices, autoScalingGroup.UserData); StackResources.AutoScalingGroups.Add(autoScalingGroup.Id, asgGroup); } }