AWS Fundamentals for PHP Developers
debt(d5/e6/b8/t5)
Closest to 'specialist tool catches' (d5), trufflehog catches hardcoded access keys and terraform/semgrep can flag public S3 buckets or missing IAM roles, but architectural mistakes like ephemeral storage usage are typically only caught at incident time.
Closest to 'cross-cutting refactor' (e6), swapping EC2 instance storage for S3 or access keys for IAM roles requires touching deployment config, app file-handling code, and infrastructure-as-code — spans multiple components but stops short of full architectural rewrite.
Closest to 'gravitational pull' (b8), AWS service choices (EC2 vs ECS, RDS engine, IAM model) shape every deployment, scaling, and security decision in the codebase across web and CLI contexts; migrating off is near-rewrite territory.
Closest to 'documented gotcha' (t5), the misconception that AWS is enterprise-only plus the surprises around ephemeral EC2 storage and 1-day default RDS backup retention are well-known traps most devs hit once and learn.
Also Known As
TL;DR
Explanation
Key AWS services for PHP: EC2 (virtual servers for PHP-FPM), Elastic Beanstalk / App Runner (PaaS for PHP), RDS (managed MySQL/PostgreSQL), S3 (file storage), SQS (job queues), ElastiCache (Redis/Memcached), CloudFront (CDN), Lambda + Bref (serverless PHP), IAM (identity — who can do what), Route 53 (DNS), ACM (free TLS certificates), Secrets Manager (credentials). The AWS Free Tier covers most of these for experimentation. The PHP AWS SDK (aws/aws-sdk-php) provides type-safe access to all services.
Diagram
flowchart TD
subgraph Compute
EC2[EC2 - Virtual servers]
LAMBDA[Lambda - Functions]
ECS[ECS - Containers]
end
subgraph Storage
S3[S3 - Object storage<br/>files uploads assets]
RDS[RDS - Managed DB<br/>MySQL PostgreSQL]
ELASTICACHE[ElastiCache<br/>Redis Memcached]
end
subgraph Networking
VPC[VPC - Private network]
CF[CloudFront - CDN]
ALB[ALB - Load balancer]
end
subgraph Messaging
SQS[SQS - Job queue]
SNS[SNS - Notifications]
end
ALB --> EC2 & ECS
EC2 & ECS --> RDS & ELASTICACHE & S3 & SQS
style ALB fill:#d29922,color:#fff
style RDS fill:#6e40c9,color:#fff
style S3 fill:#238636,color:#fff
Common Misconception
Why It Matters
Common Mistakes
- Running PHP on EC2 without Auto Scaling — no ability to handle traffic spikes.
- Storing files on EC2 instance storage — lost when the instance is replaced; use S3.
- Using access keys instead of IAM roles for EC2 — roles rotate automatically; hardcoded keys are a security risk.
- Not enabling RDS automated backups — default retention is 1 day; configure 7-35 days.
Code Examples
// Hardcoded AWS credentials — never do this:
$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'eu-west-1',
'credentials' => [
'key' => 'AKIAIOSFODNN7EXAMPLE', // In source code!
'secret' => 'wJalrXUtnFEMI/K7MDENG', // Committed to git!
],
]);
// IAM role on EC2 — credentials auto-rotated, never in code:
$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'eu-west-1',
// No credentials key — SDK picks up IAM role from instance metadata
]);
// Or environment variables injected at runtime:
$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => getenv('AWS_REGION'),
'credentials' => Aws\Credentials\CredentialProvider::env(),
]);