emrserverless

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 23 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

EMR Serverless

Parity grade: A · SDK aws-sdk-go-v2/service/emrserverless@v1.44.4 · last audited 2026-08-13 (b0d0cfe0)

Coverage

Metric Value
Operations audited 22 (22 ok)
Feature families 5 (5 ok)
Known gaps 1
Deferred items 0
Resource leaks clean
Known gaps
  • Fixed: JobRunState was missing the real SDK's QUEUED constant (types/enums.go:76-84 in aws-sdk-go-v2/service/emrserverless@v1.44.4, also emr-serverless/2021-07-13/service-2.json shapes.JobRunState, both list SUBMITTED/PENDING/SCHEDULED/RUNNING/SUCCESS/FAILED/CANCELLING/CANCELLED/QUEUED). Added JobRunStateQueued for enum completeness. The lifecycle itself is unaffected: StartJobRun still only ever produces SUBMITTED (or CANCELLED via explicit cancel) -- this backend does not model application capacity/scheduler configuration, which is the only real trigger for QUEUED (see JobRun.queuedDurationMilliseconds / SchedulerConfiguration.queueTimeoutMinutes in service-2.json), so nothing ever enters PENDING/SCHEDULED/RUNNING/SUCCESS/FAILED/CANCELLING/QUEUED either -- not just QUEUED. This is a self-consistent simplification (every client-polled field agrees the run stays SUBMITTED), not an instant-success bug; simulating job execution to make QUEUED observable is out of scope without job-lifecycle simulation (tracked separately if ever undertaken).

More

Documentation

Index

Constants

View Source
const (
	// SessionStateSubmitted identifies a newly submitted session.
	SessionStateSubmitted = "SUBMITTED"
	// SessionStateStarting identifies a session being provisioned.
	SessionStateStarting = "STARTING"
	// SessionStateStarted identifies an active session.
	SessionStateStarted = "STARTED"
	// SessionStateIdle identifies an idle active session.
	SessionStateIdle = "IDLE"
	// SessionStateBusy identifies a busy active session.
	SessionStateBusy = "BUSY"
	// SessionStateFailed identifies a failed session.
	SessionStateFailed = "FAILED"
	// SessionStateTerminated identifies a terminated session.
	SessionStateTerminated = "TERMINATED"
)
View Source
const ApplicationStateCreated = "CREATED"

ApplicationStateCreated is the state when an application has been created.

View Source
const ApplicationStateCreating = "CREATING"

ApplicationStateCreating is the state when an application is being created.

View Source
const ApplicationStateStarted = "STARTED"

ApplicationStateStarted is the state when an application is running.

View Source
const ApplicationStateStarting = "STARTING"

ApplicationStateStarting is the state when an application is starting.

View Source
const ApplicationStateStopped = "STOPPED"

ApplicationStateStopped is the state when an application has stopped.

View Source
const ApplicationStateStopping = "STOPPING"

ApplicationStateStopping is the state when an application is stopping.

View Source
const ApplicationStateTerminated = "TERMINATED"

ApplicationStateTerminated is the state when an application is terminated.

View Source
const DefaultJobRunExecutionTimeoutMinutes = 720

DefaultJobRunExecutionTimeoutMinutes is the timeout the real EMR Serverless API reports for a job run when StartJobRun did not specify executionTimeoutMinutes (types.JobRun.ExecutionTimeoutMinutes doc: "If no timeout was specified, then it returns the default timeout of 720 minutes.").

View Source
const JobRunStateCancelled = "CANCELLED"

JobRunStateCancelled is the state when a job run has been cancelled.

View Source
const JobRunStateCancelling = "CANCELLING"

JobRunStateCancelling is the state when a job run is being cancelled.

View Source
const JobRunStateFailed = "FAILED"

JobRunStateFailed is the state when a job run has failed.

View Source
const JobRunStatePending = "PENDING"

JobRunStatePending is the state when a job run is pending.

View Source
const JobRunStateQueued = "QUEUED"

JobRunStateQueued is the state when a job run is queued awaiting capacity (types.JobRunState in aws-sdk-go-v2/service/emrserverless@v1.44.4, types/enums.go:84). This backend's job runs never contend for capacity, so nothing ever enters this state; the constant exists so a job run this backend did not create (e.g. seeded directly) can still round-trip it.

View Source
const JobRunStateRunning = "RUNNING"

JobRunStateRunning is the state when a job run is running.

View Source
const JobRunStateScheduled = "SCHEDULED"

JobRunStateScheduled is the state when a job run is scheduled.

View Source
const JobRunStateSubmitted = "SUBMITTED"

JobRunStateSubmitted is the state when a job run has been submitted.

View Source
const JobRunStateSuccess = "SUCCESS"

JobRunStateSuccess is the state when a job run completed successfully.

Variables

View Source
var (
	// ErrNotFound is returned when a requested resource does not exist.
	ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound)
	// ErrAlreadyExists is returned when a resource already exists.
	ErrAlreadyExists = awserr.New("ConflictException", awserr.ErrAlreadyExists)
	// ErrValidation is returned when input validation fails.
	ErrValidation = awserr.New("ValidationException", awserr.ErrInvalidParameter)
	// ErrInvalidState is returned when an operation is not valid for the resource's current state.
	ErrInvalidState = awserr.New("RequestFailedException", awserr.ErrInvalidParameter)
)
View Source
var ErrNilAppContext = errors.New("emrserverless provider: nil AppContext")

ErrNilAppContext is returned when Init is called with a nil application context.

Functions

This section is empty.

Types

type Application

type Application struct {
	Tags map[string]string `json:"tags,omitempty"`
	// ExtraConfig holds application configuration sub-objects that this
	// in-memory backend does not interpret (initialCapacity, maximumCapacity,
	// autoStartConfiguration, autoStopConfiguration, networkConfiguration,
	// imageConfiguration, monitoringConfiguration, workerTypeSpecifications,
	// runtimeConfiguration, interactiveConfiguration) but must still store and
	// echo back verbatim on GetApplication/ListApplications -- AWS clients
	// (Terraform, drift-detection tooling) commonly round-trip these values,
	// and CreateApplication/UpdateApplication silently discarding them is a
	// disguised no-op. Keyed by AWS wire field name; see applicationToMap.
	ExtraConfig   map[string]any `json:"extraConfig,omitempty"`
	CreatedAt     time.Time      `json:"createdAt"`
	UpdatedAt     time.Time      `json:"updatedAt"`
	ApplicationID string         `json:"applicationId"`
	Arn           string         `json:"arn"`
	Name          string         `json:"name"`
	Type          string         `json:"type"`
	ReleaseLabel  string         `json:"releaseLabel"`
	Architecture  string         `json:"architecture,omitempty"`
	State         string         `json:"state"`
	// StateDetails holds additional details about the application's current
	// state. Optional on the real API (types.Application.StateDetails is not
	// a required response member); this backend leaves it empty except where
	// a state transition sets a specific message.
	StateDetails string `json:"stateDetails,omitempty"`
}

Application represents an EMR Serverless application.

type CreateApplicationOptions

type CreateApplicationOptions struct {
	ExtraConfig map[string]any
	ClientToken string
}

CreateApplicationOptions carries optional CreateApplication parameters beyond the always-present name/type/releaseLabel/architecture/tags: the client idempotency token (matching AWS's CreateApplicationInput.ClientToken, a required input field on the real API) and the configuration sub-objects this backend stores but does not interpret. Passed as a trailing variadic argument so existing call sites that don't need these are unaffected.

type Handler

type Handler struct {
	Backend *InMemoryBackend
}

Handler is the Echo HTTP handler for EMR Serverless operations (REST-JSON protocol).

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a new EMR Serverless 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 handler 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 returns the operation name from the request.

func (*Handler) ExtractResource

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

ExtractResource extracts a resource identifier from the request path.

func (*Handler) GetSupportedOperations

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

GetSupportedOperations returns the list of supported operations.

func (*Handler) Handler

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

Handler returns the Echo handler function for EMR Serverless requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority. Uses 87 to be evaluated before AppConfig (priority 86) which also uses /applications paths.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all backend state. Used for test isolation.

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 EMR Serverless requests. For /applications paths, it additionally checks the Authorization header service name to distinguish from AppConfig (which also uses /applications).

func (*Handler) Snapshot

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

Snapshot implements persistence.Persistable by delegating to the backend.

type InMemoryBackend

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

InMemoryBackend stores EMR Serverless state in memory.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new InMemoryBackend.

func (*InMemoryBackend) AddApplicationInternal

func (b *InMemoryBackend) AddApplicationInternal(app *Application)

AddApplicationInternal directly inserts an Application into the backend without going through the HTTP layer. Intended for test seeding only.

func (*InMemoryBackend) AddJobRunInternal

func (b *InMemoryBackend) AddJobRunInternal(jr *JobRun)

AddJobRunInternal directly inserts a JobRun into the backend without going through the HTTP layer. The application must already exist. Intended for test seeding only.

func (*InMemoryBackend) CancelJobRun

func (b *InMemoryBackend) CancelJobRun(applicationID, jobRunID string) (*JobRun, error)

CancelJobRun cancels a job run.

func (*InMemoryBackend) CreateApplication

func (b *InMemoryBackend) CreateApplication(
	name, appType, releaseLabel, architecture string,
	tags map[string]string,
	opts ...CreateApplicationOptions,
) (*Application, error)

CreateApplication creates a new EMR Serverless application. If opts carries a non-empty ClientToken that was already used successfully, the previously created application is returned instead of erroring or creating a duplicate -- matching AWS's client-idempotency-token contract, which real SDKs rely on when retrying a CreateApplication call after a timeout.

func (*InMemoryBackend) DeleteApplication

func (b *InMemoryBackend) DeleteApplication(id string) error

DeleteApplication removes an application. It rejects the request if the application is in STARTED or STARTING state.

func (*InMemoryBackend) GetApplication

func (b *InMemoryBackend) GetApplication(id string) (*Application, error)

GetApplication retrieves an application by ID.

func (*InMemoryBackend) GetDashboardForJobRun

func (b *InMemoryBackend) GetDashboardForJobRun(applicationID, jobRunID string) (string, error)

GetDashboardForJobRun returns a dashboard URL for a job run.

func (*InMemoryBackend) GetJobRun

func (b *InMemoryBackend) GetJobRun(applicationID, jobRunID string) (*JobRun, error)

GetJobRun retrieves a job run by application ID and job run ID.

func (*InMemoryBackend) GetResourceDashboard

func (b *InMemoryBackend) GetResourceDashboard(applicationID, resourceID, resourceType string) (string, error)

GetResourceDashboard returns a dashboard URL for a supported session resource.

func (*InMemoryBackend) GetSession

func (b *InMemoryBackend) GetSession(applicationID, sessionID string) (*Session, error)

GetSession retrieves an interactive session.

func (*InMemoryBackend) GetSessionEndpoint

func (b *InMemoryBackend) GetSessionEndpoint(applicationID, sessionID string) (string, string, time.Time, error)

GetSessionEndpoint produces an active session endpoint and expiring token.

func (*InMemoryBackend) ListApplications

func (b *InMemoryBackend) ListApplications(
	nextToken string, maxResults int, states ...string,
) ([]*Application, string)

ListApplications returns paginated applications, optionally filtered by state.

func (*InMemoryBackend) ListJobRunAttempts

func (b *InMemoryBackend) ListJobRunAttempts(
	applicationID, jobRunID, nextToken string,
	maxResults int,
) ([]*JobRunAttemptSummary, string, error)

ListJobRunAttempts returns paginated attempt summaries for a job run.

func (*InMemoryBackend) ListJobRuns

func (b *InMemoryBackend) ListJobRuns(
	applicationID, nextToken string, maxResults int, states ...string,
) ([]*JobRun, string, error)

ListJobRuns returns paginated job runs for an application, optionally filtered by state.

func (*InMemoryBackend) ListSessions

func (b *InMemoryBackend) ListSessions(
	applicationID, nextToken string, maxResults int, createdAfter, createdBefore time.Time, states ...string,
) ([]*Session, string, error)

ListSessions returns sessions ordered newest first with optional state and time filtering.

func (*InMemoryBackend) ListTagsForResource

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

ListTagsForResource returns tags for a resource identified by ARN.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the AWS region this backend is configured for.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all backend state, returning it to the initial empty state.

func (*InMemoryBackend) Restore

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

Restore loads backend state from a JSON snapshot produced by Snapshot.

func (*InMemoryBackend) Snapshot

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

Snapshot serialises the backend state to JSON.

func (*InMemoryBackend) StartApplication

func (b *InMemoryBackend) StartApplication(id string) error

StartApplication transitions an application to STARTED state.

func (*InMemoryBackend) StartJobRun

func (b *InMemoryBackend) StartJobRun(
	applicationID, executionRoleArn, name, mode string,
	tags map[string]string,
	opts ...StartJobRunOptions,
) (*JobRun, error)

StartJobRun creates and starts a new job run. If opts carries a non-empty ClientToken that was already used successfully for this application, the previously created job run is returned instead of creating a duplicate -- matching AWS's client-idempotency-token contract. JobDriver and ConfigurationOverrides are stored and echoed back verbatim by GetJobRun/ListJobRuns rather than discarded: JobDriver is a required field on the real JobRun response shape, so dropping it there would silently erase the job specification the caller submitted.

func (*InMemoryBackend) StartSession

func (b *InMemoryBackend) StartSession(
	applicationID, clientToken, executionRoleArn, name string,
	idleTimeoutMinutes int64, configurationOverrides map[string]any, tags map[string]string,
) (*Session, error)

StartSession creates an interactive session on a running application.

func (*InMemoryBackend) StopApplication

func (b *InMemoryBackend) StopApplication(id string) error

StopApplication transitions an application to STOPPED state.

func (*InMemoryBackend) TagResource

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

TagResource adds or updates tags on a resource identified by ARN.

func (*InMemoryBackend) TaggedResources added in v1.3.1

func (b *InMemoryBackend) TaggedResources() []TaggedEntry

TaggedResources returns every application and job run that carries at least one tag, keyed by ARN. Sessions are excluded: real EMR Serverless only supports applications and job runs as TagResource/ListTagsForResource targets (botocore 1.43.56, emr-serverless/2021-07-13/service-2.json.gz, TagResourceRequest.resourceArn: "the supported resources are Amazon EMR Serverless applications and job runs"), unlike findTagsByARN above which is more permissive for the backend's own direct tag calls.

func (*InMemoryBackend) TerminateSession

func (b *InMemoryBackend) TerminateSession(applicationID, sessionID string) (*Session, error)

TerminateSession moves a session to terminal state.

func (*InMemoryBackend) UntagResource

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

UntagResource removes tags from a resource identified by ARN.

func (*InMemoryBackend) UpdateApplication

func (b *InMemoryBackend) UpdateApplication(id string, update func(*Application)) (*Application, error)

UpdateApplication applies a mutating function to an application.

type JobRun

type JobRun struct {
	Tags map[string]string `json:"tags,omitempty"`
	// JobDriver is the job driver (sparkSubmit/hive) supplied to StartJobRun.
	// GetJobRun/ListJobRuns mark this as a required response field in the
	// real API; storing and echoing it verbatim (rather than discarding it)
	// avoids silently dropping the job specification the caller submitted.
	JobDriver any `json:"jobDriver,omitempty"`
	// ConfigurationOverrides is the configurationOverrides supplied to
	// StartJobRun, echoed back verbatim.
	ConfigurationOverrides any `json:"configurationOverrides,omitempty"`
	// ExecutionIamPolicy is the optional IAM policy supplied to StartJobRun
	// (StartJobRunInput.ExecutionIamPolicy), echoed back verbatim.
	ExecutionIamPolicy any `json:"executionIamPolicy,omitempty"`
	// RetryPolicy is the retry policy supplied to StartJobRun
	// (StartJobRunInput.RetryPolicy), echoed back verbatim.
	RetryPolicy      any       `json:"retryPolicy,omitempty"`
	CreatedAt        time.Time `json:"createdAt"`
	UpdatedAt        time.Time `json:"updatedAt"`
	ApplicationID    string    `json:"applicationId"`
	JobRunID         string    `json:"jobRunId"`
	Arn              string    `json:"arn"`
	Name             string    `json:"name"`
	State            string    `json:"state"`
	ExecutionRoleArn string    `json:"executionRoleArn"`
	Mode             string    `json:"mode,omitempty"`
	ReleaseLabel     string    `json:"releaseLabel,omitempty"`
	StateDetails     string    `json:"stateDetails,omitempty"`
	// CreatedBy is the IAM principal that created the job run -- a required
	// field on the real JobRun/JobRunSummary response shape
	// (types.JobRun.CreatedBy). This in-memory backend does not model IAM
	// principals, so it uses the execution role ARN as a best-effort
	// substitute, matching the convention already used by
	// ListJobRunAttempts' synthesized attempt.
	CreatedBy string `json:"createdBy"`
	// ExecutionTimeoutMinutes is the job run timeout in minutes. The real API
	// returns the default timeout (720 minutes) when none was supplied to
	// StartJobRun; see StartJobRunOptions.ExecutionTimeoutMinutes.
	ExecutionTimeoutMinutes int64 `json:"executionTimeoutMinutes"`
}

JobRun represents an EMR Serverless job run.

type JobRunAttemptSummary

type JobRunAttemptSummary struct {
	CreatedAt     time.Time `json:"createdAt"`
	UpdatedAt     time.Time `json:"updatedAt"`
	JobCreatedAt  time.Time `json:"jobCreatedAt"`
	ApplicationID string    `json:"applicationId"`
	Arn           string    `json:"arn"`
	CreatedBy     string    `json:"createdBy"`
	ExecutionRole string    `json:"executionRole"`
	ID            string    `json:"id"`
	ReleaseLabel  string    `json:"releaseLabel"`
	State         string    `json:"state"`
	StateDetails  string    `json:"stateDetails"`
	Name          string    `json:"name"`
	Type          string    `json:"type"`
	Attempt       int32     `json:"attempt"`
}

JobRunAttemptSummary represents a single attempt of a job run.

type Provider

type Provider struct{}

Provider implements service.Provider for EMR Serverless.

func (*Provider) Init

Init initializes the EMR Serverless backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type Session

type Session struct {
	Tags                   map[string]string `json:"tags,omitempty"`
	ConfigurationOverrides map[string]any    `json:"configurationOverrides,omitempty"`
	CreatedAt              time.Time         `json:"createdAt"`
	UpdatedAt              time.Time         `json:"updatedAt"`
	StartedAt              time.Time         `json:"startedAt"`
	EndedAt                time.Time         `json:"endedAt,omitzero"`
	ApplicationID          string            `json:"applicationId"`
	SessionID              string            `json:"sessionId"`
	Arn                    string            `json:"arn"`
	Name                   string            `json:"name,omitempty"`
	State                  string            `json:"state"`
	StateDetails           string            `json:"stateDetails"`
	CreatedBy              string            `json:"createdBy"`
	ExecutionRoleArn       string            `json:"executionRoleArn"`
	ReleaseLabel           string            `json:"releaseLabel"`
	IdleTimeoutMinutes     int64             `json:"idleTimeoutMinutes,omitempty"`
}

Session represents an interactive EMR Serverless session.

type StartJobRunOptions

type StartJobRunOptions struct {
	JobDriver               any
	ConfigurationOverrides  any
	ExecutionIamPolicy      any
	RetryPolicy             any
	ClientToken             string
	ExecutionTimeoutMinutes int64
}

StartJobRunOptions carries optional StartJobRun parameters beyond the always-present applicationID/executionRoleArn/name/mode/tags: the client idempotency token (matching AWS's StartJobRunInput.ClientToken, a required input field on the real API), the job driver, configuration overrides, execution IAM policy, execution timeout, and retry policy. Passed as a trailing variadic argument so existing call sites that don't need these are unaffected.

type TaggedEntry added in v1.3.1

type TaggedEntry struct {
	Tags map[string]string
	ARN  string
}

TaggedEntry pairs a resource ARN with its tag set, for the Resource Groups Tagging API's GetResources (see cli.go's wireTaggingEmrServerless).

Jump to

Keyboard shortcuts

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