private void CreateEcrRepositories() { if (CdkOptions == null || CdkOptions.EcrRepositories?.Any() != true) { return; } StackResources.EcrRepositories = new Dictionary <string, IRepository>(); foreach (var ecrRepository in CdkOptions.EcrRepositories) { if (ecrRepository.LocateInsteadOfCreate) { StackResources.EcrRepositories.Add(ecrRepository.Id, AwsCdkHandler.LocateEcrRepositoryByName(ecrRepository.Id, ecrRepository.RepositoryName)); } else { var expiredImageLifeCycleRules = (ecrRepository.ExpireImageRules?.Any() == null || ecrRepository.ExpireImageRules?.Any() == false) ? null : ecrRepository.ExpireImageRules.ConvertAll(x => AwsCdkHandler.CreateEcrLifecycleRule(x.Description, x.MaxImageAgeDays, x.MaxImageNumber, x.PriorityOrder, x.TagPrefixList, x.TagStatus)); var imageTagMutability = ecrRepository.IsMutableImage ? TagMutability.MUTABLE : TagMutability.IMMUTABLE; StackResources.EcrRepositories.Add(ecrRepository.Id, AwsCdkHandler.AddEcrRepository(ecrRepository.RepositoryName, RemovalPolicy.DESTROY, imageTagMutability, ecrRepository.ImageScanOnPush, expiredImageLifeCycleRules)); } } }