Expert AWS cloud infrastructure design, deployment, and optimization for production-grade applications.
/plugin marketplace add DNYoussef/context-cascade/plugin install dnyoussef-context-cascade@DNYoussef/context-cascadeThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Expert AWS cloud infrastructure design, deployment, and optimization for production-grade applications.
Comprehensive AWS expertise across IaC (CloudFormation, CDK), serverless (Lambda), containers (ECS/Fargate), databases (RDS, DynamoDB), storage (S3), CDN (CloudFront), and DevOps automation. Ensures AWS architectures are secure, cost-effective, and scalable.
Required: AWS account, AWS CLI installed, basic understanding of cloud concepts
Agent Assignments: cicd-engineer, system-architect, security-manager, perf-analyzer
Step 1: Initialize CDK Project
mkdir my-infra && cd my-infra
npx cdk init app --language typescript
npm install @aws-cdk/aws-lambda @aws-cdk/aws-apigateway @aws-cdk/aws-dynamodb
Step 2: Define Lambda + API Gateway Stack
// lib/api-stack.ts
import * as cdk from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
export class ApiStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// DynamoDB table
const table = new dynamodb.Table(this, 'ItemsTable', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
removalPolicy: cdk.RemovalPolicy.DESTROY, // ONLY for dev
});
// Lambda function
const handler = new lambda.Function(this, 'ItemsHandler', {
runtime: lambda.Runtime.NODEJS_18_X,
code: lambda.Code.fromAsset('lambda'),
handler: 'index.handler',
environment: {
TABLE_NAME: table.tableName,
},
});
table.grantReadWriteData(handler);
// API Gateway
const api = new apigateway.RestApi(this, 'ItemsApi', {
restApiName: 'Items Service',
});
const items = api.root.addResource('items');
items.addMethod('GET', new apigateway.LambdaIntegration(handler));
items.addMethod('POST', new apigateway.LambdaIntegration(handler));
}
}
Step 3: Deploy Stack
# Bootstrap CDK (first time only)
cdk bootstrap
# Deploy
cdk deploy
Step 1: Create Fargate Service with CDK
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';
export class FargateStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, 'MyVpc', { maxAzs: 2 });
const cluster = new ecs.Cluster(this, 'MyCluster', { vpc });
const taskDefinition = new ecs.FargateTaskDefinition(this, 'TaskDef', {
memoryLimitMiB: 512,
cpu: 256,
});
taskDefinition.addContainer('web', {
image: ecs.ContainerImage.fromRegistry('nginx'),
portMappings: [{ containerPort: 80 }],
logging: ecs.LogDrivers.awsLogs({ streamPrefix: 'MyApp' }),
});
const service = new ecs.FargateService(this, 'Service', {
cluster,
taskDefinition,
desiredCount: 2,
});
const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', {
vpc,
internetFacing: true,
});
const listener = lb.addListener('Listener', { port: 80 });
listener.addTargets('ECS', {
port: 80,
targets: [service],
healthCheck: { path: '/' },
});
}
}
import * as rds from 'aws-cdk-lib/aws-rds';
import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
const dbSecret = new secretsmanager.Secret(this, 'DBSecret', {
generateSecretString: {
secretStringTemplate: JSON.stringify({ username: 'admin' }),
generateStringKey: 'password',
excludePunctuation: true,
},
});
const db = new rds.DatabaseInstance(this, 'MyDatabase', {
engine: rds.DatabaseInstanceEngine.postgres({
version: rds.PostgresEngineVersion.VER_15_3,
}),
instanceType: ec2.InstanceType.of(
ec2.InstanceClass.T3,
ec2.InstanceSize.MICRO
),
vpc,
credentials: rds.Credentials.fromSecret(dbSecret),
backupRetention: cdk.Duration.days(7),
deleteAutomatedBackups: false,
removalPolicy: cdk.RemovalPolicy.SNAPSHOT,
});
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
import * as origins from 'aws-cdk-lib/aws-cloudfront-origins';
const bucket = new s3.Bucket(this, 'WebsiteBucket', {
publicReadAccess: false,
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoDeleteObjects: true,
});
const distribution = new cloudfront.Distribution(this, 'Distribution', {
defaultBehavior: {
origin: new origins.S3Origin(bucket),
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
},
defaultRootObject: 'index.html',
});
1. Use IAM Least Privilege
// ✅ GOOD: Specific permissions
lambda.addToRolePolicy(new iam.PolicyStatement({
actions: ['dynamodb:GetItem', 'dynamodb:PutItem'],
resources: [table.tableArn],
}));
// ❌ BAD: Overly permissive
lambda.addToRolePolicy(new iam.PolicyStatement({
actions: ['*'],
resources: ['*'],
}));
2. Enable Encryption
const bucket = new s3.Bucket(this, 'Bucket', {
encryption: s3.BucketEncryption.S3_MANAGED, // or KMS
});
3. Use Secrets Manager for Credentials
// ✅ GOOD: Secrets Manager
const secret = secretsmanager.Secret.fromSecretNameV2(this, 'Secret', 'my-secret');
// ❌ BAD: Hardcoded in environment
environment: { API_KEY: 'hardcoded-key-123' }
4. Enable Auto-Scaling
const scaling = service.autoScaleTaskCount({ maxCapacity: 10 });
scaling.scaleOnCpuUtilization('CpuScaling', {
targetUtilizationPercent: 70,
});
5. Cost Optimization
Issue: CDK deployment fails with "not authorized"
Solution: Check AWS credentials (aws sts get-caller-identity), ensure IAM permissions
Issue: Lambda timeout errors Solution: Increase timeout (max 15 minutes), check VPC NAT gateway if Lambda in VPC
Issue: High RDS costs Solution: Use Aurora Serverless v2 for variable workloads, stop dev databases overnight
terraform-iac: Multi-cloud IaCdocker-containerization: Container best practiceskubernetes-specialist: K8s on EKSopentelemetry-observability: Distributed tracingmcp__flow-nexus__sandbox_execute for AWS CLI commandsmcp__memory-mcp__memory_store for AWS architecture patternsSkill Version: 1.0.0 Last Updated: 2025-11-02