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
40 changes: 40 additions & 0 deletions .github/workflows/app-gitops-guardrails.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: app-gitops-guardrails

on:
pull_request:
branches: [ main ]
paths:
- 'applications/**'
- '.github/workflows/app-gitops-guardrails.yml'

permissions:
contents: read

jobs:
app-policy-checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Validate Kubernetes manifests with kubeconform
shell: bash
run: |
set -euo pipefail

curl -sSL -o kubeconform.tar.gz \
https://github.com/yannh/kubeconform/releases/latest/download/kubeconform-linux-amd64.tar.gz
tar -xzf kubeconform.tar.gz kubeconform

mapfile -t manifest_files < <(find applications/gitops/base -type f \( -name '*.yaml' -o -name '*.yml' \) | sort)

if [ "${#manifest_files[@]}" -eq 0 ]; then
echo "No Kubernetes manifests found in applications/gitops/base"
exit 1
fi

./kubeconform -strict -summary "${manifest_files[@]}"

- name: Policy test placeholder (OPA/Kyverno)
run: |
echo "Run conftest / kyverno CLI checks here"
41 changes: 41 additions & 0 deletions .github/workflows/platform-iac-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: platform-iac-ci

on:
pull_request:
branches: [ main ]
paths:
- 'platform/**'
- 'lib/**'
- 'bin/**'
- '.github/workflows/platform-iac-ci.yml'

permissions:
contents: read

jobs:
quality-gates:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install deps
run: npm ci

- name: Format check
run: npm run build

- name: CDK synth
run: npx cdk synth

- name: Static security scan (Checkov)
uses: bridgecrewio/checkov-action@v12
with:
directory: .
framework: cloudformation,terraform,github_actions
quiet: true
48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
SHELL := /bin/bash
ENV ?= dev
SERVICE ?= sample-service
TAG ?= latest

.PHONY: help build test synth platform-check platform-plan platform-apply app-bootstrap app-deploy platform-progress

help:
@echo "make build # Build TypeScript"
@echo "make test # Run tests"
@echo "make synth # CDK synth"
@echo "make platform-check # Build + synth + lint placeholder"
@echo "make platform-plan ENV=dev # Plan platform changes"
@echo "make platform-apply ENV=dev # Apply platform changes"
@echo "make app-bootstrap SERVICE=name # Bootstrap app from template"
@echo "make app-deploy ENV=dev SERVICE=name TAG=v1.0.0"
@echo "make platform-progress # Show platform-as-product progress tracker"

build:
npm run build

test:
npm test

synth:
npx cdk synth

platform-check: build synth
@echo "[platform-check] add checkov/tfsec/cdk-nag in CI"

platform-plan:
@echo "[platform-plan] ENV=$(ENV)"
@echo "Use environment overlays in platform/environments/$(ENV)"

platform-apply:
@echo "[platform-apply] ENV=$(ENV)"
@echo "Run approved deploy pipeline for $(ENV)"

app-bootstrap:
@echo "[app-bootstrap] SERVICE=$(SERVICE)"
@echo "Scaffold from templates/service-catalog/template.yaml via Backstage"

app-deploy:
@echo "[app-deploy] ENV=$(ENV) SERVICE=$(SERVICE) TAG=$(TAG)"
@echo "Update GitOps manifest tag and let Argo CD reconcile"

platform-progress:
@cat docs/platform-product-progress.md
130 changes: 76 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,97 @@
# InfraAsCodeWithCDK
# Platform as a Product Blueprint (AWS + CDK)

# Overview
This project deploys a serverless application using AWS CDK with TypeScript, including API Gateway, Lambda, and DynamoDB.
This repository has been transformed from a single-stack IaC project into a **Platform Engineering starter** with a clear separation between:

## Prerequisites
- Node.js 18.x or later
- AWS CLI configured
- AWS CDK CLI (`npm install -g aws-cdk`)
- **Platform layer** (shared capabilities operated by platform team)
- **Application layer** (self-service onboarding and app delivery operated by developers)

## Quick Start
It now provides opinionated architecture, repository layout, templates, and delivery workflows to support a scalable **Internal Developer Platform (IDP)**.

1. **Install dependencies**
```bash
npm install
## What is included

AWS_ACCOUNT_ID=account-id
AWS_REGION=aws-region
- A target platform architecture with:
- Amazon EKS for workload runtime
- GitOps with Argo CD
- Backstage as the developer portal
- Secure-by-default guardrails and policy checks
- Repository structure for multi-team and multi-environment operation
- Backstage software template example for self-service service creation
- CI pipeline for platform IaC quality gates (fmt/validate/lint/security)
- GitOps-oriented app delivery guardrails
- Day-2 DX helpers via `Makefile`

Deploy
cdk bootstrap # First time only
cdk deploy
## Repository structure

Stack Components
```text
.
├── platform/
│ ├── modules/ # Reusable building blocks (network, EKS, observability, security)
│ ├── services/ # Platform services (argocd, backstage, observability, security)
│ └── environments/
│ ├── dev/
│ ├── stage/
│ └── prod/
├── applications/
│ ├── templates/ # Golden path app templates
│ └── gitops/
│ ├── base/
│ └── overlays/
│ ├── dev/
│ ├── stage/
│ └── prod/
├── templates/
│ └── service-catalog/ # Backstage software template example
├── docs/
│ └── platform-product-architecture.md
├── .github/workflows/ # Platform CI and GitOps checks
└── Makefile
```

API Gateway REST API
Lambda Function (Node.js)
DynamoDB Table
CloudWatch Logging
## Recommended-path developer workflow

Request flow :
Template ID: `recommended-path-k8s-service`

Client → API Gateway → Lambda → DynamoDB
↑ ↓ ↓ ↓
└──────── Response ← Data ← Databasen
1. Developer opens Backstage and chooses the **recommended path** service template.
2. Template scaffolds:
- service repo structure
- Kubernetes manifests/Helm chart
- CI pipeline and GitOps app definition
- observability and security defaults
3. Developer merges app code to main.
4. CI builds/tests/scans image, updates GitOps manifest/tag.
5. Argo CD reconciles environment cluster automatically.
6. Service is deployed with metrics, logs, traces, and policy validation enabled by default.

See detailed architecture and workflows in:

- `docs/platform-product-architecture.md`
- `templates/service-catalog/template.yaml`

Useful Commands
npm run build # Compile TypeScript
npm run test # Run tests
cdk diff # Compare changes
cdk synth # Generate CloudFormation

API Endpoints
GET /scan - Returns log stream name
## Code review resolution

Security
IAM authentication enabled
Review feedback and implemented fixes are tracked in:

Environment variables for sensitive data
AWS managed encryption
- `docs/code-review-resolution.md`

## Platform progress

## Security & Monitoring
- API Gateway logs to CloudWatch
- Lambda execution tracing with X-Ray
- IAM roles with least privilege
- CORS configured for API endpoints
Track implementation maturity and next milestones in:

## Infrastructure as Code
- Defined using AWS CDK in TypeScript
- Automated deployment via CloudFormation
- Environment-specific tagging
- Environment: Development
- Project: DemoAPI
- `docs/platform-product-progress.md`

## Stack Outputs
- API Gateway URL
- DynamoDB table name
## Quick commands

## Scaling
- Lambda: Auto-scales based on demand
- DynamoDB: Pay-per-request auto-scaling
- API Gateway: Handles scaling automatically
```bash
make help
make platform-check
make platform-plan ENV=dev
make platform-apply ENV=dev
make app-bootstrap SERVICE=my-api
make app-deploy ENV=dev SERVICE=my-api TAG=v1.2.3
```

## Notes

- Existing CDK sample stack code is preserved for continuity and can be refactored incrementally into `platform/` and `applications/` domains.
- This repo now documents and scaffolds a platform operating model even where implementation modules are placeholders.
Empty file.
52 changes: 52 additions & 0 deletions applications/gitops/base/sample-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: v1
kind: Namespace
metadata:
name: sample-service
labels:
app.kubernetes.io/name: sample-service
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-service
namespace: sample-service
labels:
app.kubernetes.io/name: sample-service
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/name: sample-service
template:
metadata:
labels:
app.kubernetes.io/name: sample-service
spec:
containers:
- name: app
image: nginx:1.27
ports:
- containerPort: 80
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 250m
memory: 256Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
---
apiVersion: v1
kind: Service
metadata:
name: sample-service
namespace: sample-service
spec:
selector:
app.kubernetes.io/name: sample-service
ports:
- port: 80
targetPort: 80
type: ClusterIP
Empty file.
Empty file.
Empty file.
Empty file added applications/templates/.gitkeep
Empty file.
30 changes: 30 additions & 0 deletions docs/code-review-resolution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Code Review Resolution Log

This document captures how review feedback was applied during the Platform-as-a-Product transformation.

## Review items resolved

- [x] **GitOps validation must fail on invalid manifests**
- Removed failure suppression and ensured kubeconform exits non-zero on invalid resources.
- Implemented deterministic manifest discovery with `find` to avoid shell glob portability issues in GitHub Actions.

- [x] **Backstage template referenced missing repo structure path**
- Added `templates/service-catalog/structure/` with `catalog-info.yaml`, `README.md`, and `.gitignore`.
- Updated `fetch:template` path to `./structure` and made it executable.

- [x] **Hardcoded GitHub organization in Backstage template**
- Added required `organization` parameter.
- Updated `publish:github.repoUrl` to use `${{ parameters.organization }}`.

- [x] **Workflow-level permission hardening**
- Added explicit least-privilege workflow permissions (`contents: read`).

- [x] **Checkov findings from CDK stack resources**
- Added CMK encryption, Lambda DLQ, reserved concurrency, VPC placement, IAM auth defaults, and encrypted API access logs.
- Removed CDK-generated `CustomVpcRestrictDefaultSG` provider Lambda by setting `restrictDefaultSecurityGroup: false`, which eliminated residual Checkov findings tied to that generated function.

## Current status

- CI checks are green.
- Platform blueprint scaffolding is in place and runnable.
- Remaining work is implementation depth (EKS/Argo CD deployment, policy packs, and observability stack rollouts), tracked in `docs/platform-product-progress.md`.
Loading
Loading