From 460aa7dcb54717b15c699487bbee98838a3f2f7f Mon Sep 17 00:00:00 2001 From: Chris Brown <1731074+ccbrown@users.noreply.github.com> Date: Sun, 20 Apr 2025 02:38:04 -0400 Subject: [PATCH 1/2] add scp management ui --- frontend/scripts/gather_aws_service_info.py | 40 + .../(public-area)/articles/[slug]/page.tsx | 7 +- .../teams/[teamId]/MapOverlays.tsx | 4 +- .../app/(user-area)/teams/[teamId]/Rules.tsx | 271 +++ .../app/(user-area)/teams/[teamId]/page.tsx | 21 +- frontend/src/app/globals.css | 3 + frontend/src/aws.ts | 1696 +++++++++++++++++ frontend/src/components/ChipEditor.tsx | 146 ++ frontend/src/components/SuccessMessage.tsx | 2 +- frontend/src/components/index.tsx | 1 + frontend/src/hooks.ts | 11 + frontend/src/models/aws.ts | 34 +- frontend/src/rules.ts | 174 ++ 13 files changed, 2403 insertions(+), 7 deletions(-) create mode 100755 frontend/scripts/gather_aws_service_info.py create mode 100644 frontend/src/app/(user-area)/teams/[teamId]/Rules.tsx create mode 100644 frontend/src/aws.ts create mode 100644 frontend/src/components/ChipEditor.tsx create mode 100644 frontend/src/rules.ts diff --git a/frontend/scripts/gather_aws_service_info.py b/frontend/scripts/gather_aws_service_info.py new file mode 100755 index 00000000..22adde58 --- /dev/null +++ b/frontend/scripts/gather_aws_service_info.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +import boto3 +import json +import time + +orgs = boto3.client('organizations') +iam = boto3.client('iam') + +roots = orgs.list_roots() +root = roots['Roots'][0] +entity_path = root['Arn'].split('/', 1)[1] + +job = iam.generate_organizations_access_report(EntityPath=entity_path) +job_id = job['JobId'] + +params = { + 'JobId': job_id, +} + +services = [] + +while True: + report = iam.get_organizations_access_report(**params) + if report['JobStatus'] == 'IN_PROGRESS': + time.sleep(1) + elif report['JobStatus'] == 'COMPLETED': + for service in report['AccessDetails']: + services.append({ + 'name': service['ServiceName'], + 'namespace': service['ServiceNamespace'], + }) + + if report['IsTruncated']: + params['Marker'] = report['Marker'] + else: + break + else: + raise Exception(f"Unexpected job status: {report['JobStatus']}") + +print(json.dumps(services, indent=2)) diff --git a/frontend/src/app/(public-area)/articles/[slug]/page.tsx b/frontend/src/app/(public-area)/articles/[slug]/page.tsx index fc1fa1c8..47ac85d9 100644 --- a/frontend/src/app/(public-area)/articles/[slug]/page.tsx +++ b/frontend/src/app/(public-area)/articles/[slug]/page.tsx @@ -55,7 +55,12 @@ export default async function Page({ params }: Props) {