What is an artifact?
An artifact is a built, compiled, or packaged piece of software produced by a CI/CD workflow. It captures a reproducible, versioned snapshot of a software component that you can publish and distribute. Common artifact examples include:- Application packages (ZIP, JAR, WAR)
- Container images and container layers
- Infrastructure-as-code outputs (CloudFormation templates, CDK synthesized artifacts)
- Helm charts, YAML/JSON manifests, AMIs (Amazon Machine Images), golden images
- Third-party libraries or internally built dependencies

Recommended store per artifact type
AWS services for storing artifacts
AWS provides first-party services optimized for different artifact types:- AWS CodeArtifact — Managed package repository for Maven, npm, PyPI, NuGet. Ideal for internal libraries and proxied third-party packages; integrates with IAM for access control.
- Amazon S3 — General-purpose object store suitable for build artifacts, ZIPs, binaries, serverless deployments and IaC artifacts. Supports bucket versioning and lifecycle policies for retention and cost optimization.
- Amazon ECR (Elastic Container Registry) — Purpose-built registry for OCI/Docker images and layers. Provides image storage, IAM-based access, lifecycle policies, and image scanning features.

Image scanning and image consumption notes
- ECR supports vulnerability scanning on push and can integrate with third-party scanners like Trivy. For deeper scanning and runtime checks, integrate Amazon Inspector or other security tools.
- Container images stored in ECR can be consumed across AWS services: Lambda (container images as functions), ECS/EKS (task definitions and pods), and EC2.
- CodeArtifact is less feature-rich than some enterprise products (e.g., JFrog Artifactory), but it offers native AWS integration and is sufficient for many teams.
Artifact flow in CI/CD pipelines
A typical AWS CI/CD pipeline flow:- Source repo (CodeCommit, GitHub, etc.) triggers the pipeline.
- Build step (CodeBuild) executes
install,pre_build,build, andpost_buildphases. - Build outputs are pushed to one or more artifact stores (CodeArtifact, S3, ECR).
- Deployment stages pull artifacts from storage and deploy to targets (CodeDeploy, ECS, Lambda, EC2).

Example: CodeBuild buildspec
Below is a minimalbuildspec.yml that demonstrates CodeBuild phases and artifact publishing. Customize the commands and paths to match your project and artifact destinations.
post_build phase, upload compiled artifacts to S3, or publish packages to CodeArtifact.
Retention and lifecycle management
Retention strategies differ per service. Implement automated lifecycle rules to control storage costs and limit the blast radius of old or unscanned artifacts.
Best practices for artifact management
- Immutable artifacts: treat published artifacts as immutable. If a release is incorrect, publish a new version rather than mutating an existing artifact.
- Consistent environments: package dependencies and configuration so artifacts behave identically across staging and production.
- Automate everything: artifact creation, scanning, storage, and distribution should be automated in CI/CD pipelines to reduce human error.
- Metadata and provenance: publish metadata (release notes, dependency lists, SBOMs) alongside the artifact so consumers can verify provenance and contents.
- Security and access control: restrict who can publish or delete artifacts using IAM, and enable audit logging to track changes.
- Scanning and signing: enable image/package scanning and consider cryptographic signing and attestation to enforce trust boundaries.

Automate metadata collection (for example, a simple JSON or SBOM) and retention policies. If you must comply with supply-chain standards such as SLSA, include reproducible artifact creation and provenance tracking in your pipeline from day one.
Summary
Artifacts are versioned, reproducible snapshots of software used across environments. Select the right AWS service for the artifact type:- Use CodeArtifact for package repositories (Maven, npm, PyPI, NuGet).
- Use S3 for general-purpose object storage and IaC artifacts.
- Use ECR for OCI/Docker images and container layers.
Links and references
- AWS CodeArtifact documentation
- Amazon S3 documentation
- Amazon ECR documentation
- Trivy vulnerability scanner
- CycloneDX SBOM specification
- SLSA supply chain security framework