
CI/CD pipeline fundamentals
Core concept: pipelines orchestrate the flow from source through build, test, artifact storage, and deployment. Recognize the AWS-native orchestration and how pieces integrate.- AWS CodePipeline is the orchestration service. Typical flow: source (e.g., CodeCommit) → CodeBuild (build/test) → artifact storage (S3/ECR/CodeArtifact) → CodeDeploy (or other deployment actions).
- Artifacts from CodeBuild can be stored in S3 for static outputs, in ECR for container images, or in CodeArtifact for packages. Pipelines can operate across single-account or multi-account topologies — understand cross-account IAM roles, trust policies, and how AWS Organizations affect CI/CD design.
- Webhooks, service roles, and scoped permissions (least privilege) are essential to a secure, reliable pipeline.

CodeBuild and buildspec
CodeBuild executes the build and test commands you specify in abuildspec.yml. The buildspec lays out named phases and artifacts that control the build lifecycle.
- Named phases:
install,pre_build,build,post_build. - Artifacts: specify what to upload to S3 (or other configured sinks).
- Additional concerns: caching for speed, test reports integration, and secure secrets/parameter access.
buildspec.yml to illustrate typical sections:
- Never store database credentials or long-lived secrets directly in plaintext environment variables. Inject secrets at build time using secure stores (see Secrets Management below) and grant minimal IAM permissions to the CodeBuild service role.
Prefer AWS Secrets Manager when you require automatic secret rotation and native integrations. Use Systems Manager Parameter Store (standard tier) for lower-cost, non-rotating configuration values; use the advanced tier only when you need its features.

Secrets management: Secrets Manager vs Parameter Store
Choose the right secret store based on rotation needs, integration, and cost.- AWS Secrets Manager: automatic rotation, native integrations (e.g., RDS), secure storage for credentials and API keys; comes with additional cost.
- AWS Systems Manager Parameter Store: standard tier is free with limits, advanced tier charges apply; does not provide automatic rotation out of the box (you can implement custom rotation workflows).

Automated testing in pipelines
Place tests in the pipeline according to speed and scope. Ensure build steps return correct exit codes so pipeline stages fail or pass deterministically. Table: Test levels, cadence, where to place
Configure test runners and scripts so they propagate proper exit codes and provide helpful test reports.

Artifact management
Map artifact types to appropriate AWS services and design retention/versioning strategies.
You can host custom repositories if organizational policy requires it. Consider lifecycle policies and immutability/version schemes to make rollbacks predictable.

Deployment strategies
Understand trade-offs between speed, risk, and rollback simplicity.
Select strategies that support monitoring and automated rollbacks. Use ALB/traffic shifting or service mesh routing to control traffic during deployments.

CodeDeploy and compute targets
CodeDeploy adapts behavior per compute target — know the options and where lifecycle hooks fit.- EC2 / On-premises: supports in-place (mutable) updates and batched deployments. Use
appspec.ymlto define lifecycle hooks that run on instance-level events. - ECS: supports blue/green and traffic shifting via ALB and new task sets (immutable deployments). Use task definitions and CodeDeploy integration for controlled cutovers.
- EKS: typically use Kubernetes-native deployments or tools such as Argo Rollouts / Istio for progressive delivery — CodeDeploy integration is not the primary Kubernetes pattern.
- Lambda: uses versions and aliases; supports linear/canary traffic shifting and pre/post-traffic hooks.

Blue/green and traffic shifting
Blue/green creates a parallel (green) environment while the old (blue) remains live. Traffic shifting approaches:- All-at-once: single cutover — fast but riskier.
- Canary: route a small percentage first, verify, then increase.
- Linear: increment traffic by fixed steps over time.

Immutable vs mutable deployments
- Immutable: replace instances/tasks with new versions. Advantages: no drift, predictable rollbacks, easier testing of images (golden AMIs, container images). Preferred for cloud-native/containerized workloads.
- Mutable (in-place): patch or update running instances. Advantages: sometimes faster for tiny fixes, but increases risk of drift and inconsistent state.
Troubleshooting deployment failures
When a pipeline or deployment fails, follow a focused troubleshooting sequence:- Permissions and roles: verify service roles, cross-account role trusts, bucket policies, and repository permissions.
- Logs and diagnostics: examine CloudWatch logs (CodeBuild logs, CodeDeploy agent logs, Lambda logs) and pipeline execution history for detailed error messages.
- Networking and health checks: check load balancer health checks and target group configurations — misconfigured health checks are a common cause of rollbacks.

Exam focus and common scenarios
Prepare to reason about:- CodePipeline stage roles, parallel/sequential actions, and webhook triggers.
- CodeBuild lifecycle,
buildspec.ymlstructure, caching, and artifact upload behaviors. - CodeDeploy deployment types across EC2, ECS/EKS, and Lambda; know when to use ALB-based traffic shifting.
- Artifact storage options: S3, ECR, CodeArtifact; retention and versioning strategies.
- Multi-account CI/CD topologies: cross-account roles, AWS Organizations, and secure artifact sharing.
- Secrets and keys: use IAM roles, KMS, Secrets Manager or Parameter Store appropriately.
- Immutable infrastructure patterns (golden AMIs, image pipelines) and zero-downtime release design.

Key takeaways
- Automation is the core — automate build, test, artifact storage, and deployment consistently.
- Consistency reduces risk — prefer immutable infrastructure and golden-image patterns to limit drift.
- Safety and security — use IAM roles and KMS for encryption, and inject secrets via Secrets Manager or Parameter Store. Design for testability and zero-downtime rollouts; plan for multi-account CI/CD when needed.

- AWS CodePipeline docs: https://docs.aws.amazon.com/codepipeline/
- AWS CodeBuild docs: https://docs.aws.amazon.com/codebuild/
- AWS CodeDeploy docs: https://docs.aws.amazon.com/codedeploy/
- AWS Secrets Manager: https://docs.aws.amazon.com/secretsmanager/
- AWS Systems Manager Parameter Store: https://docs.aws.amazon.com/systems-manager/parameter-store/
- Kubernetes concepts (for EKS patterns): https://kubernetes.io/docs/concepts/