codepipeline

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package codepipeline reads and writes the artifacts of a CodePipeline job, the S3 half of Powertools Python's CodePipelineJobEvent (setup_s3_client, get_artifact, put_artifact).

A CodePipeline Lambda invoke action receives temporary credentials scoped to the pipeline's artifact store. FromConfig builds an S3 client with them; New takes any client:

func handle(ctx context.Context, event eventsource.CodePipelineJobEvent) error {
	artifacts := codepipeline.FromConfig(cfg, event)
	template, err := artifacts.GetFile(ctx, "SourceArtifact", "template.yaml")
	...
	return artifacts.Put(ctx, "BuildArtifact", bytes.NewReader(out), "application/zip")
}

It lives in its own package so that importing eventsource does not bring in the S3 client.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrArtifactNotFound reports a name the job has no artifact for.
	ErrArtifactNotFound = errors.New("artifact not found")
	// ErrFileNotFound reports a file the artifact archive does not hold.
	ErrFileNotFound = errors.New("file not found in the artifact")
)

Errors of the artifact helpers.

Functions

func NewS3Client

func NewS3Client(cfg aws.Config, job eventsource.CodePipelineJobEvent, optFns ...func(*s3.Options)) *s3.Client

NewS3Client returns an S3 client authenticated with the job's temporary artifact credentials. cfg gives the region and everything else; optFns customize the client further.

Types

type Artifacts

type Artifacts struct {
	// contains filtered or unexported fields
}

Artifacts reads the input artifacts and writes the output artifacts of a job. It is safe for concurrent use when the client is.

func FromConfig

func FromConfig(cfg aws.Config, job eventsource.CodePipelineJobEvent, optFns ...func(*s3.Options)) *Artifacts

FromConfig returns the artifacts of job, accessed with a client built by NewS3Client.

func New

New returns the artifacts of job, accessed with client.

func (*Artifacts) Get

func (a *Artifacts) Get(ctx context.Context, name string) ([]byte, error)

Get returns the content of the input artifact called name.

func (*Artifacts) GetFile

func (a *Artifacts) GetFile(ctx context.Context, name, filename string) ([]byte, error)

GetFile returns one file of the input artifact called name, which is a zip archive, as CodePipeline stores source and build outputs. The archive is spooled to a temporary file, as Powertools Python does, so that a large artifact does not have to fit in memory.

func (*Artifacts) Put

func (a *Artifacts) Put(ctx context.Context, name string, body io.Reader, contentType string) error

Put writes body as the output artifact called name. When the pipeline encrypts its artifact store with a KMS key, the object is encrypted with it; an S3 Bucket Key is always enabled, as Powertools Python does.

type S3API

type S3API interface {
	GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
	PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
}

S3API is the part of the S3 client the helpers use; *s3.Client satisfies it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL