Feature/aws account separation and proliferation - #513
Draft
andreasfrisch wants to merge 7 commits into
Draft
andreasfrisch wants to merge 7 commits into
andreasfrisch wants to merge 7 commits into
Conversation
Automated PR - Merging develop into master
feat(catalog): expose reachability path in API responses
fix: portal base URL for Capability.NameLink variable wrong protocol
andreasfrisch
force-pushed
the
feature/aws-account-separation-and-proliferation
branch
from
September 22, 2026 09:42
970564c to
8c9590e
Compare
andreasfrisch
requested review from
SEQUOIIA
and
a lite review from Copilot
September 23, 2026 14:20
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 5
Open (10)
Backfill legacy AwsAccount links into KubernetesAccess · New Enforce the account cap under a capability-scoped lock · New Add Kubernetes RBAC grants to existing seeded roles · New Align advertised AWS account links with the GET route · New Correlate completion events with the exact KubernetesAccess record · New Seed KubernetesAccess records for existing seeded accounts · New Generate an item route for account self links · New Generate an item route for Kubernetes access self links · New Validate selected account status before requesting access · New Add namespace name to the Kubernetes access request · New
What changed in this PR
This PR separates AWS account provisioning from Kubernetes access requests, supporting multiple environment-specific accounts and namespaces per capability.
Changes:
- Adds environment-aware AWS account limits and APIs.
- Introduces Kubernetes access persistence, events, authorization, and compliance handling.
- Updates messaging, migrations, resources, and tests.
| File | Description |
|---|---|
| src/SelfService/Infrastructure/Persistence/TemplateRenderingService.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Persistence/SelfServiceDbContext.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Persistence/KubernetesAccessRepository.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Persistence/AwsAccountRepository.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Messaging/Legacy/K8sNamespaceCreatedAndAwsArnConnected.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Messaging/ConsumerConfiguration.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Api/Capabilities/NewKubernetesAccessRequest.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Api/Capabilities/NewAwsAccountRequest.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Api/Capabilities/KubernetesAccessApiResource.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Api/Capabilities/CapabilityDetailsApiResource.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Api/Capabilities/CapabilityController.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Api/Capabilities/AwsAccountsApiResource.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Api/Capabilities/AwsAccountApiResource.cs | Updated as part of this pull request. |
| src/SelfService/Infrastructure/Api/ApiResourceFactory.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Services/IAuthorizationService.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Services/AuthorizationService.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Models/RbacNamespace.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Models/KubernetesAccessStatus.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Models/KubernetesAccessId.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Models/KubernetesAccess.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Models/IKubernetesAccessRepository.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Models/IAwsAccountRepository.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Models/AwsAccount.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Exceptions/AwsAccountLimitExceededException.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Events/KubernetesAccessRequested.cs | Updated as part of this pull request. |
| src/SelfService/Domain/Events/AwsAccountRequested.cs | Updated as part of this pull request. |
| src/SelfService/Domain/AwsAccountConfiguration.cs | Updated as part of this pull request. |
| src/SelfService/Configuration/Domain.cs | Updated as part of this pull request. |
| src/SelfService/Application/StubComplianceApplicationService.cs | Updated as part of this pull request. |
| src/SelfService/Application/KubernetesAccessApplicationService.cs | Updated as part of this pull request. |
| src/SelfService/Application/IKubernetesAccessApplicationService.cs | Updated as part of this pull request. |
| src/SelfService/Application/IAwsAccountApplicationService.cs | Updated as part of this pull request. |
| src/SelfService/Application/ComplianceApplicationService.cs | Updated as part of this pull request. |
| src/SelfService/Application/AwsAccountApplicationService.cs | Updated as part of this pull request. |
| src/SelfService.Tests/TestDoubles/StubAwsAccountRepository.cs | Updated as part of this pull request. |
| src/SelfService.Tests/TestDoubles/StubAuthenticationService.cs | Updated as part of this pull request. |
| src/SelfService.Tests/Infrastructure/Persistence/TestTemplateRenderingService.cs | Updated as part of this pull request. |
| src/SelfService.Tests/Infrastructure/Persistence/TestPostgresMappings.cs | Updated as part of this pull request. |
| src/SelfService.Tests/Infrastructure/Api/TestCapabilityAwsAccountRoutes.cs | Updated as part of this pull request. |
| src/SelfService.Tests/Domain/Models/TestAwsAccount.cs | Updated as part of this pull request. |
| src/SelfService.Tests/Builders/ComplianceApplicationServiceBuilder.cs | Updated as part of this pull request. |
| src/SelfService.Tests/Builders/AwsAccountBuilder.cs | Updated as part of this pull request. |
| src/SelfService.Tests/Application/TestComplianceApplicationService.cs | Updated as part of this pull request. |
| db/seed/AwsAccount.csv | Updated as part of this pull request. |
| db/migrations/20260818110000_add-kubernetes-access-request-table.sql | Updated as part of this pull request. |
| db/migrations/20260818100000_add-environment-to-aws-account.sql | Updated as part of this pull request. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| "RequestedBy" varchar(255) NOT NULL, | ||
| "Namespace" varchar(255) NULL, | ||
| "GrantedAt" timestamp NULL | ||
| ); |
Comment on lines
+49
to
+53
| var accountCount = await _awsAccountRepository.CountBy(capabilityId); | ||
| if (accountCount >= AwsAccountConfiguration.MaxAccountsPerCapability) | ||
| { | ||
| throw new AwsAccountLimitExceededException( | ||
| $"Capability {capabilityId} has reached the maximum limit of {AwsAccountConfiguration.MaxAccountsPerCapability} AWS accounts" |
| public static readonly RbacNamespace CapabilityMembershipManagement = new("capability-membership-management"); | ||
| public static readonly RbacNamespace TagsAndMetadata = new("tags-and-metadata"); | ||
| public static readonly RbacNamespace Aws = new("aws"); | ||
| public static readonly RbacNamespace Kubernetes = new("kubernetes"); |
Comment on lines
+343
to
+344
| [HttpGet("{id:required}/awsaccounts")] | ||
| [ProducesResponseType(typeof(AwsAccountsApiResource), StatusCodes.Status200OK)] |
Comment on lines
+37
to
+40
| return _dbContext | ||
| .KubernetesAccesses.Where(x => x.AwsAccountId == awsAccountId && x.GrantedAt == null) | ||
| .OrderByDescending(x => x.RequestedAt) | ||
| .FirstOrDefaultAsync(); |
Comment on lines
+1
to
+3
| Id;AccountId;RoleEmail;RequestedAt;RequestedBy;CapabilityId;RegisteredAt;LinkedAt;Namespace;Environment | ||
| ECFF1558-DB23-4F1B-98DA-8235C5D49A76;123456789012;duno@duno.com;2023-02-24T08:00:00;SeedScript;cloudengineering-xxx;2023-02-24T08:05:00;2023-02-24T08:10:00;cloudengineering-xxx;prod | ||
| ECFF1558-DB23-4F1B-98DA-8235C5D49A78;123456789013;duno@duno.com;2023-02-24T08:00:00;SeedScript;notmycapability-xx1;2023-02-24T08:05:00;2023-02-24T08:10:00;notmycapability-xx1;prod |
Comment on lines
+934
to
+936
| action: nameof(CapabilityController.GetCapabilityAwsAccount), | ||
| controller: GetNameOf<CapabilityController>(), | ||
| values: new { id = account.CapabilityId } |
Comment on lines
+996
to
+1000
| href: _linkGenerator.GetUriByAction( | ||
| httpContext: HttpContext, | ||
| action: nameof(CapabilityController.GetKubernetesAccesses), | ||
| controller: GetNameOf<CapabilityController>(), | ||
| values: new { id = capabilityId } |
Comment on lines
+542
to
+549
| var account = await _awsAccountRepository.Get(awsAccountId); | ||
|
|
||
| if (account.CapabilityId != capabilityId) | ||
| return NotFound(); | ||
|
|
||
| await _kubernetesAccessApplicationService.RequestKubernetesAccess(awsAccountId, userId); | ||
|
|
||
| return Ok(); |
| public class NewKubernetesAccessRequest | ||
| { | ||
| [Required] | ||
| public string? AwsAccountId { get; set; } = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


🌟 Changes:
stringto indicate 'environmentssu-k8sneeds updating too, to handle the new events and use improved internal naming properly🎶 Notes: