amplify

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 27 Imported by: 0

README

Amplify

Parity grade: A · SDK aws-sdk-go-v2/service/amplify@v1.40.0 · last audited 2026-07-23 (c807b481)

Coverage

Metric Value
Operations audited 37 (37 ok)
Feature families 2 (2 ok)
Known gaps none
Deferred items 0
Resource leaks clean

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a resource is not found.
	ErrNotFound = awserr.New("NotFoundException", awserr.ErrNotFound)
	// ErrAlreadyExists is returned when a resource already exists.
	ErrAlreadyExists = awserr.New("BadRequestException", awserr.ErrAlreadyExists)
	// ErrValidation is returned when a request parameter fails validation
	// (e.g. an unrecognized Platform/Stage/JobType enum value). Real Amplify
	// rejects these with a 400 BadRequestException.
	ErrValidation = awserr.New("BadRequestException", awserr.ErrInvalidParameter)
)

Functions

This section is empty.

Types

type App

type App struct {
	CreateTime                 time.Time                 `json:"createTime"`
	UpdateTime                 time.Time                 `json:"updateTime"`
	Tags                       *tags.Tags                `json:"tags,omitzero"`
	EnvironmentVariables       map[string]string         `json:"environmentVariables,omitempty"`
	AutoBranchCreationConfig   *AutoBranchCreationConfig `json:"autoBranchCreationConfig,omitempty"`
	CacheConfig                *CacheConfig              `json:"cacheConfig,omitempty"`
	ProductionBranch           *ProductionBranch         `json:"productionBranch,omitempty"`
	DefaultDomain              string                    `json:"defaultDomain,omitzero"`
	IAMServiceRoleArn          string                    `json:"iamServiceRoleArn,omitzero"`
	Name                       string                    `json:"name"`
	Description                string                    `json:"description,omitzero"`
	Repository                 string                    `json:"repository,omitzero"`
	AppID                      string                    `json:"appId"`
	BasicAuthCredentials       string                    `json:"basicAuthCredentials,omitzero"`
	BuildSpec                  string                    `json:"buildSpec,omitzero"`
	CustomHeaders              string                    `json:"customHeaders,omitzero"`
	ARN                        string                    `json:"appArn"`
	RepositoryCloneMethod      string                    `json:"repositoryCloneMethod,omitzero"`
	Platform                   Platform                  `json:"platform"`
	CustomRules                []CustomRule              `json:"customRules,omitempty"`
	AutoBranchCreationPatterns []string                  `json:"autoBranchCreationPatterns,omitempty"`
	EnableBranchAutoBuild      bool                      `json:"enableBranchAutoBuild"`
	EnableBasicAuth            bool                      `json:"enableBasicAuth"`
	EnableAutoBranchCreation   bool                      `json:"enableAutoBranchCreation,omitzero"`
	EnableBranchAutoDeletion   bool                      `json:"enableBranchAutoDeletion,omitzero"`
}

App represents an Amplify application.

ProductionBranch and RepositoryCloneMethod are computed at read time (InMemoryBackend.productionBranchFor / repositoryCloneMethod) and set only on the copy returned to callers -- never written back to the stored table record, so they can never desync from the app's actual branches/jobs or Repository field.

type AppOptions added in v1.2.0

type AppOptions struct {
	IAMServiceRoleArn          *string
	AutoBranchCreationConfig   *AutoBranchCreationConfig
	CacheConfig                *CacheConfig
	BasicAuthCredentials       *string
	BuildSpec                  *string
	CustomHeaders              *string
	EnvironmentVariables       map[string]string
	EnableBranchAutoBuild      *bool
	EnableBasicAuth            *bool
	EnableAutoBranchCreation   *bool
	EnableBranchAutoDeletion   *bool
	AutoBranchCreationPatterns []string
	CustomRules                []CustomRule
}

AppOptions carries the optional App fields beyond the always-present name/description/repository/platform/tags quintet accepted directly by CreateApp/UpdateApp. It is passed as a trailing variadic argument (opts ...AppOptions) so every pre-existing positional call site -- throughout this package's tests and test/e2e/amplify_test.go -- keeps compiling unchanged while CreateApp/UpdateApp gain full field parity with real Amplify's CreateAppInput/UpdateAppInput.

Every field is a pointer/nil-able type so "not set" is distinguishable from the zero value:

  • CreateApp: a nil pointer applies the real-Amplify create-time default (EnableBranchAutoBuild defaults true; every other optional bool defaults false; strings/slices/maps default empty).
  • UpdateApp: a nil pointer means "leave the existing value unchanged", matching real Amplify's partial-update semantics for UpdateApp.

type Artifact

type Artifact struct {
	ArtifactID       string `json:"artifactId"`
	ArtifactType     string `json:"artifactType"`
	ArtifactFileName string `json:"artifactFileName"`
	AppID            string `json:"appId"`
	BranchName       string `json:"branchName"`
	JobID            string `json:"jobId"`
}

Artifact represents an Amplify build artifact. AppID/BranchName/JobID identify the job whose build produced it (see ListArtifacts and janitor.go's advanceJobs, the only producer).

type AutoBranchCreationConfig added in v1.2.0

type AutoBranchCreationConfig struct {
	EnvironmentVariables       map[string]string `json:"environmentVariables,omitempty"`
	BasicAuthCredentials       string            `json:"basicAuthCredentials,omitempty"`
	BuildSpec                  string            `json:"buildSpec,omitempty"`
	Framework                  string            `json:"framework,omitempty"`
	PullRequestEnvironmentName string            `json:"pullRequestEnvironmentName,omitempty"`
	Stage                      string            `json:"stage,omitempty"`
	EnableAutoBuild            bool              `json:"enableAutoBuild,omitempty"`
	EnableBasicAuth            bool              `json:"enableBasicAuth,omitempty"`
	EnablePerformanceMode      bool              `json:"enablePerformanceMode,omitempty"`
	EnablePullRequestPreview   bool              `json:"enablePullRequestPreview,omitempty"`
}

AutoBranchCreationConfig mirrors aws-sdk-go-v2/service/amplify/types.AutoBranchCreationConfig: the template applied to branches Amplify automatically creates for this app (when EnableAutoBranchCreation is set) from AutoBranchCreationPatterns.

type BackendEnvironment

type BackendEnvironment struct {
	CreateTime            time.Time `json:"createTime"`
	UpdateTime            time.Time `json:"updateTime"`
	EnvironmentName       string    `json:"environmentName"`
	BackendEnvironmentARN string    `json:"backendEnvironmentArn"`
	AppID                 string    `json:"appId"`
	StackName             string    `json:"stackName,omitzero"`
	DeploymentArtifacts   string    `json:"deploymentArtifacts,omitzero"`
}

BackendEnvironment represents an Amplify backend environment.

type Branch

type Branch struct {
	CreateTime                 time.Time         `json:"createTime"`
	UpdateTime                 time.Time         `json:"updateTime"`
	EnvironmentVariables       map[string]string `json:"environmentVariables,omitempty"`
	Tags                       *tags.Tags        `json:"tags,omitzero"`
	Framework                  string            `json:"framework,omitzero"`
	BasicAuthCredentials       string            `json:"basicAuthCredentials,omitzero"`
	Stage                      Stage             `json:"stage,omitzero"`
	AppID                      string            `json:"appId"`
	BranchARN                  string            `json:"branchArn"`
	BranchName                 string            `json:"branchName"`
	Description                string            `json:"description,omitzero"`
	DisplayName                string            `json:"displayName,omitzero"`
	SourceBranch               string            `json:"sourceBranch,omitzero"`
	TTL                        string            `json:"ttl,omitzero"`
	ActiveJobID                string            `json:"activeJobId,omitzero"`
	TotalNumberOfJobs          string            `json:"totalNumberOfJobs,omitzero"`
	BuildSpec                  string            `json:"buildSpec,omitzero"`
	BackendEnvironmentARN      string            `json:"backendEnvironmentArn,omitzero"`
	PullRequestEnvironmentName string            `json:"pullRequestEnvironmentName,omitzero"`
	CustomDomains              []string          `json:"customDomains,omitempty"`
	AssociatedResources        []string          `json:"associatedResources,omitempty"`
	EnableAutoBuild            bool              `json:"enableAutoBuild"`
	EnableBasicAuth            bool              `json:"enableBasicAuth"`
	EnableNotification         bool              `json:"enableNotification"`
	EnablePullRequestPreview   bool              `json:"enablePullRequestPreview"`
	EnablePerformanceMode      bool              `json:"enablePerformanceMode,omitzero"`
}

Branch represents an Amplify app branch.

TotalNumberOfJobs and ActiveJobID are computed at read time (InMemoryBackend.branchView) from the branch's actual jobs and, like App.ProductionBranch, only ever set on a returned copy. EnableBasicAuth/ EnableNotification/EnablePullRequestPreview are required response members in real Amplify (types.Branch), so unlike the optional bool fields below they must never be tagged omitempty/omitzero -- omitting a required *bool response member would deserialize client-side as a nil pointer instead of a false one.

type BranchOptions added in v1.2.0

type BranchOptions struct {
	EnvironmentVariables       map[string]string
	DisplayName                *string
	Framework                  *string
	TTL                        *string
	BasicAuthCredentials       *string
	BuildSpec                  *string
	BackendEnvironmentARN      *string
	PullRequestEnvironmentName *string
	SourceBranch               *string
	EnableBasicAuth            *bool
	EnableNotification         *bool
	EnablePullRequestPreview   *bool
	EnablePerformanceMode      *bool
}

BranchOptions carries the optional Branch fields beyond the appId/branchName/description/stage/enableAutoBuild/tags quintet accepted directly by CreateBranch/UpdateBranch. See AppOptions for the nil-means-default-on-create/nil-means-unchanged-on-update convention.

type CacheConfig added in v1.2.0

type CacheConfig struct {
	Type string `json:"type"`
}

CacheConfig mirrors aws-sdk-go-v2/service/amplify/types.CacheConfig.

type CustomRule added in v1.2.0

type CustomRule struct {
	Source    string `json:"source"`
	Target    string `json:"target"`
	Condition string `json:"condition,omitempty"`
	Status    string `json:"status,omitempty"`
}

CustomRule mirrors aws-sdk-go-v2/service/amplify/types.CustomRule.

type DomainAssociation

type DomainAssociation struct {
	AppID                            string       `json:"appId"`
	DomainName                       string       `json:"domainName"`
	ARN                              string       `json:"domainAssociationArn"`
	DomainStatus                     DomainStatus `json:"domainStatus"`
	StatusReason                     string       `json:"statusReason,omitzero"`
	CertificateVerificationDNSRecord string       `json:"certificateVerificationDNSRecord,omitzero"`
	SubDomains                       []SubDomain  `json:"subDomains"`
	EnableAutoSubDomain              bool         `json:"enableAutoSubDomain"`
}

DomainAssociation represents an Amplify custom domain association.

type DomainStatus

type DomainStatus string

DomainStatus represents the status of a domain association.

const (
	// DomainStatusCreating is the creating status.
	DomainStatusCreating DomainStatus = "CREATING"
	// DomainStatusPendingVerification is waiting for verification.
	DomainStatusPendingVerification DomainStatus = "PENDING_VERIFICATION"
	// DomainStatusAvailable is the available status.
	DomainStatusAvailable DomainStatus = "AVAILABLE"
	// DomainStatusFailed is the failed status.
	DomainStatusFailed DomainStatus = "FAILED"
)

type Handler

type Handler struct {
	Backend StorageBackend

	DefaultRegion string
	AccountID     string
	// contains filtered or unexported fields
}

Handler is the Echo HTTP handler for Amplify operations.

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new Amplify handler.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this Amplify instance handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation extracts the Amplify operation from the request path.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource extracts the app ID from the request path.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns the list of supported Amplify operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for Amplify requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a function that matches Amplify API requests.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker starts the background janitor if configured. It implements the worker-lifecycle hook of service.Registerable, so cli.go's generic startup dispatch starts it without any Amplify-specific wiring there.

func (*Handler) WithJanitor

func (h *Handler) WithJanitor(
	backend *InMemoryBackend,
	interval time.Duration,
	taskTimeout ...time.Duration,
) *Handler

WithJanitor attaches a background janitor to the handler. backend must be the concrete *InMemoryBackend backing this Handler -- the janitor needs direct access to the backend's tables and lock, which the StorageBackend interface (used for h.Backend so the handler stays mockable) does not expose.

type InMemoryBackend

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

InMemoryBackend is the in-memory implementation of StorageBackend.

Every resource collection is a *store.Table[T] registered on registry (see store_setup.go); branches, jobs, domains, and backendEnvironments were previously nested per-parent maps and are now flattened to a single Table keyed by a composite "parent|child" string with a companion byApp/byBranch store.Index for the "all children of parent X" lookups the nested maps used to answer directly. webhooksByApp was a reverse-lookup map (map[string][]string); it is now a store.Index on webhooks, not its own Table.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new in-memory Amplify backend.

func (*InMemoryBackend) CreateApp

func (b *InMemoryBackend) CreateApp(
	name, description, repository, platform string,
	tagMap map[string]string,
	opts ...AppOptions,
) (*App, error)

CreateApp creates a new Amplify application. opts is optional (see AppOptions); a nil/omitted opts applies real Amplify's create-time defaults for every field it covers.

func (*InMemoryBackend) CreateBackendEnvironment

func (b *InMemoryBackend) CreateBackendEnvironment(
	appID, environmentName, stackName, deploymentArtifacts string,
) (*BackendEnvironment, error)

CreateBackendEnvironment creates a new backend environment for an app.

func (*InMemoryBackend) CreateBranch

func (b *InMemoryBackend) CreateBranch(
	appID, branchName, description, stage string,
	enableAutoBuild bool,
	tagMap map[string]string,
	opts ...BranchOptions,
) (*Branch, error)

CreateBranch creates a new branch for an Amplify application. opts is optional (see BranchOptions); a nil/omitted opts applies real Amplify's create-time defaults for every field it covers.

func (*InMemoryBackend) CreateDeployment

func (b *InMemoryBackend) CreateDeployment(appID, branchName string) (string, string, error)

CreateDeployment creates a pre-signed upload URL for a manual deployment.

func (*InMemoryBackend) CreateDomainAssociation

func (b *InMemoryBackend) CreateDomainAssociation(
	appID, domainName string,
	subDomains []SubDomainSetting,
	enableAutoSubDomain bool,
) (*DomainAssociation, error)

CreateDomainAssociation creates a custom domain association for an app.

func (*InMemoryBackend) CreateWebhook

func (b *InMemoryBackend) CreateWebhook(appID, branchName, description string) (*Webhook, error)

CreateWebhook creates a new webhook for an app branch.

func (*InMemoryBackend) DeleteApp

func (b *InMemoryBackend) DeleteApp(appID string) error

DeleteApp deletes an Amplify application and cascades the deletion to every child resource: branches (and their jobs and artifacts), domain associations, webhooks, and backend environments. Without this cascade, deleting an app would leave every child resource behind as a ghost row still reachable by ListBranches/ListJobs/etc. under the deleted app's ID, growing every table unboundedly across create/delete churn.

func (*InMemoryBackend) DeleteBackendEnvironment

func (b *InMemoryBackend) DeleteBackendEnvironment(
	appID, environmentName string,
) (*BackendEnvironment, error)

DeleteBackendEnvironment deletes a backend environment.

func (*InMemoryBackend) DeleteBranch

func (b *InMemoryBackend) DeleteBranch(appID, branchName string) error

DeleteBranch deletes a branch from an Amplify application, cascading the deletion to every job (and each job's artifacts) that belongs to it -- without this, deleted branches would leave ghost job/artifact rows behind under a branch name ListJobs/ListArtifacts can no longer reach by any legitimate path once the branch itself 404s.

func (*InMemoryBackend) DeleteDomainAssociation

func (b *InMemoryBackend) DeleteDomainAssociation(
	appID, domainName string,
) (*DomainAssociation, error)

DeleteDomainAssociation deletes a domain association.

func (*InMemoryBackend) DeleteJob

func (b *InMemoryBackend) DeleteJob(appID, branchName, jobID string) (*Job, error)

DeleteJob deletes a job record, cascading the deletion to every artifact that job produced (see janitor.go's advanceJobs) so ListArtifacts can never return a row for a job that no longer exists.

func (*InMemoryBackend) DeleteWebhook

func (b *InMemoryBackend) DeleteWebhook(webhookID string) (*Webhook, error)

DeleteWebhook deletes a webhook.

func (*InMemoryBackend) GenerateAccessLogs

func (b *InMemoryBackend) GenerateAccessLogs(
	appID, domainName, startTime, endTime string,
) (string, error)

GenerateAccessLogs generates a presigned URL for access logs.

func (*InMemoryBackend) GetApp

func (b *InMemoryBackend) GetApp(appID string) (*App, error)

GetApp returns an Amplify application by ID.

func (*InMemoryBackend) GetArtifactURL

func (b *InMemoryBackend) GetArtifactURL(artifactID string) (string, string, error)

GetArtifactURL returns the download URL for an artifact.

func (*InMemoryBackend) GetBackendEnvironment

func (b *InMemoryBackend) GetBackendEnvironment(
	appID, environmentName string,
) (*BackendEnvironment, error)

GetBackendEnvironment returns a backend environment.

func (*InMemoryBackend) GetBranch

func (b *InMemoryBackend) GetBranch(appID, branchName string) (*Branch, error)

GetBranch returns a branch for an Amplify application.

func (*InMemoryBackend) GetDomainAssociation

func (b *InMemoryBackend) GetDomainAssociation(
	appID, domainName string,
) (*DomainAssociation, error)

GetDomainAssociation returns a domain association.

func (*InMemoryBackend) GetJob

func (b *InMemoryBackend) GetJob(appID, branchName, jobID string) (*Job, error)

GetJob returns a job by ID.

func (*InMemoryBackend) GetWebhook

func (b *InMemoryBackend) GetWebhook(webhookID string) (*Webhook, error)

GetWebhook returns a webhook by ID.

func (*InMemoryBackend) ListApps

func (b *InMemoryBackend) ListApps(nextToken string, maxResults int) ([]*App, string, error)

ListApps returns Amplify applications with optional pagination.

func (*InMemoryBackend) ListArtifacts

func (b *InMemoryBackend) ListArtifacts(
	appID, branchName, jobID, nextToken string,
	maxResults int,
) ([]*Artifact, string, error)

ListArtifacts lists the build artifacts produced by a job. Artifacts are created by the janitor (see janitor.go's advanceJobs) when a job reaches SUCCEED -- a job that hasn't completed yet, or that failed/was cancelled, legitimately has none.

func (*InMemoryBackend) ListBackendEnvironments

func (b *InMemoryBackend) ListBackendEnvironments(
	appID, nextToken string,
	maxResults int,
) ([]*BackendEnvironment, string, error)

ListBackendEnvironments lists backend environments for an app.

func (*InMemoryBackend) ListBranches

func (b *InMemoryBackend) ListBranches(
	appID, nextToken string,
	maxResults int,
) ([]*Branch, string, error)

ListBranches returns branches for an Amplify application with optional pagination.

func (*InMemoryBackend) ListDomainAssociations

func (b *InMemoryBackend) ListDomainAssociations(
	appID, nextToken string,
	maxResults int,
) ([]*DomainAssociation, string, error)

ListDomainAssociations lists domain associations for an app.

func (*InMemoryBackend) ListJobs

func (b *InMemoryBackend) ListJobs(
	appID, branchName, nextToken string,
	maxResults int,
) ([]*Job, string, error)

ListJobs lists all jobs for a branch.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)

ListTagsForResource returns all tags for an Amplify resource identified by ARN.

func (*InMemoryBackend) ListWebhooks

func (b *InMemoryBackend) ListWebhooks(
	appID, nextToken string,
	maxResults int,
) ([]*Webhook, string, error)

ListWebhooks lists webhooks for an app.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) StartDeployment

func (b *InMemoryBackend) StartDeployment(
	appID, branchName, jobID, sourceURL string,
) (*Job, error)

StartDeployment starts a deployment from a pre-uploaded artifact.

func (*InMemoryBackend) StartJob

func (b *InMemoryBackend) StartJob(
	appID, branchName, jobType, jobID, commitID, commitMsg string,
	commitTime time.Time,
) (*Job, error)

StartJob creates and starts a new deployment job for a branch. jobID is required when jobType is RETRY (real Amplify's StartJobInput.JobId is required in that case) and identifies the job being retried: if that job exists, its commit metadata is inherited by the new job unless the caller supplies its own. commitTime may be the zero time, in which case the response's commitTime field is omitted (matches an app with no Git commit metadata, e.g. a manually deployed app).

func (*InMemoryBackend) StopJob

func (b *InMemoryBackend) StopJob(appID, branchName, jobID string) (*Job, error)

StopJob cancels a running job.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(resourceARN string, tagMap map[string]string) error

TagResource adds or updates tags on an Amplify resource identified by ARN.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(resourceARN string, tagKeys []string) error

UntagResource removes tags from an Amplify resource identified by ARN.

func (*InMemoryBackend) UpdateApp

func (b *InMemoryBackend) UpdateApp(
	appID, name, description, repository, platform string,
	opts ...AppOptions,
) (*App, error)

UpdateApp updates an existing Amplify application. opts is optional (see AppOptions); a nil/omitted opts leaves every field it covers unchanged. name/description/repository/platform use the "" means unchanged" convention already established by the rest of this backend.

func (*InMemoryBackend) UpdateBranch

func (b *InMemoryBackend) UpdateBranch(
	appID, branchName, description, stage string,
	enableAutoBuild bool,
	opts ...BranchOptions,
) (*Branch, error)

UpdateBranch updates an existing Amplify branch. opts is optional (see BranchOptions); a nil/omitted opts leaves every field it covers unchanged.

func (*InMemoryBackend) UpdateDomainAssociation

func (b *InMemoryBackend) UpdateDomainAssociation(
	appID, domainName string,
	subDomains []SubDomainSetting,
	enableAutoSubDomain bool,
) (*DomainAssociation, error)

UpdateDomainAssociation updates a domain association.

func (*InMemoryBackend) UpdateWebhook

func (b *InMemoryBackend) UpdateWebhook(
	webhookID, branchName, description string,
) (*Webhook, error)

UpdateWebhook updates a webhook.

type Janitor

type Janitor struct {
	Backend  *InMemoryBackend
	Interval time.Duration
	// TaskTimeout bounds each individual janitor task. When non-zero, each task
	// runs with a child context that expires after this duration, preventing a
	// stalled operation from blocking the janitor loop indefinitely.
	TaskTimeout time.Duration
}

Janitor is the Amplify background worker that advances jobs and domain associations out of their transient starting states.

StartJob/StartDeployment only ever set a job's Status to RUNNING, and CreateDomainAssociation only ever sets a domain's DomainStatus to PENDING_VERIFICATION -- real Amplify eventually finishes the build / verifies the certificate on its own, but nothing else in this backend ever mutates those fields again (StopJob/DeleteDomainAssociation require an explicit caller action). Without this janitor a job or domain association would sit in its transient state forever, and any client polling GetJob/ListJobs or GetDomainAssociation/ListDomainAssociations to wait for completion would spin indefinitely.

func NewJanitor

func NewJanitor(backend *InMemoryBackend, interval time.Duration) *Janitor

NewJanitor creates a new Amplify Janitor for the given backend. A zero interval falls back to defaultAmplifyJanitorInterval.

func (*Janitor) Run

func (j *Janitor) Run(ctx context.Context)

Run runs the janitor loop until ctx is cancelled.

func (*Janitor) SweepOnce

func (j *Janitor) SweepOnce(ctx context.Context)

SweepOnce runs a single janitor pass. Exposed for testing.

type Job

type Job struct {
	JobID      string    `json:"jobId"`
	JobARN     string    `json:"jobArn"`
	CommitID   string    `json:"commitId,omitzero"`
	CommitMsg  string    `json:"commitMessage,omitzero"`
	Status     JobStatus `json:"status"`
	Type       JobType   `json:"jobType"`
	StartTime  time.Time `json:"startTime"`
	EndTime    time.Time `json:"endTime,omitzero"`
	CommitTime time.Time `json:"commitTime,omitzero"`
	AppID      string    `json:"appId"`
	BranchName string    `json:"branchName"`
}

Job represents an Amplify deployment job.

type JobStatus

type JobStatus string

JobStatus represents the status of a deployment job.

const (
	// JobStatusPending is the pending status.
	JobStatusPending JobStatus = "PENDING"
	// JobStatusProvisioning is the provisioning status.
	JobStatusProvisioning JobStatus = "PROVISIONING"
	// JobStatusRunning is the running status.
	JobStatusRunning JobStatus = "RUNNING"
	// JobStatusFailed is the failed status.
	JobStatusFailed JobStatus = "FAILED"
	// JobStatusSucceed is the succeed status.
	JobStatusSucceed JobStatus = "SUCCEED"
	// JobStatusCancelling is the cancelling status.
	JobStatusCancelling JobStatus = "CANCELLING"
	// JobStatusCancelled is the cancelled status.
	JobStatusCancelled JobStatus = "CANCELLED"
)

type JobType

type JobType string

JobType represents the type of deployment job.

const (
	// JobTypeRelease is a manual release job.
	JobTypeRelease JobType = "RELEASE"
	// JobTypeRetry is a retry job.
	JobTypeRetry JobType = "RETRY"
	// JobTypeManual is a direct-upload deployment.
	JobTypeManual JobType = "MANUAL"
	// JobTypeWebHook is a webhook-triggered job.
	JobTypeWebHook JobType = "WEB_HOOK"
)

type Platform

type Platform string

Platform represents the Amplify app platform type.

const (
	// PlatformWEB is a static web app.
	PlatformWEB Platform = "WEB"
	// PlatformWEBCOMPUTE is a web app with server-side rendering (SSR).
	PlatformWEBCOMPUTE Platform = "WEB_COMPUTE"
	// PlatformWEBDYNAMIC is a dynamic web app.
	PlatformWEBDYNAMIC Platform = "WEB_DYNAMIC"
)

type ProductionBranch added in v1.2.0

type ProductionBranch struct {
	BranchName     string    `json:"branchName,omitempty"`
	LastDeployTime time.Time `json:"lastDeployTime,omitzero"`
	Status         string    `json:"status,omitempty"`
	ThumbnailURL   string    `json:"thumbnailUrl,omitempty"`
}

ProductionBranch mirrors aws-sdk-go-v2/service/amplify/types.ProductionBranch. It is never stored on an App record -- it is computed at read time (see InMemoryBackend.productionBranchFor) from the app's PRODUCTION-stage branch and that branch's most recent job, so it can never go stale.

type Provider

type Provider struct{}

Provider implements service.Provider for the Amplify service.

func (*Provider) Init

Init initializes the Amplify service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the logical name of the provider.

type Stage

type Stage string

Stage represents the branch deployment stage.

Real Amplify's Stage enum (aws-sdk-go-v2/service/amplify/types.Stage) is PRODUCTION, BETA, DEVELOPMENT, EXPERIMENTAL, PULL_REQUEST. gopherstack previously defined a STAGING value that does not exist in the real API; it has been renamed to BETA, and PULL_REQUEST was added.

const (
	// StageProduction is the production stage.
	StageProduction Stage = "PRODUCTION"
	// StageBeta is the beta stage.
	StageBeta Stage = "BETA"
	// StageDevelopment is the development stage.
	StageDevelopment Stage = "DEVELOPMENT"
	// StageExperimental is the experimental stage.
	StageExperimental Stage = "EXPERIMENTAL"
	// StagePullRequest is the pull-request-preview stage.
	StagePullRequest Stage = "PULL_REQUEST"
)

type StorageBackend

type StorageBackend interface {
	// Snapshot and Restore implement persistence.Persistable. Handler
	// delegates to them (see persistence.go) so cli.go's generic
	// setupPersistence picks Amplify up.
	Snapshot(ctx context.Context) []byte
	Restore(ctx context.Context, data []byte) error

	CreateApp(
		name, description, repository, platform string,
		tagMap map[string]string,
		opts ...AppOptions,
	) (*App, error)
	GetApp(appID string) (*App, error)
	ListApps(nextToken string, maxResults int) ([]*App, string, error)
	DeleteApp(appID string) error
	UpdateApp(
		appID, name, description, repository, platform string,
		opts ...AppOptions,
	) (*App, error)
	CreateBranch(
		appID, branchName, description, stage string,
		enableAutoBuild bool,
		tagMap map[string]string,
		opts ...BranchOptions,
	) (*Branch, error)
	GetBranch(appID, branchName string) (*Branch, error)
	ListBranches(appID, nextToken string, maxResults int) ([]*Branch, string, error)
	DeleteBranch(appID, branchName string) error
	UpdateBranch(
		appID, branchName, description, stage string,
		enableAutoBuild bool,
		opts ...BranchOptions,
	) (*Branch, error)
	TagResource(resourceARN string, tagMap map[string]string) error
	UntagResource(resourceARN string, tagKeys []string) error
	ListTagsForResource(resourceARN string) (map[string]string, error)
	// Jobs
	StartJob(
		appID, branchName, jobType, jobID, commitID, commitMsg string,
		commitTime time.Time,
	) (*Job, error)
	StopJob(appID, branchName, jobID string) (*Job, error)
	GetJob(appID, branchName, jobID string) (*Job, error)
	ListJobs(appID, branchName, nextToken string, maxResults int) ([]*Job, string, error)
	DeleteJob(appID, branchName, jobID string) (*Job, error)
	CreateDeployment(appID, branchName string) (string, string, error)
	StartDeployment(appID, branchName, jobID, sourceURL string) (*Job, error)
	// Domains
	CreateDomainAssociation(
		appID, domainName string, subDomains []SubDomainSetting, enableAutoSubDomain bool,
	) (*DomainAssociation, error)
	UpdateDomainAssociation(
		appID, domainName string, subDomains []SubDomainSetting, enableAutoSubDomain bool,
	) (*DomainAssociation, error)
	DeleteDomainAssociation(appID, domainName string) (*DomainAssociation, error)
	GetDomainAssociation(appID, domainName string) (*DomainAssociation, error)
	ListDomainAssociations(
		appID, nextToken string,
		maxResults int,
	) ([]*DomainAssociation, string, error)
	// Webhooks
	CreateWebhook(appID, branchName, description string) (*Webhook, error)
	UpdateWebhook(webhookID, branchName, description string) (*Webhook, error)
	DeleteWebhook(webhookID string) (*Webhook, error)
	GetWebhook(webhookID string) (*Webhook, error)
	ListWebhooks(appID, nextToken string, maxResults int) ([]*Webhook, string, error)
	// Backend environments
	CreateBackendEnvironment(
		appID, environmentName, stackName, deploymentArtifacts string,
	) (*BackendEnvironment, error)
	GetBackendEnvironment(appID, environmentName string) (*BackendEnvironment, error)
	DeleteBackendEnvironment(appID, environmentName string) (*BackendEnvironment, error)
	ListBackendEnvironments(
		appID, nextToken string,
		maxResults int,
	) ([]*BackendEnvironment, string, error)
	// Logs and artifacts
	GenerateAccessLogs(appID, domainName, startTime, endTime string) (string, error)
	GetArtifactURL(artifactID string) (string, string, error)
	ListArtifacts(
		appID, branchName, jobID, nextToken string,
		maxResults int,
	) ([]*Artifact, string, error)
}

StorageBackend defines the interface for Amplify storage operations.

type SubDomain

type SubDomain struct {
	SubDomainSetting SubDomainSetting `json:"subDomainSetting"`
	DNSRecord        string           `json:"dnsRecord,omitzero"`
	Verified         bool             `json:"verified"`
}

SubDomain represents a configured subdomain.

type SubDomainSetting

type SubDomainSetting struct {
	Prefix     string `json:"prefix"`
	BranchName string `json:"branchName"`
}

SubDomainSetting represents a subdomain setting.

type Webhook

type Webhook struct {
	CreateTime  time.Time `json:"createTime"`
	UpdateTime  time.Time `json:"updateTime"`
	WebhookID   string    `json:"webhookId"`
	WebhookARN  string    `json:"webhookArn"`
	AppID       string    `json:"appId"`
	BranchName  string    `json:"branchName"`
	Description string    `json:"description,omitzero"`
	WebhookURL  string    `json:"webhookUrl"`
}

Webhook represents an Amplify webhook.

Jump to

Keyboard shortcuts

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