CI/CD concepts on AWS: stages, artefacts, environments and where each tool fits
Learn the vocabulary and the shape of a delivery pipeline (build once, promote the same artefact, gate each stage), map every stage to GitHub Actions or the AWS developer tools, and choose between them with a decision rule you can defend to an architecture board.
Assumes: .NET 10 LTS · GitHub Actions · AWS CodePipeline V2 · AWS CodeBuild · AWS CodeDeploy · AWS CLI v2 · Region us-east-1. Verified against official sources on 2026-11-18.
Learning objectives
By the end of this lesson you can:
- Explain the difference between continuous integration, continuous delivery and continuous deployment, and say which one a bank usually runs in production.
- Draw a pipeline as a sequence of stages with gates, and name the artefact that travels through it.
- Apply the rule build once, deploy the same bytes everywhere, and show how an image digest makes it checkable.
- Map each pipeline stage to GitHub Actions, AWS CodeBuild, AWS CodePipeline, AWS CodeDeploy, Amazon ECR or AWS CloudFormation.
- Choose between GitHub Actions, CodePipeline plus CodeBuild, or a hybrid, using a short decision rule.
- Run a small C# verification step that proves the running service is the commit the pipeline built.
Prerequisites
- Git and GitHub for regulated teams — protected branches, pull-request reviews and CODEOWNERS.
- Module 3: .NET on AWS — containers, ECR and ECS on Fargate.
- Tools: a terminal, Docker, and either the .NET 10 SDK or the
mcr.microsoft.com/dotnet/sdk:10.0image. No AWS account is needed for this lesson.
Why this matters in banking
Imagine the Harbourline Bank Accounts API has a bug that rounds a balance incorrectly. Support asks: "Which build is in production, who approved it, which tests ran, and how do we put the previous one back?" If the answer is "Dave built it on his laptop and copied the files", the bank has no evidence, no repeatability and no fast rollback.
Delivery pipelines exist to make those answers boring. In a regulated bank they do four jobs at once:
- Quality control. Every change goes through the same automated checks.
- Security control. Scanning, signing and least-privilege deployment happen in one place that can be audited.
- Change-management evidence. The pipeline records who approved what and when.
- Operational resilience. Releases are small, frequent and reversible, which is safer than rare, large and scary.
This lesson gives you the shared vocabulary. The rest of the module builds each piece.
The idea in plain language
A pipeline is an automated assembly line that takes a code change from a developer's commit to running in production. It has stages (build, test, scan, deploy), and between stages there are gates: conditions that must be true before the line moves on.
Three terms are often confused:
| Term | What is automated | Who presses the final button |
|---|---|---|
| Continuous integration (CI) | Merge often; every merge builds and runs the automated tests | Nobody — CI never deploys to production |
| Continuous delivery | Every change that passes the pipeline is ready to release | A human (or an approval gate) decides when |
| Continuous deployment | Every change that passes the pipeline is released automatically | Nobody |
Most banks run continuous delivery to production, with continuous deployment to development and test. The manual step is not a failure of automation: it is the segregation of duties control. Your change-management policy decides who may approve, not the tool.
Two more words you need:
- Artefact: the single thing the pipeline builds and everything downstream consumes. For a container-based .NET service it is a container image stored in Amazon ECR. For a Lambda function it is a zip file or image. For infrastructure it is a CloudFormation template or a Terraform plan.
- Environment: a place the artefact runs, such as
dev,test,stagingorprod. In AWS the strongest boundary is a separate AWS account per environment (covered in Environment separation).
Analogy: a pipeline is a sealed-bag cash route. The bag is packed once at the cash centre (build), sealed with a numbered tag (digest), and every checkpoint (test, staging, prod) checks that the tag is intact before opening the next door. Nobody re-packs the bag at a checkpoint, because then the numbered tag would no longer prove what is inside.
The rule that matters most: build once, promote the same artefact
A common anti-pattern is to rebuild the application for each environment, for example dotnet publish in the test job and again in the prod job. The two builds can differ: a newer base image, a package that floated to a new patch version, a different timestamp. What you tested is then not what you shipped.
The rule is:
- Build once, in the first stage.
- Identify the artefact by a content hash, not a name. For container images that is the digest (
sha256:…). A tag such as1.4.0is a label someone can move; a digest cannot lie. - Promote the same digest through test, staging and production. Only configuration changes between environments (and configuration comes from the environment, not from the image).
The lab for this module applies the rule literally: the release.yml workflow outputs the image reference as repository@sha256:… and every later job deploys exactly that string.
What problem the AWS services solve
AWS offers a set of developer tools, each covering one stage. You can use them together, mix them with GitHub Actions, or ignore most of them. Know what each one is for:
| Service | What it does | Typical limits and sharp edges |
|---|---|---|
| AWS CodeConnections | Lets AWS services read your GitHub (or GitLab, Bitbucket) repository through an authorised connection | A connection must be completed once in the console (a human handshake); it starts in a pending state ⚠ VERIFY current naming, as CodeStar Connections was renamed |
| AWS CodeCommit | Managed Git repositories inside AWS | Closed to new customers from July 2024, then returned to general availability on 2025-11-24 according to this module's index ⚠ VERIFY on the CodeCommit page before you depend on it. Most teams still choose GitHub |
| AWS CodeBuild | Runs a build in a fresh container (or VM) that you define with a buildspec.yml; billed per build minute | Builds are ephemeral; caching must be configured; Docker builds need privileged mode |
| AWS CodePipeline | Orchestrates stages: source, build, test, approval, deploy; records every execution | Orchestrates other services; it does not build anything itself. V2 pipelines are billed per action-execution minute ⚠ VERIFY current price |
| AWS CodeDeploy | Shifts traffic to a new version on EC2, on-premises servers, Lambda or ECS, and rolls back on alarms | ECS now has native blue/green inside ECS itself; see ECS deployment strategies |
| Amazon ECR | Stores and scans container images | Tags are mutable unless you set immutability |
| AWS CodeArtifact | Private NuGet, npm, Maven and PyPI repository with upstream proxying | Useful for private shared libraries and for controlling which public packages are allowed |
| AWS CloudFormation / CDK / Terraform | Create the infrastructure the artefact runs on | Covered in Infrastructure automation in the pipeline |
Status notes for banks that keep an eye on the vendor. Amazon CodeCatalyst is closed to new customers, AWS Cloud9 is closed to new customers, and Amazon CodeGuru Reviewer is in maintenance (see the module overview for the verified dates). Do not design a new platform around any of them.
Microsoft / Azure comparison
| You know (Microsoft/Azure) | AWS or GitHub equivalent | What is different |
|---|---|---|
| Azure Repos | GitHub (recommended) or CodeCommit | The module uses GitHub; AWS services read it through CodeConnections |
| Azure Pipelines (YAML), build stage | GitHub Actions workflow job, or CodeBuild project | CodeBuild is only the build runner; orchestration is a separate service |
| Azure Pipelines multi-stage YAML | GitHub Actions jobs with needs, or a CodePipeline pipeline | In CodePipeline the pipeline definition is not YAML in your repository by default; it is a resource you create with IaC |
| Pipeline artefacts / Azure Artifacts | Actions artefacts, CodePipeline artefact store (S3), ECR, CodeArtifact | The pipeline artefact store is an S3 bucket you should encrypt and lock down |
| Environments with approvals and checks | GitHub environments with required reviewers; CodePipeline manual approval action | Both record who approved; export that record as evidence |
| Service connection to Azure | OIDC federation to an IAM role | No stored secret; see the next lesson, GitHub Actions with OIDC |
| Release pipeline with deployment slots | ECS blue/green, Lambda aliases, CodeDeploy | Traffic shifting is driven by health checks and CloudWatch alarms |
| Azure Monitor alerts gating a release | CloudWatch alarms attached to the deployment | Alarm-based rollback is a first-class setting on ECS and CodeDeploy |
Architecture
The generic pipeline
Where the tools sit
Notice that two orchestrators (GitHub Actions and CodePipeline) can drive the same targets. You normally choose one orchestrator per service, not both.
Security-boundary view
The principle: the further a job is from the production account, the fewer permissions it has. Pull-request code gets none.
Step-by-step implementation
This lesson is a concepts lesson, so the steps are about designing and sanity-checking a pipeline rather than creating AWS resources.
Write the pipeline as a list of questions
For the Accounts API, write down what each stage must prove:
| Stage | Question it answers | Failing it means |
|---|---|---|
| Pull request | Has another person reviewed this, and does it build? | Cannot merge |
| Build and unit test | Does the code compile and do the fast tests pass? | Stop; nothing is published |
| Scan | Is a secret, a critical vulnerability or a bad dependency present? | Stop; nothing is published |
| Publish | Is the artefact immutable and traceable to a commit? | Stop |
| Test environment | Does the artefact work with real infrastructure? | Do not promote |
| Approval | Did the right person, who is not the author, approve? | Do not deploy to prod |
| Production deploy | Is the new version healthy for real traffic? | Roll back automatically |
If you cannot state the question, the stage is probably decoration.
Choose the artefact and how it is identified
For the Accounts API: a container image in ECR, immutable tags, identified in deployments by digest. Record the commit SHA inside the image (the lab stamps it into GET /version) so a running container can tell you where it came from.
Separate what changes per environment
List everything that differs between test and prod: database endpoints, log levels, feature flags, secret ARNs. These belong in the environment's configuration (task definition environment, Parameter Store, Secrets Manager), never baked into the image.
Decide the orchestrator
Use the decision rule in the next section. Write the decision and the reasons in one paragraph in your architecture decision record; auditors like a stated reason more than a perfect choice.
Add verification at the end
A deployment is not "done" when the API call returns. It is done when the running system reports the version you expect and its health checks are green. The C# tool below does exactly that.
Decision rule: GitHub Actions, CodePipeline, or both?
| Question | If yes, lean towards |
|---|---|
| Is the code already in GitHub and the team lives in pull requests? | GitHub Actions |
| Does the organisation forbid third-party SaaS from running build steps with cloud access? | CodePipeline plus CodeBuild (runs inside your AWS account) |
| Do builds need access to private VPC resources (an internal package feed, a database for integration tests)? | CodeBuild in a VPC, or self-hosted runners in your VPC |
| Do you need a single place where release approvals and execution history live next to the AWS resources they change? | CodePipeline |
| Do you need rich marketplace actions and fast iteration on workflows? | GitHub Actions |
| Is the deployment itself an ECS or Lambda traffic shift with alarms? | Either; the traffic shift is done by ECS or CodeDeploy, not by the orchestrator |
A hybrid is common and sensible: GitHub Actions for build, test and scan; the AWS-native service for the deployment mechanics. That is the shape of this module's project.
Whichever you pick, keep the pipeline definition in version control, reviewed by CODEOWNERS (the lab's CODEOWNERS requires platform and security teams to approve changes to .github/). A pipeline anyone can edit is a pipeline anyone can use to reach production.
AWS Console instructions
You will see each tool in detail later. For now, find them and notice what they show:
- Console → Developer Tools → Settings → Connections (CodeConnections). If you have no connections, the list is empty; that is expected. Do not create one yet.
- Console → CodePipeline → Pipelines. Read the "Create pipeline" wizard's first page to see the pipeline types (V1 and V2). Close it without creating anything.
- Console → CodeBuild → Build projects. Note that a project is a template for builds, not a build.
- Console → CodeDeploy → Applications. Note the compute platforms offered (EC2/on-premises, AWS Lambda, Amazon ECS).
- Console → ECR → Repositories. Note Private, Public and Pull through cache tabs.
Navigation labels change from time to time; if one differs, use the service search box at the top of the console.
AWS CLI
These read-only commands list what exists in an account, which is a safe way to explore. Replace the profile if yours differs.
# Who am I? Confirms the SSO session before any other command.
aws sts get-caller-identity --profile learn-sandbox
# List pipelines (empty in a fresh sandbox). Read-only.
aws codepipeline list-pipelines --profile learn-sandbox --region us-east-1
# List CodeBuild projects. Read-only.
aws codebuild list-projects --profile learn-sandbox --region us-east-1
# List CodeConnections connections. Read-only. (The CLI namespace is codeconnections;
# older accounts may still use codestar-connections.) ⚠ VERIFY the namespace in your CLI version.
aws codeconnections list-connections --profile learn-sandbox --region us-east-1
# List CodeDeploy applications. Read-only.
aws deploy list-applications --profile learn-sandbox --region us-east-1
# List ECR repositories with their immutability and scan settings. Read-only.
aws ecr describe-repositories \
--query "repositories[].{name:repositoryName,tags:imageTagMutability,scan:imageScanningConfiguration.scanOnPush}" \
--profile learn-sandbox --region us-east-1Infrastructure as Code
A pipeline can itself be code. This minimal CodePipeline V2 skeleton shows the shape (source from GitHub through a connection, a build action, a manual approval). The full, working pipeline is built in CodeBuild, CodePipeline and CodeDeploy; here the point is that stages and gates are resources you can review.
using Amazon.CDK;
using Amazon.CDK.AWS.CodePipeline;
using Amazon.CDK.AWS.CodePipeline.Actions;
using Constructs;
namespace Harbourline.Pipelines;
public class PipelineSkeletonStack : Stack
{
public PipelineSkeletonStack(Construct scope, string id, string connectionArn, IStackProps? props = null)
: base(scope, id, props)
{
var source = new Artifact_("Source");
var pipeline = new Pipeline(this, "AccountsApi", new PipelineProps
{
PipelineName = "hl-accounts-api-skeleton",
PipelineType = PipelineType.V2,
ExecutionMode = ExecutionMode.QUEUED,
});
pipeline.AddStage(new StageOptions
{
StageName = "Source",
Actions = new IAction[]
{
new CodeStarConnectionsSourceAction(new CodeStarConnectionsSourceActionProps
{
ActionName = "GitHub",
Owner = "harbourline-learn",
Repo = "accounts-api",
Branch = "main",
ConnectionArn = connectionArn,
Output = source,
}),
},
});
pipeline.AddStage(new StageOptions
{
StageName = "Approve",
Actions = new IAction[]
{
new ManualApprovalAction(new ManualApprovalActionProps
{
ActionName = "ProdApproval",
AdditionalInformation = "Change ticket and test evidence must be attached.",
}),
},
});
Amazon.CDK.Tags.Of(this).Add("Project", "cea-lab");
Amazon.CDK.Tags.Of(this).Add("Lab", "m09-concepts");
}
}The class names Artifact_ and CodeStarConnectionsSourceAction are the C# spellings in current CDK v2 ⚠ VERIFY against your Amazon.CDK.Lib version, because construct names around CodeConnections have been renamed in some languages.
Complete code
The most valuable last step of any pipeline is a check that the running system is the one you built. This is a runnable single-file C# program (.NET 10 supports running a .cs file directly). It polls GET /version until the service reports the expected commit, then exits 0; otherwise 1. The Accounts API in labs/m09-delivery-pipeline exposes exactly this endpoint.
// Usage: dotnet run VerifyDeployed.cs -- <base-url> <expected-commit> [attempts] [delay-seconds]
// Exit codes: 0 = the running service reports the commit we built, 1 = mismatch or unreachable, 2 = usage.
using System.Text.Json;
if (args.Length < 2)
{
Console.Error.WriteLine("usage: VerifyDeployed <base-url> <expected-commit> [attempts] [delay-seconds]");
return 2;
}
var baseUrl = args[0].TrimEnd('/');
var expected = args[1].Trim().ToLowerInvariant();
var attempts = args.Length > 2 ? int.Parse(args[2]) : 10;
var delay = TimeSpan.FromSeconds(args.Length > 3 ? int.Parse(args[3]) : 6);
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(10) };
string? lastSeen = null;
for (var attempt = 1; attempt <= attempts; attempt++)
{
try
{
var json = await http.GetStringAsync($"{baseUrl}/version");
using var doc = JsonDocument.Parse(json);
lastSeen = doc.RootElement.GetProperty("commit").GetString()?.ToLowerInvariant();
if (lastSeen == expected)
{
Console.WriteLine($"OK: {baseUrl} runs commit {expected[..7]} (attempt {attempt}).");
return 0;
}
Console.WriteLine($"attempt {attempt}/{attempts}: service reports {lastSeen?[..Math.Min(7, lastSeen.Length)] ?? "nothing"}, expected {expected[..7]}");
}
catch (Exception ex) when (ex is HttpRequestException or TaskCanceledException or JsonException or KeyNotFoundException)
{
Console.WriteLine($"attempt {attempt}/{attempts}: {ex.GetType().Name}: {ex.Message}");
}
if (attempt < attempts)
{
await Task.Delay(delay);
}
}
Console.Error.WriteLine($"FAIL: {baseUrl} did not report commit {expected}. Last seen: {lastSeen ?? "none"}.");
return 1;Try it against the lab API running locally:
# Terminal 1 (from labs/m09-delivery-pipeline): run the API with a known commit
docker build --build-arg VERSION=1.0.0 --build-arg GIT_SHA=3f9c2ab1d4e5f60718293a4b5c6d7e8f90a1b2c3 -t hl-m09-accounts-api:dev .
docker run --rm -p 8080:8080 hl-m09-accounts-api:dev
# Terminal 2: verify
dotnet run VerifyDeployed.cs -- http://localhost:8080 3f9c2ab1d4e5f60718293a4b5c6d7e8f90a1b2c3 3 2A minimal GitHub Actions workflow that expresses the generic pipeline (no AWS yet, so it is free and safe) is below. The real version in the lab adds scanning, OIDC and approvals.
name: minimal-ci
on:
pull_request:
branches: [main]
push:
branches: [main]
permissions:
contents: read # the token can read the code and nothing else
jobs:
build-test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
global-json-file: global.json
- run: dotnet build DeliveryPipeline.slnx -c Release
- run: dotnet test --solution DeliveryPipeline.slnx -c Release --no-buildCode explained line by line
VerifyDeployed.cs
if (args.Length < 2)— a single-file program receives its arguments inargs. Two are required, so a typo fails fast with exit code2, which the pipeline can tell apart from a real mismatch.expected = ... ToLowerInvariant()— Git SHAs are hexadecimal; normalising case avoids a false mismatch.attemptsanddelay— deployments are not instantaneous. ECS needs time to start tasks and shift traffic, so the check retries rather than failing on the first call.HttpClient { Timeout = 10 s }— never leave a pipeline step without a timeout; a hung request would otherwise hold a runner until the job timeout.JsonDocument.ParseandGetProperty("commit")— reads the field the API publishes.JsonDocumentis disposable, henceusing.catch (Exception ex) when (...)— only expected failures are retried (network, timeout, malformed body, missing field). Anything else, such as anOutOfMemoryException, is a real bug and should crash the step.return 0/1/2— top-level statements can return an exit code; CI tools decide pass or fail from it.
minimal-ci.yml
permissions: contents: read— a workflow-level default that denies the token every other permission.persist-credentials: false— the checkout does not leave the token in.git/config, so later steps cannot reuse it by accident.uses: …@<40-character SHA> # v7.0.1— the action is pinned to an exact commit; the comment records the human-readable version. Why this matters is explained in the pipeline security lesson.--no-buildon the test step — the test step reuses the build output, which keeps "build once" true even inside a single job.
Security considerations
⚠ Learning shortcut — not for production
The skeleton pipeline attaches no permissions to its role and uses force_destroy on the artefact bucket so you can delete it easily. A production pipeline's service role is scoped to the exact bucket, connection and deploy targets it needs, the artefact bucket is encrypted with a customer managed KMS key and blocks public access, and its bucket policy denies any principal except the pipeline. Never ship a pipeline role with AdministratorAccess "to get it working".
- A pipeline is a privileged identity. Whoever can change the pipeline can reach every environment it deploys to. Protect the pipeline definition like production code.
- Pull-request code is untrusted. Give PR workflows no cloud credentials and no secrets. This is the single most important rule.
- Prefer short-lived credentials. OIDC federation (next lesson) replaces stored access keys with credentials that expire within an hour.
- Record, do not just log. Logs scroll away. Keep the run URL, digest, approver and scan results as a release record (Release management and audit evidence).
- Compliance. This lesson does not make a pipeline compliant with anything. Control mappings (for example to PCI DSS change-management requirements or your internal policy) are decisions for your compliance, risk and audit teams.
Banking use case
Harbourline's mobile-banking team ships the Accounts API twice a week. Their pipeline is continuous delivery:
- Every pull request needs one approving review from a code owner and green CI. Direct pushes to
mainare blocked. - Merging to
mainbuilds the image once, scans it and pushes it to ECR with an immutable tag. - The same digest is deployed automatically to the test account, where integration and smoke tests run.
- Production needs an approval from someone who did not write or merge the change, and a change ticket reference (for example
CHG-104233, fictional). - Production uses a blue/green deployment with CloudWatch alarms; a failed health check rolls back automatically.
- The pipeline writes a release record to an append-only evidence bucket.
When internal audit asks "show me three random releases from last quarter", the team exports three records rather than reconstructing events from chat history.
Common mistakes
- Rebuilding per environment → results are not comparable → build once and promote the digest.
- Using the
latesttag → nobody knows what is running → use commit-based and version tags, and deploy by digest. - Baking configuration into the image → every environment needs its own build → read configuration from the environment.
- Giving CI jobs production credentials "for convenience" → one compromised dependency reaches production → separate roles per stage.
- Treating approval as decoration → the approver is the author → enforce that the approver differs from the author in the release policy.
- No verification after deploy → "deployed" means "the API call returned" → check the running version and health.
- One giant pipeline nobody understands → changes become risky → keep stages small and named by the question they answer.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
VerifyDeployed.cs prints Connection refused | Container not started, or wrong port | Check docker ps; the lab API listens on 8080 inside the container |
| Verification reports an older commit | Deployment still in progress, or traffic not shifted | Increase attempts; check the ECS deployment status |
dotnet run VerifyDeployed.cs says it cannot find a project | Older SDK without file-based app support | Use .NET 10 SDK, or the mcr.microsoft.com/dotnet/sdk:10.0 image |
CodePipeline source action stays Pending | CodeConnections connection not authorised | Complete the connection handshake once in the console |
aws codeconnections command not found | Older AWS CLI v2 | Update the CLI, or use the codestar-connections namespace ⚠ VERIFY |
A GitHub workflow does not start on push | Workflow file not on the default branch, or path filters exclude the change | Merge the workflow to main; check on: filters |
Cost and cleanup
Cost: free. The lesson creates no AWS resources. GitHub Actions is free for public repositories and has a monthly allowance for private ones ⚠ VERIFY current minutes. The skeleton IaC is for reading: do not apply it unless you also complete the CodePipeline lesson, where cost and teardown are explained (CodePipeline V2 is billed per action-execution minute, with a small monthly free allowance ⚠ VERIFY).
Local cleanup:
# Stop and remove the local container if still running, and the dev image
docker rm -f $(docker ps -q --filter ancestor=hl-m09-accounts-api:dev) 2>/dev/null
docker rmi hl-m09-accounts-api:devExercises
- 🟢 Guided: Write the "list of questions" table for a pipeline that deploys a Lambda function (stages, the question each answers, and what failing means). Name the artefact and how it is identified.
- 🟡 Challenge: Take the minimal workflow and add a second job,
publish, that only runs onmain,needsthe first job, and uploads the build output as a workflow artefact. Explain in two sentences whypublishdoes not rebuild. - 🔴 Live problem: Your head of engineering says "we deploy straight from the developers' IDE because the pipeline is slow, and we have a production incident every month." Write a one-page proposal that keeps the team's speed, names the first three pipeline stages you would build, and states which controls you would make non-negotiable. Include what you would measure after one month.
Assignment
Create docs/delivery-design.md in your portfolio repository describing the delivery pipeline for the Accounts API: stage list with the question each stage answers, the artefact and how it is identified, which tool you chose for orchestration and why (use the decision rule), and a diagram of the trust zones. One page, no code.
Solutions
For a Lambda function:
| Stage | Question | Failing it means |
|---|---|---|
| Pull request | Reviewed by a code owner, builds, unit tests pass? | Cannot merge |
| Build | Does dotnet publish produce a package, and are dependencies free of high advisories? | Nothing published |
| Package | Is there one zip (or image) with a recorded SHA-256? | Stop |
| Deploy to test | Does the new version pass smoke tests when invoked through an alias? | Do not promote |
| Approval | Did someone other than the author approve with a ticket? | Do not deploy to prod |
| Production | Do alarms stay green while a canary alias shifts traffic? | Automatic rollback |
The artefact is the zip file stored in S3 (or the image in ECR). It is identified by its content hash (the SHA-256 of the zip, or the image digest), and the Lambda version number that Lambda assigns when you publish it is the immutable deployment handle. The reason to name a hash and a version is that names can be reused, but hashes and published versions cannot be changed.
publish:
needs: build-test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: build-output(and an actions/upload-artifact step at the end of build-test that uploads artifacts/ as build-output).
publish does not rebuild because it downloads the artefact the first job produced. A rebuild could differ from what was tested (a floating dependency, a newer base image), which would break the guarantee that tested bytes equal shipped bytes. The if condition keeps publishing off pull requests, which are untrusted.
A good answer is short, honest about the trade-off and measurable:
- Diagnose the speed complaint first. Measure where the pipeline's time goes (tests, image build, scans). Caching restore and Docker layers and running independent jobs in parallel usually halves the time.
- First three stages: protected
mainwith review and CI on pull requests; build once and test; publish an immutable, scanned artefact. Deployment to test follows. - Non-negotiables: no deployments from laptops (remove IDE deploy permissions in IAM); no stored access keys (OIDC); approval by someone who is not the author for production; a release record for every deployment.
- Measure: lead time from merge to production, deployment frequency, change failure rate and time to restore service. If the monthly incident rate does not fall, the controls are wrong.
- Governance: agree the approval rule with risk and audit; do not decide it alone.
The reason to propose measurements is that "pipelines are slow" and "incidents are monthly" are opinions until you have numbers.
Knowledge check
Answer: In continuous delivery every change that passes the pipeline is ready to release, but a person or approval gate decides when. In continuous deployment, passing the pipeline releases automatically. Banks commonly use delivery for production because the human approval supports segregation of duties.
Answer: A tag is a movable label; unless tags are immutable, it can later point to different content. A digest is a hash of the content, so deploying by digest guarantees the bytes tested are the bytes shipped. The other options (a name, a timestamp) can all be reused or faked.
Answer: AWS CodePipeline. CodeBuild runs the build; CodeDeploy shifts traffic; ECR stores images. CodePipeline connects them and records executions.
Answer: Pull-request code can come from a fork or from a compromised contributor, so anything the workflow can reach, an attacker can reach. Without credentials, the worst a malicious PR can do is waste build minutes.
Answer: Configuration and identity: for example database endpoints, secret ARNs, log levels, feature flags, the IAM role the task runs under, and the AWS account itself. The image does not change.
Interview questions
- "Walk me through a pipeline you would design for a payments API." Pull request with review and CI; build once; scan; publish an immutable image by digest; deploy to test automatically; approval by someone other than the author for prod; blue/green with alarm rollback; a release record. Mention which controls are non-negotiable and why.
- "GitHub Actions or CodePipeline?" It depends on where the code and the runners must live. A strong answer states a decision rule (code location, network access to private resources, where approvals must be recorded) and notes that a hybrid is normal.
- "What does 'build once' mean and why does it matter?" The same artefact, identified by digest, is promoted across environments, so tests prove what ships.
- "How do you know what is running in production?" The service reports its commit and release identifier; the pipeline verifies it after deploy; deployment history and the release record agree.
- "What would you not automate?" Production approval, where policy requires a human who is not the author; and the decision to accept a vulnerability risk.
Certification practice
A team deploys the same ASP.NET Core service to test and production. Today the production job runs dotnet publish again before deploying. After an outage, they cannot prove production runs what was tested. Which change best addresses this?
A. Add a longer integration test suite to the production job.
B. Build the container image once, push it to Amazon ECR, and deploy the same image digest to both environments.
C. Tag the production image latest so it is always current.
D. Run the production build on a larger instance type.
Answer: B. Building once and promoting by digest guarantees identical bytes. A tests more but still tests a different build. C makes identification worse. D changes speed, not identity.
Which AWS service runs a build defined in a buildspec.yml in a fresh, isolated container?
A. AWS CodePipeline B. AWS CodeDeploy C. AWS CodeBuild D. Amazon ECR
Answer: C. CodeBuild runs buildspec-defined builds. CodePipeline orchestrates, CodeDeploy deploys, ECR stores images.
A bank wants developers to open pull requests from forks of an internal repository without any chance of the workflow reaching AWS. Which approach is correct?
A. Store an access key as a repository secret and restrict it with a deny policy.
B. Give pull-request workflows no AWS role; only main and protected environments can assume deploy roles.
C. Allow any workflow in the repository to assume the production role but require MFA.
D. Run pull-request workflows with pull_request_target so secrets are available.
Answer: B. Credentials are only issued to trusted contexts. A keeps a long-lived key where untrusted code might read it. C cannot work, since workflows cannot supply an MFA code. D is the opposite of safe: pull_request_target runs with base-repository secrets.
Completion checklist
- I can explain delivery versus deployment in two sentences
- I can state why the artefact is built once and identified by digest
- I completed the guided exercise
- I ran
VerifyDeployed.csagainst the local container - I removed the local container and image
Key takeaways
- A pipeline is stages plus gates; each stage should answer a stated question.
- Build once, promote the same digest. Only configuration differs per environment.
- Orchestration (GitHub Actions or CodePipeline) and execution (runner or CodeBuild) and deployment mechanics (ECS or CodeDeploy) are separate jobs; a hybrid is normal.
- The further a job is from production, the fewer permissions it holds; pull-request code holds none.
- A deployment is finished when the running system proves its version and health, and a release record exists.
Further reading
- What is AWS CodePipeline? — concepts: pipelines, stages, actions, executions
- What is AWS CodeBuild?
- What is AWS CodeDeploy?
- CodePipeline pipeline types (V1 and V2)
- Next: GitHub Actions with OIDC
Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.
Git and GitHub for regulated teams
Choose a branching strategy, protect main with rulesets, route reviews with CODEOWNERS and signed commits, and turn every merge into audit evidence a bank's change board will accept.
GitHub Actions with OIDC: deploy to AWS with no stored keys
Create an IAM OIDC identity provider for GitHub, write trust policies that pin a role to one repository and one environment or branch, and prove that forks, pull requests and sibling repositories cannot assume it.