Skip to content

Feature/aws account separation and proliferation - #513

Draft
andreasfrisch wants to merge 7 commits into
developfrom
feature/aws-account-separation-and-proliferation
Draft

andreasfrisch wants to merge 7 commits into
developfrom
feature/aws-account-separation-and-proliferation

Conversation

@andreasfrisch

Copy link
Copy Markdown
Contributor

🌟 Changes:

  • Requesting an AWS Account is now a separate process from requesting Kubernetes Namespace
  • Users are limited to 10 AWS Accounts and provide a string to indicate 'environment
  • When requesting a Kubernetes Namespace the users will provide a name and choose an existing account to link
  • A single AWS Account can be used for multiple Kubernetes Namespaces
  • Kubernetes IAM role and config storage in SSM works as normal
  • Separate events are triggered for the two chains of requests
  • The API returns information needed for the frontend to render things nicely

⚠️ Warning:

  • Breaks API (we could choose not to, but we need to update the frontend anyway)
  • ssu-k8s needs updating too, to handle the new events and use improved internal naming properly

🎶 Notes:

  • This should be backwards compliant
  • This should be (somewhat) easily supportive of multiple kubernetes clusters in the future

andreasfrisch and others added 5 commits September 1, 2026 09:55
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
andreasfrisch force-pushed the feature/aws-account-separation-and-proliferation branch from 970564c to 8c9590e Compare September 22, 2026 09:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 High severity · 5 Medium severity

Open (10)
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 thread db/seed/AwsAccount.csv
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants