Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 37 additions & 23 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,41 +53,40 @@ AWS Lab Infrastructure Visualizer is a web application that provides visual repr

```
┌─────────────────────────────────────────────────────────────────────┐
│ Frontend (React + TypeScript)
│ Frontend (React + TypeScript) │
│ ┌─────────────┐ ┌──────────────┐ ┌─────────────────────────────┐ │
│ │ Pages │ │ Components │ │ Topology Visualization │ │
│ │ VPCPage │ │ common/ │ │ (React Flow) │ │
│ │ │ │ dashboard/ │ │ VPC → Subnet → EC2/RDS │ │
│ └─────────────┘ │ vpc/ │ └─────────────────────────────┘ │
│ │ topology/ │ │
│ │ resources/ │ │
│ │ layout/ │ │
│ └──────────────┘ │
│ │ ECSList │ │ dashboard/ │ │ VPC → Subnet → EC2/RDS/ECS │ │
│ │ Settings │ │ vpc/ │ └─────────────────────────────┘ │
│ │ Login │ │ topology/ │ │
│ └─────────────┘ │ settings/ │ │
│ │ resources/ │ │
│ │ layout/ │ │
│ └──────────────┘ │
└───────────────────────────┬─────────────────────────────────────────┘
│ HTTP/REST
┌─────────────────────────────────────────────────────────────────────┐
│ FastAPI Backend
│ FastAPI Backend │
│ ┌──────────────┐ ┌──────────────┐ ┌────────────────────────────┐ │
│ │ API Routes │ │ Services │ │ Collectors │ │
│ │ /api/* │→ │ Business │→ │ EC2, RDS, ECS, VPC │ │
│ │ │ │ Logic │ │ Subnet, IGW, NAT GW, EIP │ │
│ └──────────────┘ └──────────────┘ └──────────┬─────────────────┘ │
│ │ │
│ ┌──────────────┐ ┌──────────────┐ │ │
│ │ Parsers │ │ Models │ │ │
│ │ Terraform │ │ SQLAlchemy │ │ │
│ │ State │ │ Database │ │ │
│ └──────────────┘ └──────────────┘ │ │
└──────────────────────────────────────────────────┼───────────────────┘
┌──────────────────────────────────────────┼──────────────────┐
│ │ │
▼ ▼ │
┌──────────────────┐ ┌──────────────────────┐ │
│ Terraform State │ │ AWS APIs │ │
│ (S3 Backend) │ │ EC2, RDS, VPC, etc. │ │
└──────────────────┘ └──────────────────────┘ │
│ │ │
│ ┌──────────────┐ ┌──────────────┐ │ │
│ │ Parsers │ │ Models │ │ │
│ │ Terraform │ │ SQLAlchemy │ │ │
│ │ State │ │ Database │ │ │
│ └──────┬───────┘ └──────────────┘ │ │
└─────────┼───────────────────────────────────────┼───────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌───────────────────────────┐
│ Terraform State │ │ AWS APIs │
│ (S3 Backend) │ │ EC2, RDS, ECS, VPC, etc. │
└──────────────────┘ └───────────────────────────┘
```

## Directory Structure
Expand Down Expand Up @@ -617,6 +616,21 @@ persists independently of the deployment mechanism.
],
"Resource": "*"
},
{
"Sid": "ECSReadAccess",
"Effect": "Allow",
"Action": [
"ecs:DescribeClusters",
"ecs:ListClusters",
"ecs:DescribeServices",
"ecs:ListServices",
"ecs:DescribeTasks",
"ecs:ListTasks",
"ecs:DescribeTaskDefinition",
"ecs:DescribeContainerInstances"
],
"Resource": "*"
},
{
"Sid": "S3TerraformStateAccess",
"Effect": "Allow",
Expand Down
60 changes: 37 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,40 @@ A web application that provides visual representation of AWS infrastructure stat

```
┌─────────────────────────────────────────────────────────────────────┐
│ Frontend (React + TypeScript)
│ Frontend (React + TypeScript) │
│ ┌─────────────┐ ┌──────────────┐ ┌─────────────────────────────┐ │
│ │ Pages │ │ Components │ │ Topology Visualization │ │
│ │ VPCPage │ │ common/ │ │ (React Flow) │ │
│ │ │ │ dashboard/ │ │ VPC → Subnet → EC2/RDS │ │
│ └─────────────┘ │ vpc/ │ └─────────────────────────────┘ │
│ │ topology/ │ │
│ │ resources/ │ │
│ │ layout/ │ │
│ └──────────────┘ │
│ │ ECSList │ │ dashboard/ │ │ VPC → Subnet → EC2/RDS/ECS │ │
│ │ Settings │ │ vpc/ │ └─────────────────────────────┘ │
│ │ Login │ │ topology/ │ │
│ └─────────────┘ │ settings/ │ │
│ │ resources/ │ │
│ │ layout/ │ │
│ └──────────────┘ │
└───────────────────────────┬─────────────────────────────────────────┘
│ HTTP/REST
┌─────────────────────────────────────────────────────────────────────┐
│ FastAPI Backend
│ FastAPI Backend │
│ ┌──────────────┐ ┌──────────────┐ ┌────────────────────────────┐ │
│ │ API Routes │ │ Services │ │ Collectors │ │
│ │ /api/* │→ │ Business │→ │ EC2, RDS, ECS, VPC │ │
│ │ │ │ Logic │ │ Subnet, IGW, NAT GW, EIP │ │
│ └──────────────┘ └──────────────┘ └──────────┬─────────────────┘ │
│ │ │
│ ┌──────────────┐ ┌──────────────┐ │ │
│ │ Parsers │ │ Models │ │ │
│ │ Terraform │ │ SQLAlchemy │ │ │
│ │ State │ │ Database │ │ │
│ └──────────────┘ └──────────────┘ │ │
└──────────────────────────────────────────────────┼───────────────────┘
┌──────────────────────────────────────────┼──────────────────┐
│ │ │
▼ ▼ │
┌──────────────────┐ ┌──────────────────────┐ │
│ Terraform State │ │ AWS APIs │ │
│ (S3 Backend) │ │ EC2, RDS, VPC, etc. │ │
└──────────────────┘ └──────────────────────┘ │
│ │ │
│ ┌──────────────┐ ┌──────────────┐ │ │
│ │ Parsers │ │ Models │ │ │
│ │ Terraform │ │ SQLAlchemy │ │ │
│ │ State │ │ Database │ │ │
│ └──────┬───────┘ └──────────────┘ │ │
└─────────┼───────────────────────────────────────┼───────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌───────────────────────────┐
│ Terraform State │ │ AWS APIs │
│ (S3 Backend) │ │ EC2, RDS, ECS, VPC, etc. │
└──────────────────┘ └───────────────────────────┘
```

## Quick Start
Expand Down Expand Up @@ -464,6 +463,21 @@ The application task role is managed by the standalone `iam` module (`infrastruc
],
"Resource": "*"
},
{
"Sid": "ECSReadAccess",
"Effect": "Allow",
"Action": [
"ecs:DescribeClusters",
"ecs:ListClusters",
"ecs:DescribeServices",
"ecs:ListServices",
"ecs:DescribeTasks",
"ecs:ListTasks",
"ecs:DescribeTaskDefinition",
"ecs:DescribeContainerInstances"
],
"Resource": "*"
},
{
"Sid": "S3TerraformStateAccess",
"Effect": "Allow",
Expand Down
1 change: 1 addition & 0 deletions infrastructure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The `iam` module is intentionally separate from the `ecs` module so that the app
- **Application task role**: Assumed by ECS tasks via `ecs-tasks.amazonaws.com`
- **EC2 read-only policy**: `DescribeInstances`, `DescribeVpcs`, `DescribeSubnets`, `DescribeRouteTables`, `DescribeInternetGateways`, `DescribeNatGateways`, `DescribeAddresses`, etc.
- **RDS read-only policy**: `DescribeDBInstances`, `DescribeDBClusters`, `ListTagsForResource`
- **ECS read-only policy**: `DescribeClusters`, `ListClusters`, `DescribeServices`, `ListServices`, `DescribeTasks`, `ListTasks`, `DescribeTaskDefinition`, `DescribeContainerInstances`
- **S3 Terraform state policy**: `GetObject`, `ListBucket`, `GetBucketLocation` scoped to the current AWS account

### Secrets Module
Expand Down
1 change: 1 addition & 0 deletions infrastructure/modules/iam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Provisions IAM roles and policies for the backend application task role. This mo
- **Application task role**: Assumed by ECS tasks via `ecs-tasks.amazonaws.com`
- **EC2 monitoring policy**: Read-only access to EC2, VPC, subnet, route table, internet gateway, NAT gateway, and elastic IP resources
- **RDS monitoring policy**: Read-only access to RDS instances, clusters, and tags
- **ECS monitoring policy**: Read-only access to ECS clusters, services, tasks, task definitions, and container instances (`DescribeClusters`, `ListClusters`, `DescribeServices`, `ListServices`, `DescribeTasks`, `ListTasks`, `DescribeTaskDefinition`, `DescribeContainerInstances`)
- **S3 Terraform state policy**: Read access to S3 objects and bucket listing, scoped to the current AWS account

## Variables
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/modules/iam/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =============================================================================
# IAM Module
# Creates IAM role and policies for the backend application to monitor
# AWS infrastructure (EC2, RDS, VPC, Subnets, IGW, NAT Gateway, EIP)
# AWS infrastructure (EC2, RDS, ECS, VPC, Subnets, IGW, NAT Gateway, EIP)
# =============================================================================

data "aws_caller_identity" "current" {}
Expand Down Expand Up @@ -33,7 +33,7 @@

# -----------------------------------------------------------------------------
# AWS Infrastructure Monitoring Policy
# Grants read-only access to EC2, VPC, and RDS resources
# Grants read-only access to EC2, VPC, RDS, and ECS resources
# -----------------------------------------------------------------------------

resource "aws_iam_role_policy" "aws_monitoring" {
Expand Down Expand Up @@ -94,7 +94,7 @@
# Scoped to the current AWS account
# -----------------------------------------------------------------------------

resource "aws_iam_role_policy" "s3_terraform_state" {

Check warning on line 97 in infrastructure/modules/iam/main.tf

View workflow job for this annotation

GitHub Actions / TFLint Analysis

Missing version constraint for provider "aws" in `required_providers`
name = "s3-terraform-state-access"
role = aws_iam_role.app_task.id

Expand Down
Loading