@neyugn/agent-kits 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +514 -0
- package/README.vi.md +410 -0
- package/README.zh.md +410 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +422 -0
- package/kits/coder/ARCHITECTURE.md +289 -0
- package/kits/coder/agents/ai-engineer.md +344 -0
- package/kits/coder/agents/backend-specialist.md +270 -0
- package/kits/coder/agents/cloud-architect.md +363 -0
- package/kits/coder/agents/code-reviewer.md +284 -0
- package/kits/coder/agents/data-engineer.md +401 -0
- package/kits/coder/agents/database-specialist.md +251 -0
- package/kits/coder/agents/debugger.md +209 -0
- package/kits/coder/agents/devops-engineer.md +281 -0
- package/kits/coder/agents/documentation-writer.md +296 -0
- package/kits/coder/agents/frontend-specialist.md +298 -0
- package/kits/coder/agents/i18n-specialist.md +348 -0
- package/kits/coder/agents/integration-specialist.md +314 -0
- package/kits/coder/agents/mobile-developer.md +271 -0
- package/kits/coder/agents/multi-tenant-architect.md +281 -0
- package/kits/coder/agents/orchestrator.md +263 -0
- package/kits/coder/agents/performance-analyst.md +327 -0
- package/kits/coder/agents/project-planner.md +277 -0
- package/kits/coder/agents/queue-specialist.md +282 -0
- package/kits/coder/agents/realtime-specialist.md +267 -0
- package/kits/coder/agents/security-auditor.md +253 -0
- package/kits/coder/agents/test-engineer.md +315 -0
- package/kits/coder/agents/ux-researcher.md +388 -0
- package/kits/coder/rules/.cursorrules +287 -0
- package/kits/coder/rules/CLAUDE.md +287 -0
- package/kits/coder/rules/CODEX.md +287 -0
- package/kits/coder/rules/GEMINI.md +287 -0
- package/kits/coder/scripts/checklist.py +318 -0
- package/kits/coder/scripts/kit_status.py +292 -0
- package/kits/coder/scripts/skills_manager.py +243 -0
- package/kits/coder/scripts/verify_all.py +391 -0
- package/kits/coder/skills/accessibility-patterns/SKILL.md +372 -0
- package/kits/coder/skills/accessibility-patterns/scripts/a11y_checker.py +211 -0
- package/kits/coder/skills/ai-rag-patterns/SKILL.md +444 -0
- package/kits/coder/skills/api-patterns/SKILL.md +316 -0
- package/kits/coder/skills/api-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/api-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/api-patterns/scripts/api_validator.py +253 -0
- package/kits/coder/skills/api-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/auth-patterns/SKILL.md +267 -0
- package/kits/coder/skills/aws-patterns/SKILL.md +576 -0
- package/kits/coder/skills/brainstorming/SKILL.md +370 -0
- package/kits/coder/skills/brainstorming/assets/.gitkeep +1 -0
- package/kits/coder/skills/brainstorming/references/deep-dive.md +21 -0
- package/kits/coder/skills/brainstorming/scripts/validate.py +56 -0
- package/kits/coder/skills/clean-code/SKILL.md +240 -0
- package/kits/coder/skills/clean-code/assets/.gitkeep +1 -0
- package/kits/coder/skills/clean-code/references/deep-dive.md +21 -0
- package/kits/coder/skills/clean-code/scripts/lint_runner.py +186 -0
- package/kits/coder/skills/clean-code/scripts/validate.py +56 -0
- package/kits/coder/skills/database-design/SKILL.md +255 -0
- package/kits/coder/skills/database-design/assets/.gitkeep +1 -0
- package/kits/coder/skills/database-design/references/deep-dive.md +21 -0
- package/kits/coder/skills/database-design/scripts/schema_validator.py +272 -0
- package/kits/coder/skills/database-design/scripts/validate.py +56 -0
- package/kits/coder/skills/docker-patterns/SKILL.md +240 -0
- package/kits/coder/skills/documentation-templates/SKILL.md +441 -0
- package/kits/coder/skills/e2e-testing/SKILL.md +457 -0
- package/kits/coder/skills/flutter-patterns/SKILL.md +330 -0
- package/kits/coder/skills/frontend-design/SKILL.md +127 -0
- package/kits/coder/skills/github-actions/SKILL.md +349 -0
- package/kits/coder/skills/gitlab-ci-patterns/SKILL.md +466 -0
- package/kits/coder/skills/graphql-patterns/SKILL.md +558 -0
- package/kits/coder/skills/i18n-localization/SKILL.md +345 -0
- package/kits/coder/skills/i18n-localization/scripts/i18n_checker.py +267 -0
- package/kits/coder/skills/kubernetes-patterns/SKILL.md +357 -0
- package/kits/coder/skills/mermaid-diagrams/SKILL.md +351 -0
- package/kits/coder/skills/mobile-design/SKILL.md +305 -0
- package/kits/coder/skills/monitoring-observability/SKILL.md +458 -0
- package/kits/coder/skills/multi-tenancy/SKILL.md +317 -0
- package/kits/coder/skills/multi-tenancy/assets/.gitkeep +1 -0
- package/kits/coder/skills/multi-tenancy/references/deep-dive.md +21 -0
- package/kits/coder/skills/multi-tenancy/scripts/validate.py +56 -0
- package/kits/coder/skills/nodejs-best-practices/SKILL.md +220 -0
- package/kits/coder/skills/performance-profiling/SKILL.md +333 -0
- package/kits/coder/skills/performance-profiling/assets/.gitkeep +1 -0
- package/kits/coder/skills/performance-profiling/references/deep-dive.md +21 -0
- package/kits/coder/skills/performance-profiling/scripts/validate.py +56 -0
- package/kits/coder/skills/plan-writing/SKILL.md +360 -0
- package/kits/coder/skills/plan-writing/assets/.gitkeep +1 -0
- package/kits/coder/skills/plan-writing/references/deep-dive.md +21 -0
- package/kits/coder/skills/plan-writing/scripts/validate.py +56 -0
- package/kits/coder/skills/postgres-patterns/SKILL.md +361 -0
- package/kits/coder/skills/prompt-engineering/SKILL.md +277 -0
- package/kits/coder/skills/queue-patterns/SKILL.md +359 -0
- package/kits/coder/skills/queue-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/queue-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/queue-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/react-native-patterns/SKILL.md +393 -0
- package/kits/coder/skills/react-patterns/SKILL.md +319 -0
- package/kits/coder/skills/realtime-patterns/SKILL.md +506 -0
- package/kits/coder/skills/realtime-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/realtime-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/realtime-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/redis-patterns/SKILL.md +484 -0
- package/kits/coder/skills/security-fundamentals/SKILL.md +363 -0
- package/kits/coder/skills/security-fundamentals/assets/.gitkeep +1 -0
- package/kits/coder/skills/security-fundamentals/references/deep-dive.md +21 -0
- package/kits/coder/skills/security-fundamentals/scripts/security_scan.py +326 -0
- package/kits/coder/skills/security-fundamentals/scripts/validate.py +56 -0
- package/kits/coder/skills/seo-patterns/SKILL.md +262 -0
- package/kits/coder/skills/seo-patterns/scripts/seo_checker.py +211 -0
- package/kits/coder/skills/systematic-debugging/SKILL.md +478 -0
- package/kits/coder/skills/systematic-debugging/assets/.gitkeep +1 -0
- package/kits/coder/skills/systematic-debugging/references/deep-dive.md +21 -0
- package/kits/coder/skills/systematic-debugging/scripts/validate.py +56 -0
- package/kits/coder/skills/tailwind-patterns/SKILL.md +395 -0
- package/kits/coder/skills/terraform-patterns/SKILL.md +470 -0
- package/kits/coder/skills/testing-patterns/SKILL.md +285 -0
- package/kits/coder/skills/testing-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/testing-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/kits/coder/skills/testing-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/typescript-patterns/SKILL.md +417 -0
- package/kits/coder/skills/ui-ux-pro-max/SKILL.md +364 -0
- package/kits/coder/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/kits/coder/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/kits/coder/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/kits/coder/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/kits/coder/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/kits/coder/skills/ui-ux-pro-max/data/prompts.csv +24 -0
- package/kits/coder/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/kits/coder/skills/ui-ux-pro-max/data/styles.csv +59 -0
- package/kits/coder/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/kits/coder/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/kits/coder/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/kits/coder/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-314.pyc +0 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/core.py +257 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/design_system.py +488 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/search.py +76 -0
- package/kits/coder/workflows/.gitkeep +20 -0
- package/kits/coder/workflows/create.md +152 -0
- package/kits/coder/workflows/debug.md +223 -0
- package/kits/coder/workflows/deploy.md +283 -0
- package/kits/coder/workflows/orchestrate.md +243 -0
- package/kits/coder/workflows/plan.md +134 -0
- package/kits/coder/workflows/test.md +237 -0
- package/kits/coder/workflows/ui-ux-pro-max.md +109 -0
- package/package.json +49 -0
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: aws-patterns
|
|
3
|
+
description: AWS CLI and Console patterns for cloud infrastructure management. Use when configuring AWS services, writing CLI scripts, managing IAM, S3, EC2, Lambda, or CloudFormation. Covers security best practices, automation, and service-specific patterns.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# AWS Patterns - Cloud Infrastructure Management
|
|
8
|
+
|
|
9
|
+
> **Philosophy:** Security-first, automation-ready, and production-proven patterns for AWS services.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📑 Content Map
|
|
14
|
+
|
|
15
|
+
| Section | When to Read |
|
|
16
|
+
| ----------------------- | --------------------------------------- |
|
|
17
|
+
| AWS CLI Basics | Setting up CLI, configuration, profiles |
|
|
18
|
+
| IAM Security Patterns | Users, roles, policies, access control |
|
|
19
|
+
| S3 Patterns | Bucket management, object storage, sync |
|
|
20
|
+
| EC2 Patterns | Instance management, security groups |
|
|
21
|
+
| Lambda Patterns | Serverless functions, deployment |
|
|
22
|
+
| CloudFormation Patterns | Infrastructure as Code |
|
|
23
|
+
| Security Checklist | Pre-deployment security validation |
|
|
24
|
+
| Troubleshooting | Common issues and solutions |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🔧 AWS CLI Basics
|
|
29
|
+
|
|
30
|
+
### Installation & Configuration
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Install AWS CLI v2 (macOS)
|
|
34
|
+
brew install awscli
|
|
35
|
+
|
|
36
|
+
# Configure default profile
|
|
37
|
+
aws configure
|
|
38
|
+
# → AWS Access Key ID
|
|
39
|
+
# → AWS Secret Access Key
|
|
40
|
+
# → Default region (e.g., ap-southeast-1)
|
|
41
|
+
# → Default output format (json)
|
|
42
|
+
|
|
43
|
+
# Configure named profile
|
|
44
|
+
aws configure --profile production
|
|
45
|
+
|
|
46
|
+
# List configurations
|
|
47
|
+
aws configure list
|
|
48
|
+
aws configure list-profiles
|
|
49
|
+
|
|
50
|
+
# Get current identity
|
|
51
|
+
aws sts get-caller-identity
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Profile Management
|
|
55
|
+
|
|
56
|
+
| Pattern | Command |
|
|
57
|
+
| --------------- | -------------------------------------------------------------------------------------------------- |
|
|
58
|
+
| Use profile | `aws s3 ls --profile production` |
|
|
59
|
+
| Export profile | `export AWS_PROFILE=production` |
|
|
60
|
+
| Override region | `aws ec2 describe-instances --region us-west-2` |
|
|
61
|
+
| MFA session | `aws sts get-session-token --serial-number arn:aws:iam::123456789012:mfa/user --token-code 123456` |
|
|
62
|
+
|
|
63
|
+
### Output Formats
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# JSON (default, best for scripts)
|
|
67
|
+
aws ec2 describe-instances --output json
|
|
68
|
+
|
|
69
|
+
# Table (human-readable)
|
|
70
|
+
aws ec2 describe-instances --output table
|
|
71
|
+
|
|
72
|
+
# Text (simple, tab-separated)
|
|
73
|
+
aws ec2 describe-instances --output text
|
|
74
|
+
|
|
75
|
+
# Use jq for JSON parsing
|
|
76
|
+
aws ec2 describe-instances | jq '.Reservations[].Instances[].InstanceId'
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 🔐 IAM Security Patterns
|
|
82
|
+
|
|
83
|
+
### Core Principles (2024-2025)
|
|
84
|
+
|
|
85
|
+
| Principle | Implementation |
|
|
86
|
+
| ------------------------- | ------------------------------------------ |
|
|
87
|
+
| **Least Privilege** | Grant only minimum required permissions |
|
|
88
|
+
| **Temporary Credentials** | Use IAM roles, avoid long-term access keys |
|
|
89
|
+
| **MFA Everywhere** | Require MFA for console access + API calls |
|
|
90
|
+
| **No Root User** | Never use root for daily tasks |
|
|
91
|
+
| **Regular Audits** | Review unused roles/users every 90 days |
|
|
92
|
+
|
|
93
|
+
### IAM User Management
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# List all users
|
|
97
|
+
aws iam list-users
|
|
98
|
+
|
|
99
|
+
# Create user
|
|
100
|
+
aws iam create-user --user-name developer-john
|
|
101
|
+
|
|
102
|
+
# Create access key (use sparingly!)
|
|
103
|
+
aws iam create-access-key --user-name developer-john
|
|
104
|
+
|
|
105
|
+
# List access keys
|
|
106
|
+
aws iam list-access-keys --user-name developer-john
|
|
107
|
+
|
|
108
|
+
# Delete access key (rotate regularly)
|
|
109
|
+
aws iam delete-access-key \
|
|
110
|
+
--user-name developer-john \
|
|
111
|
+
--access-key-id AKIAIOSFODNN7EXAMPLE
|
|
112
|
+
|
|
113
|
+
# Delete user
|
|
114
|
+
aws iam delete-user --user-name developer-john
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### IAM Role Patterns
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Create role with trust policy
|
|
121
|
+
aws iam create-role \
|
|
122
|
+
--role-name LambdaExecutionRole \
|
|
123
|
+
--assume-role-policy-document file://trust-policy.json
|
|
124
|
+
|
|
125
|
+
# Attach managed policy
|
|
126
|
+
aws iam attach-role-policy \
|
|
127
|
+
--role-name LambdaExecutionRole \
|
|
128
|
+
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
|
129
|
+
|
|
130
|
+
# List role policies
|
|
131
|
+
aws iam list-attached-role-policies --role-name LambdaExecutionRole
|
|
132
|
+
|
|
133
|
+
# Assume role (get temp credentials)
|
|
134
|
+
aws sts assume-role \
|
|
135
|
+
--role-arn arn:aws:iam::123456789012:role/MyRole \
|
|
136
|
+
--role-session-name MySession
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Trust Policy Template
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"Version": "2012-10-17",
|
|
144
|
+
"Statement": [
|
|
145
|
+
{
|
|
146
|
+
"Effect": "Allow",
|
|
147
|
+
"Principal": {
|
|
148
|
+
"Service": "lambda.amazonaws.com"
|
|
149
|
+
},
|
|
150
|
+
"Action": "sts:AssumeRole"
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Policy Best Practices
|
|
157
|
+
|
|
158
|
+
| ❌ Don't | ✅ Do |
|
|
159
|
+
| -------------------- | ---------------------- |
|
|
160
|
+
| `"Resource": "*"` | Specify exact ARNs |
|
|
161
|
+
| `"Action": "*"` | List specific actions |
|
|
162
|
+
| Attach to users | Attach to groups/roles |
|
|
163
|
+
| Hardcode credentials | Use IAM roles + STS |
|
|
164
|
+
| Skip MFA for admins | Require MFA always |
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 📦 S3 Patterns
|
|
169
|
+
|
|
170
|
+
### Bucket Operations
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# List all buckets
|
|
174
|
+
aws s3 ls
|
|
175
|
+
|
|
176
|
+
# Create bucket
|
|
177
|
+
aws s3 mb s3://my-unique-bucket-name --region ap-southeast-1
|
|
178
|
+
|
|
179
|
+
# List bucket contents
|
|
180
|
+
aws s3 ls s3://my-bucket/
|
|
181
|
+
aws s3 ls s3://my-bucket/ --recursive
|
|
182
|
+
|
|
183
|
+
# Remove empty bucket
|
|
184
|
+
aws s3 rb s3://my-bucket
|
|
185
|
+
|
|
186
|
+
# Force remove bucket with contents
|
|
187
|
+
aws s3 rb s3://my-bucket --force
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Object Operations
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Upload file
|
|
194
|
+
aws s3 cp ./local-file.txt s3://my-bucket/
|
|
195
|
+
|
|
196
|
+
# Upload folder
|
|
197
|
+
aws s3 cp ./folder s3://my-bucket/folder --recursive
|
|
198
|
+
|
|
199
|
+
# Download file
|
|
200
|
+
aws s3 cp s3://my-bucket/file.txt ./local-file.txt
|
|
201
|
+
|
|
202
|
+
# Download folder
|
|
203
|
+
aws s3 cp s3://my-bucket/folder ./local-folder --recursive
|
|
204
|
+
|
|
205
|
+
# Sync (bidirectional)
|
|
206
|
+
aws s3 sync ./local-folder s3://my-bucket/folder
|
|
207
|
+
aws s3 sync s3://my-bucket/folder ./local-folder
|
|
208
|
+
|
|
209
|
+
# Sync with delete (dangerous!)
|
|
210
|
+
aws s3 sync ./local-folder s3://my-bucket/folder --delete
|
|
211
|
+
|
|
212
|
+
# Remove file
|
|
213
|
+
aws s3 rm s3://my-bucket/file.txt
|
|
214
|
+
|
|
215
|
+
# Remove folder
|
|
216
|
+
aws s3 rm s3://my-bucket/folder --recursive
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### S3 Security
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Block public access (ALWAYS)
|
|
223
|
+
aws s3api put-public-access-block \
|
|
224
|
+
--bucket my-bucket \
|
|
225
|
+
--public-access-block-configuration \
|
|
226
|
+
"BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true"
|
|
227
|
+
|
|
228
|
+
# Enable versioning
|
|
229
|
+
aws s3api put-bucket-versioning \
|
|
230
|
+
--bucket my-bucket \
|
|
231
|
+
--versioning-configuration Status=Enabled
|
|
232
|
+
|
|
233
|
+
# Enable encryption
|
|
234
|
+
aws s3api put-bucket-encryption \
|
|
235
|
+
--bucket my-bucket \
|
|
236
|
+
--server-side-encryption-configuration \
|
|
237
|
+
'{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"AES256"}}]}'
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 🖥️ EC2 Patterns
|
|
243
|
+
|
|
244
|
+
### Instance Management
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# List instances
|
|
248
|
+
aws ec2 describe-instances
|
|
249
|
+
|
|
250
|
+
# Filter running instances
|
|
251
|
+
aws ec2 describe-instances \
|
|
252
|
+
--filters "Name=instance-state-name,Values=running" \
|
|
253
|
+
--query 'Reservations[].Instances[].[InstanceId,InstanceType,PublicIpAddress]' \
|
|
254
|
+
--output table
|
|
255
|
+
|
|
256
|
+
# Launch instance
|
|
257
|
+
aws ec2 run-instances \
|
|
258
|
+
--image-id ami-0abcdef1234567890 \
|
|
259
|
+
--instance-type t3.micro \
|
|
260
|
+
--key-name MyKeyPair \
|
|
261
|
+
--security-group-ids sg-0123456789abcdef0 \
|
|
262
|
+
--subnet-id subnet-0123456789abcdef0 \
|
|
263
|
+
--count 1
|
|
264
|
+
|
|
265
|
+
# Start/Stop/Terminate
|
|
266
|
+
aws ec2 start-instances --instance-ids i-1234567890abcdef0
|
|
267
|
+
aws ec2 stop-instances --instance-ids i-1234567890abcdef0
|
|
268
|
+
aws ec2 terminate-instances --instance-ids i-1234567890abcdef0
|
|
269
|
+
|
|
270
|
+
# Get instance status
|
|
271
|
+
aws ec2 describe-instance-status --instance-ids i-1234567890abcdef0
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Security Groups
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Create security group
|
|
278
|
+
aws ec2 create-security-group \
|
|
279
|
+
--group-name web-access \
|
|
280
|
+
--description "Allow web traffic" \
|
|
281
|
+
--vpc-id vpc-0123456789abcdef0
|
|
282
|
+
|
|
283
|
+
# Add inbound rule (SSH)
|
|
284
|
+
aws ec2 authorize-security-group-ingress \
|
|
285
|
+
--group-id sg-0123456789abcdef0 \
|
|
286
|
+
--protocol tcp \
|
|
287
|
+
--port 22 \
|
|
288
|
+
--cidr 203.0.113.0/24 # Specific IP range, NOT 0.0.0.0/0!
|
|
289
|
+
|
|
290
|
+
# Add inbound rule (HTTPS)
|
|
291
|
+
aws ec2 authorize-security-group-ingress \
|
|
292
|
+
--group-id sg-0123456789abcdef0 \
|
|
293
|
+
--protocol tcp \
|
|
294
|
+
--port 443 \
|
|
295
|
+
--cidr 0.0.0.0/0
|
|
296
|
+
|
|
297
|
+
# List security groups
|
|
298
|
+
aws ec2 describe-security-groups --group-ids sg-0123456789abcdef0
|
|
299
|
+
|
|
300
|
+
# Revoke rule
|
|
301
|
+
aws ec2 revoke-security-group-ingress \
|
|
302
|
+
--group-id sg-0123456789abcdef0 \
|
|
303
|
+
--protocol tcp \
|
|
304
|
+
--port 22 \
|
|
305
|
+
--cidr 0.0.0.0/0
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## ⚡ Lambda Patterns
|
|
311
|
+
|
|
312
|
+
### Function Management
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
# List functions
|
|
316
|
+
aws lambda list-functions --region ap-southeast-1
|
|
317
|
+
|
|
318
|
+
# Create function
|
|
319
|
+
aws lambda create-function \
|
|
320
|
+
--function-name my-function \
|
|
321
|
+
--runtime nodejs20.x \
|
|
322
|
+
--role arn:aws:iam::123456789012:role/LambdaExecutionRole \
|
|
323
|
+
--handler index.handler \
|
|
324
|
+
--zip-file fileb://function.zip
|
|
325
|
+
|
|
326
|
+
# Update function code
|
|
327
|
+
aws lambda update-function-code \
|
|
328
|
+
--function-name my-function \
|
|
329
|
+
--zip-file fileb://function.zip
|
|
330
|
+
|
|
331
|
+
# Update configuration
|
|
332
|
+
aws lambda update-function-configuration \
|
|
333
|
+
--function-name my-function \
|
|
334
|
+
--timeout 30 \
|
|
335
|
+
--memory-size 256 \
|
|
336
|
+
--environment "Variables={ENV=production,DEBUG=false}"
|
|
337
|
+
|
|
338
|
+
# Invoke function
|
|
339
|
+
aws lambda invoke \
|
|
340
|
+
--function-name my-function \
|
|
341
|
+
--payload '{"key": "value"}' \
|
|
342
|
+
--cli-binary-format raw-in-base64-out \
|
|
343
|
+
response.json
|
|
344
|
+
|
|
345
|
+
# View logs
|
|
346
|
+
aws logs tail /aws/lambda/my-function --follow
|
|
347
|
+
|
|
348
|
+
# Delete function
|
|
349
|
+
aws lambda delete-function --function-name my-function
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Lambda Permissions
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
# Add API Gateway trigger
|
|
356
|
+
aws lambda add-permission \
|
|
357
|
+
--function-name my-function \
|
|
358
|
+
--statement-id apigateway-access \
|
|
359
|
+
--action lambda:InvokeFunction \
|
|
360
|
+
--principal apigateway.amazonaws.com \
|
|
361
|
+
--source-arn "arn:aws:execute-api:region:account-id:api-id/*"
|
|
362
|
+
|
|
363
|
+
# Add S3 trigger
|
|
364
|
+
aws lambda add-permission \
|
|
365
|
+
--function-name my-function \
|
|
366
|
+
--statement-id s3-trigger \
|
|
367
|
+
--action lambda:InvokeFunction \
|
|
368
|
+
--principal s3.amazonaws.com \
|
|
369
|
+
--source-arn arn:aws:s3:::my-bucket
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## 🏗️ CloudFormation Patterns
|
|
375
|
+
|
|
376
|
+
### Stack Operations
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
# Validate template
|
|
380
|
+
aws cloudformation validate-template \
|
|
381
|
+
--template-body file://template.yaml
|
|
382
|
+
|
|
383
|
+
# Create stack
|
|
384
|
+
aws cloudformation create-stack \
|
|
385
|
+
--stack-name my-stack \
|
|
386
|
+
--template-body file://template.yaml \
|
|
387
|
+
--parameters ParameterKey=Environment,ParameterValue=production \
|
|
388
|
+
--capabilities CAPABILITY_IAM
|
|
389
|
+
|
|
390
|
+
# Update stack
|
|
391
|
+
aws cloudformation update-stack \
|
|
392
|
+
--stack-name my-stack \
|
|
393
|
+
--template-body file://template.yaml \
|
|
394
|
+
--parameters ParameterKey=Environment,ParameterValue=staging
|
|
395
|
+
|
|
396
|
+
# Describe stack
|
|
397
|
+
aws cloudformation describe-stacks --stack-name my-stack
|
|
398
|
+
|
|
399
|
+
# List stack resources
|
|
400
|
+
aws cloudformation list-stack-resources --stack-name my-stack
|
|
401
|
+
|
|
402
|
+
# Get stack events
|
|
403
|
+
aws cloudformation describe-stack-events --stack-name my-stack
|
|
404
|
+
|
|
405
|
+
# Delete stack
|
|
406
|
+
aws cloudformation delete-stack --stack-name my-stack
|
|
407
|
+
|
|
408
|
+
# Wait for completion
|
|
409
|
+
aws cloudformation wait stack-create-complete --stack-name my-stack
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### CloudFormation Template Example
|
|
413
|
+
|
|
414
|
+
```yaml
|
|
415
|
+
AWSTemplateFormatVersion: "2010-09-09"
|
|
416
|
+
Description: Simple Lambda + API Gateway
|
|
417
|
+
|
|
418
|
+
Parameters:
|
|
419
|
+
Environment:
|
|
420
|
+
Type: String
|
|
421
|
+
AllowedValues: [development, staging, production]
|
|
422
|
+
Default: development
|
|
423
|
+
|
|
424
|
+
Resources:
|
|
425
|
+
LambdaFunction:
|
|
426
|
+
Type: AWS::Lambda::Function
|
|
427
|
+
Properties:
|
|
428
|
+
FunctionName: !Sub "${Environment}-my-function"
|
|
429
|
+
Runtime: nodejs20.x
|
|
430
|
+
Handler: index.handler
|
|
431
|
+
Code:
|
|
432
|
+
ZipFile: |
|
|
433
|
+
exports.handler = async (event) => {
|
|
434
|
+
return { statusCode: 200, body: 'Hello!' };
|
|
435
|
+
};
|
|
436
|
+
Role: !GetAtt LambdaRole.Arn
|
|
437
|
+
|
|
438
|
+
LambdaRole:
|
|
439
|
+
Type: AWS::IAM::Role
|
|
440
|
+
Properties:
|
|
441
|
+
AssumeRolePolicyDocument:
|
|
442
|
+
Version: "2012-10-17"
|
|
443
|
+
Statement:
|
|
444
|
+
- Effect: Allow
|
|
445
|
+
Principal:
|
|
446
|
+
Service: lambda.amazonaws.com
|
|
447
|
+
Action: sts:AssumeRole
|
|
448
|
+
ManagedPolicyArns:
|
|
449
|
+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
|
450
|
+
|
|
451
|
+
Outputs:
|
|
452
|
+
FunctionArn:
|
|
453
|
+
Value: !GetAtt LambdaFunction.Arn
|
|
454
|
+
Export:
|
|
455
|
+
Name: !Sub "${Environment}-function-arn"
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## 🛡️ Security Checklist
|
|
461
|
+
|
|
462
|
+
### Pre-Deployment Audit
|
|
463
|
+
|
|
464
|
+
```markdown
|
|
465
|
+
## AWS Security Checklist
|
|
466
|
+
|
|
467
|
+
### IAM
|
|
468
|
+
|
|
469
|
+
- [ ] No root user access keys exist
|
|
470
|
+
- [ ] MFA enabled for all console users
|
|
471
|
+
- [ ] Access keys rotated within 90 days
|
|
472
|
+
- [ ] Unused users/roles removed
|
|
473
|
+
- [ ] No wildcard (\*) permissions in policies
|
|
474
|
+
|
|
475
|
+
### S3
|
|
476
|
+
|
|
477
|
+
- [ ] Public access blocked on all buckets
|
|
478
|
+
- [ ] Encryption enabled (SSE-S3 or SSE-KMS)
|
|
479
|
+
- [ ] Versioning enabled for critical buckets
|
|
480
|
+
- [ ] Bucket policies reviewed
|
|
481
|
+
|
|
482
|
+
### EC2
|
|
483
|
+
|
|
484
|
+
- [ ] Security groups have no 0.0.0.0/0 for SSH (port 22)
|
|
485
|
+
- [ ] Security groups have no 0.0.0.0/0 for RDP (port 3389)
|
|
486
|
+
- [ ] IMDSv2 required (no v1)
|
|
487
|
+
- [ ] EBS volumes encrypted
|
|
488
|
+
|
|
489
|
+
### Lambda
|
|
490
|
+
|
|
491
|
+
- [ ] Functions use least privilege roles
|
|
492
|
+
- [ ] Environment variables encrypted with KMS
|
|
493
|
+
- [ ] VPC configuration if accessing internal resources
|
|
494
|
+
|
|
495
|
+
### CloudFormation
|
|
496
|
+
|
|
497
|
+
- [ ] Templates stored in version control
|
|
498
|
+
- [ ] Secrets not hardcoded (use SSM/Secrets Manager)
|
|
499
|
+
- [ ] Stack policies for critical resources
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
### Monitoring & Logging
|
|
503
|
+
|
|
504
|
+
```bash
|
|
505
|
+
# Enable CloudTrail (MANDATORY)
|
|
506
|
+
aws cloudtrail create-trail \
|
|
507
|
+
--name my-trail \
|
|
508
|
+
--s3-bucket-name my-cloudtrail-bucket \
|
|
509
|
+
--is-multi-region-trail
|
|
510
|
+
|
|
511
|
+
# Start logging
|
|
512
|
+
aws cloudtrail start-logging --name my-trail
|
|
513
|
+
|
|
514
|
+
# Enable CloudWatch Log Group for Lambda
|
|
515
|
+
aws logs create-log-group --log-group-name /aws/lambda/my-function
|
|
516
|
+
|
|
517
|
+
# Set retention
|
|
518
|
+
aws logs put-retention-policy \
|
|
519
|
+
--log-group-name /aws/lambda/my-function \
|
|
520
|
+
--retention-in-days 30
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
---
|
|
524
|
+
|
|
525
|
+
## 🔧 Troubleshooting
|
|
526
|
+
|
|
527
|
+
| Issue | Solution |
|
|
528
|
+
| ------------------------------ | --------------------------------------------------------------- |
|
|
529
|
+
| `Unable to locate credentials` | Run `aws configure` or check `~/.aws/credentials` |
|
|
530
|
+
| `Access Denied` | Check IAM policy, verify resource ARN, check STS assume-role |
|
|
531
|
+
| `Region not specified` | Add `--region` flag or set `AWS_DEFAULT_REGION` |
|
|
532
|
+
| `Invalid JSON` | Use `--cli-binary-format raw-in-base64-out` for Lambda payloads |
|
|
533
|
+
| `ExpiredToken` | Get new STS session token if using MFA/assumed role |
|
|
534
|
+
| `NoSuchBucket` | Check bucket name and region, S3 is globally unique |
|
|
535
|
+
|
|
536
|
+
### Debug Mode
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
# Enable debug output
|
|
540
|
+
aws s3 ls --debug
|
|
541
|
+
|
|
542
|
+
# Check API calls
|
|
543
|
+
aws s3 ls --debug 2>&1 | grep "Making request"
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
## Anti-Patterns
|
|
549
|
+
|
|
550
|
+
| ❌ Don't | ✅ Do |
|
|
551
|
+
| ---------------------------- | ---------------------------------------------- |
|
|
552
|
+
| Hardcode access keys in code | Use IAM roles for EC2/Lambda |
|
|
553
|
+
| Use `0.0.0.0/0` for SSH | Restrict to specific IP ranges |
|
|
554
|
+
| Create access keys for root | Never use root, use IAM users |
|
|
555
|
+
| Skip MFA for admin accounts | Require MFA for all privileged access |
|
|
556
|
+
| Use long-term credentials | Prefer STS temporary credentials |
|
|
557
|
+
| Store secrets in env vars | Use AWS Secrets Manager or SSM Parameter Store |
|
|
558
|
+
| Manual deployments | Use CloudFormation/Terraform/CDK |
|
|
559
|
+
| Single region deployment | Multi-region for DR-critical apps |
|
|
560
|
+
|
|
561
|
+
---
|
|
562
|
+
|
|
563
|
+
## Related Skills
|
|
564
|
+
|
|
565
|
+
| Need | Skill |
|
|
566
|
+
| ---------------------- | -------------------------- |
|
|
567
|
+
| Infrastructure as Code | `terraform-patterns` |
|
|
568
|
+
| Kubernetes on AWS | `kubernetes-patterns` |
|
|
569
|
+
| Docker/ECS | `docker-patterns` |
|
|
570
|
+
| CI/CD with AWS | `github-actions` |
|
|
571
|
+
| Security hardening | `security-fundamentals` |
|
|
572
|
+
| Monitoring | `monitoring-observability` |
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
> **Remember:** Security is not optional. Every AWS resource should be deployed with encryption, least privilege, and audit logging enabled.
|