Artifacts, CodeArtifact, Amplify and Release Management
Overview
Deployable code is more than your own source: it includes dependencies, build outputs and configuration. A sound release process builds an artifact once, stores it immutably with a version, and promotes the same artifact through environments. AWS CodeArtifact hosts private package repositories (npm, PyPI, Maven, NuGet and more), while Git branches, tags and labels record what is released.
Imagine a bakery shipping boxes. Each box (artifact) is sealed once, labelled with a batch number (version) and moved along the delivery chain. Nobody opens it and re-bakes the bread at each stage.
The exam also expects knowledge of managing deployed environments with Amplify branches, AWS Copilot environments, Lambda aliases and container image tags, and of organising repository directories and build specs.
Key Concepts
- CodeArtifact has domains (shared storage, encryption, policies) containing repositories with upstream repositories and external connections to npm, PyPI, Maven Central and more.
- A package version fetched through CodeArtifact is cached, protecting builds from upstream outages or deleted packages.
- Authenticate with a short-lived token (
aws codeartifact get-authorization-token, valid up to 12 hours) oraws codeartifact login. - Semantic versioning (MAJOR.MINOR.PATCH) communicates compatibility; pin and lock dependencies (package-lock.json, requirements.txt with hashes).
- Build once, deploy many: the same Lambda zip, container image or SAM-packaged template moves through dev, test and prod.
- Immutable references such as Lambda versions, ECR image tags with immutability enabled, or image digests identify approved releases.
- Git branching (trunk-based or GitFlow) and tags mark releases; pipelines trigger from branch pushes.
- Amplify branches and AWS Copilot CLI environments map branches or stages to deployments for web and container apps.
Detailed Notes
Using CodeArtifact
aws codeartifact create-domain --domain acme
aws codeartifact create-repository --domain acme --repository shared \
--upstreams repositoryName=npm-store
aws codeartifact create-repository --domain acme --repository npm-store
aws codeartifact associate-external-connection --domain acme --repository npm-store \
--external-connection public:npmjs
aws codeartifact login --tool npm --domain acme --repository shared
npm install lodash # resolved through CodeArtifact and cached
Developers and CodeBuild fetch packages from shared; the first request for a public package pulls it from upstream and stores a copy. Publish private libraries with npm publish or twine upload. In CodeBuild, the service role needs codeartifact:GetAuthorizationToken, codeartifact:ReadFromRepository and sts:GetServiceBearerToken.
version: 0.2
phases:
install:
commands:
- aws codeartifact login --tool pip --domain acme --repository shared
- pip install -r requirements.txt
build:
commands:
- pytest -q
- sam build
artifacts:
files: ['.aws-sam/**/*', 'template.yaml']
Repository and artifact layout
| Item | Convention |
|---|---|
| Source | src/ per function or service, shared code in a library or layer |
| Tests | tests/unit, tests/integration, events/ |
| IaC | template.yaml plus samconfig.toml with per-environment sections |
| Build spec | buildspec.yml at the root (CodeBuild) and appspec.yml (CodeDeploy) |
| Dependencies | Lockfiles committed; large dependencies in layers or container images |
Lambda zip packages are limited to 50 MB zipped (direct upload) and 250 MB unzipped including layers; container images up to 10 GB. Check resource requirements (memory, ephemeral storage, vCPU) before choosing the package type.
Release labels and approved versions
| Mechanism | What it identifies |
|---|---|
Git tag v1.4.2 | Source commit of a release |
Lambda version + alias (prod) | Immutable function code plus movable pointer |
| ECR image tag or digest | Container image; enable tag immutability |
| CloudFormation template in S3 + version ID | Approved infrastructure definition |
| CodePipeline artifact (S3 object) | Output of a specific execution |
git tag -a v1.4.2 -m "release 1.4.2" && git push origin v1.4.2
aws lambda publish-version --function-name orders --description "v1.4.2"
aws lambda update-alias --function-name orders --name prod --function-version 17
aws ecr put-image-tag-mutability --repository-name orders --image-tag-mutability IMMUTABLE
Amplify and Copilot for environments
Amplify Hosting connects branches to environments: main to production, develop to staging, with pull request previews. Environment variables are set per branch.
AWS Copilot CLI simplifies container apps on ECS and App Runner. It creates applications, environments and services, generating CloudFormation and a pipeline.
copilot init --app orders --name api --type "Load Balanced Web Service"
copilot env init --name test --profile default
copilot env init --name prod --profile prod-account
copilot svc deploy --name api --env test
copilot pipeline init && copilot pipeline deploy
Each Copilot environment has its own VPC and cluster, so promoting the same image from test to prod is simply another deploy.
Branching strategy and pipelines
Trigger CodePipeline from branch events (via a CodeStar connection to GitHub, GitLab or Bitbucket). Trunk-based development with short-lived branches and feature flags suits frequent releases; release branches suit scheduled releases. Require pull request reviews and passing tests before merging to the release branch. Use manual approval actions before production.
Dependency hygiene
Scan dependencies for vulnerabilities (Amazon Inspector for Lambda and ECR images, or tools in CodeBuild), update regularly, and remove unused packages to shrink package size and cold start. Avoid pulling latest versions in production builds.
Real World Example
A platform team suffered a failed release when an upstream npm package was unpublished mid-build. They introduced CodeArtifact with an upstream npm connection, so every dependency is cached, and CodeBuild installs only from it. Builds create one SAM artifact per commit, tagged with the Git SHA, and the pipeline promotes that same artifact from test to prod by updating the Lambda alias, with an ECR immutable tag policy for container services.
Architecture Diagram
Dependencies come from CodeArtifact; one artifact is promoted through environments.
- 1A push or tag triggers the pipeline.
- 2CodeBuild installs dependencies through CodeArtifact and builds one artifact.
- 3The artifact is stored with a version and passes tests in the test environment.
- 4The same artifact is promoted to production by moving an alias or image tag.
Best Practices
- ✓Install dependencies only through CodeArtifact (or another controlled proxy) and lock versions.
- ✓Build once and promote the same artifact; never rebuild per environment.
- ✓Enable ECR tag immutability and promote by digest or version, not
latest. - ✓Tag releases in Git and publish Lambda versions with aliases for approved releases.
- ✓Keep large or shared dependencies in layers or images and watch package-size limits.
Common Interview Questions
Exam Tips
DVA-C02 focus
- 'Private npm or Maven packages with upstream proxy' means CodeArtifact.
- Zip deployment limit is 50 MB zipped / 250 MB unzipped; images allow 10 GB.
- Approved versions: Lambda aliases, immutable image tags, Amplify branches or Copilot environments.
- Environment-specific config comes from parameters, aliases, stage variables or AppConfig, not separate builds.
Finished this lesson?
0 of 46 lessons done · 0% of the course

