resourcegroups

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 23 Imported by: 0

README

Resource Groups

Parity grade: A · SDK aws-sdk-go-v2/service/resourcegroups@v1.33.22 · last audited 2026-07-13 (343e1204)

Coverage

Metric Value
Operations audited 23 (23 ok)
Feature families 1 (1 ok)
Known gaps 4
Deferred items 0
Resource leaks clean
Known gaps
  • ListGroups Filters only supports 'resource-type', 'configuration-type', 'name-prefix'; real AWS GroupFilterName enum is resource-type|configuration-type|owner|display-name|criticality (no name-prefix). Filtering by owner/display-name/criticality silently matches everything instead of filtering; name-prefix is a gopherstack-only extension. (bd: gopherstack-rg-filters)
  • CreateGroup/UpdateGroup do not accept an Owner input field (real API supports it on both); Owner is therefore always empty in this emulator. CreateGroup also does not accept DisplayName/Criticality at creation time (only settable via a follow-up UpdateGroup). (bd: gopherstack-rg-owner-input)
  • SearchResources/ListGroupResources never populate QueryErrors (CLOUDFORMATION_STACK_* failure reporting) since CloudFormation-stack-based queries are not modeled. ListGroupResourcesOutput also omits the deprecated ResourceIdentifiers field (Resources is populated; most SDKs read Resources).
  • ListGroupResourcesItem/GroupConfigurationItem 'Status' (AWS::EC2::HostManagement pending-membership state) is never populated; only host-management-specific clients would notice.

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a resource group is not found.
	ErrNotFound = awserr.New("NotFoundException", awserr.ErrNotFound)
	// ErrAlreadyExists is returned when a resource group already exists.
	ErrAlreadyExists = awserr.New("BadRequestException", awserr.ErrAlreadyExists)
	// ErrValidation is returned when request validation fails.
	ErrValidation = awserr.New("BadRequestException", awserr.ErrInvalidParameter)
	// ErrTagSyncTaskNotFound is returned when a tag-sync task is not found.
	ErrTagSyncTaskNotFound = awserr.New(
		"NotFoundException: tag-sync task not found",
		awserr.ErrNotFound,
	)
)
View Source
var ErrNilAppContext = errors.New("nil AppContext passed to ResourceGroups Provider.Init")

ErrNilAppContext is returned by Init when a nil AppContext is passed.

View Source
var (
	// ErrUnknownOperation is returned when the requested Resource Groups operation is not supported.
	ErrUnknownOperation = errors.New("UnknownOperationException")
)

Functions

This section is empty.

Types

type AccountSettings

type AccountSettings struct {
	GroupLifecycleEventsDesiredStatus string `json:"GroupLifecycleEventsDesiredStatus,omitempty"`
	GroupLifecycleEventsStatus        string `json:"GroupLifecycleEventsStatus,omitempty"`
	GroupLifecycleEventsStatusMessage string `json:"GroupLifecycleEventsStatusMessage,omitempty"`
}

AccountSettings holds account-level settings for Resource Groups.

type Group

type Group struct {
	Tags           *tags.Tags        `json:"-"`
	ResourceQuery  *ResourceQuery    `json:"-"`
	ApplicationTag map[string]string `json:"ApplicationTag,omitempty"`
	Name           string            `json:"Name"`
	ARN            string            `json:"GroupArn"`
	Description    string            `json:"Description,omitempty"`
	// Owner is a free-form name/email/identifier for the person or team that
	// owns the group. The real AWS API field is called "Owner" on the wire
	// (not "OwnerId"); it is optional and, unlike an AWS account ID, is never
	// auto-populated by the service.
	Owner       string `json:"Owner,omitempty"`
	DisplayName string `json:"DisplayName,omitempty"`
	Criticality int    `json:"Criticality,omitempty"`
}

Group represents a Resource Group.

This is the internal backend representation, not an AWS wire shape: the real types.Group has no Tags or ResourceQuery members (those travel as separate top-level response fields -- see createGroupOutput/getGroupBody in handler.go), so handlers must build a dedicated wire struct rather than marshaling *Group directly.

type GroupConfigurationItem

type GroupConfigurationItem struct {
	Type       string                        `json:"Type"`
	Parameters []GroupConfigurationParameter `json:"Parameters,omitempty"`
}

GroupConfigurationItem is a single configuration item for a group.

type GroupConfigurationParameter

type GroupConfigurationParameter struct {
	Name   string   `json:"Name"`
	Values []string `json:"Values"`
}

GroupConfigurationParameter is a key-value parameter for a group configuration item.

type GroupingFailedItem

type GroupingFailedItem struct {
	ResourceArn  string `json:"ResourceArn"`
	ErrorCode    string `json:"ErrorCode"`
	ErrorMessage string `json:"ErrorMessage"`
}

GroupingFailedItem describes a resource that could not be grouped or ungrouped.

type GroupingStatusItem

type GroupingStatusItem struct {
	UpdatedAt    time.Time `json:"UpdatedAt"`
	ResourceArn  string    `json:"ResourceArn,omitempty"`
	Action       string    `json:"Action,omitempty"`
	Status       string    `json:"Status,omitempty"`
	ErrorCode    string    `json:"ErrorCode,omitempty"`
	ErrorMessage string    `json:"ErrorMessage,omitempty"`
}

GroupingStatusItem holds the grouping/ungrouping status for a resource.

type Handler

type Handler struct {
	Backend StorageBackend
	// contains filtered or unexported fields
}

Handler is the Echo HTTP handler for Resource Groups operations.

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new Resource Groups 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 Resource Groups 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 Resource Groups action from the X-Amz-Target header or REST path.

func (*Handler) ExtractResource

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

ExtractResource extracts the group name from the request body, checking Name (CreateGroup), GroupName, and Group (REST API) fields.

func (*Handler) GetSupportedOperations

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

GetSupportedOperations returns the list of supported Resource Groups operations.

func (*Handler) Handler

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

Handler returns the Echo handler function.

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) Reset

func (h *Handler) Reset()

Reset implements service.Resettable by delegating to the backend.

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 Resource Groups requests. It matches both X-Amz-Target (JSON protocol) and REST API paths used by the AWS SDK.

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 is the in-memory store for Resource Groups.

Phase 3.3 of the datalayer refactor replaces the region-nested map[string]map[string]*Group and its companion map[string]map[string]string ARN reverse index with a single flat *store.Table[Group], keyed by the composite "region|name" string (see regionKey below), with companion *store.Index values grouping entries by region (replacing the old outer map nesting used by ListGroups) and by "region|ARN" (replacing the old per-region arnIndex reverse map used by findByARN). tagSyncTasks receives the identical treatment. See store_setup.go.

Group and TagSyncTask carry no exported Region field (not part of either's AWS wire shape); both always embed their owning region in their ARN (see CreateGroup/StartTagSyncTask), so groupRegionOf/taskRegionOf derive it from there instead of adding a new field.

groups is a "dirty" table in the store_setup.go/persistence.go sense: each Group carries a live *tags.Tags field (a Prometheus-instrumented map) that plain json.Marshal cannot round-trip while preserving the per-resource metric name -- so it is NOT registered on the shared b.registry; it is built with store.New only, and persistence.go handles its Snapshot/Restore via a plain-map DTO. tagSyncTasks has no such field and is registered directly.

groupConfigurations, groupResources, and groupingStatuses remain plain region-nested maps: their values (a slice of items, a slice of ARN strings, a slice of status records) have no identity of their own for store.Table to key on, so there is nothing to convert -- each is persisted here directly instead (see persistence.go).

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new InMemoryBackend.

func (*InMemoryBackend) AccountID

func (b *InMemoryBackend) AccountID() string

AccountID returns the AWS account ID this backend is configured for.

func (*InMemoryBackend) AddTagsByARN

func (b *InMemoryBackend) AddTagsByARN(
	ctx context.Context,
	resourceARN string,
	newTags map[string]string,
) (map[string]string, error)

AddTagsByARN merges newTags into the resource group identified by ARN and returns the resulting tag set. Rejects reserved aws: tag key prefixes.

func (*InMemoryBackend) CancelTagSyncTask

func (b *InMemoryBackend) CancelTagSyncTask(ctx context.Context, taskARN string) error

CancelTagSyncTask deletes a tag-sync task. AWS documents CancelTagSyncTask as taking "the TaskArn of the tag-sync task you want to delete", and TagSyncTaskStatus's only valid wire values are ACTIVE and ERROR -- there is no CANCELLED status. So, unlike an in-place status transition, a cancelled task is removed outright: subsequent GetTagSyncTask/ListTagSyncTasks calls no longer find it.

func (*InMemoryBackend) CreateGroup

func (b *InMemoryBackend) CreateGroup(
	ctx context.Context,
	name, description string,
	resourceQuery *ResourceQuery,
	inputTags *tags.Tags,
	configuration []GroupConfigurationItem,
) (*Group, error)

CreateGroup creates a new resource group. The Tags field in the returned Group points to a fresh Tags copy; it is safe to read but callers should not pass it back to mutation methods. configuration is optional; when non-nil it is stored atomically with the group.

func (*InMemoryBackend) DeleteGroup

func (b *InMemoryBackend) DeleteGroup(ctx context.Context, nameOrARN string) (*Group, error)

DeleteGroup deletes a resource group by name or ARN, returning a copy of the group as it existed immediately before deletion (matching AWS, whose DeleteGroupOutput echoes back the deleted group's description). It cascades to remove all associated resources, configurations, grouping-status records, and tag-sync tasks for the group.

func (*InMemoryBackend) GetAccountSettings

func (b *InMemoryBackend) GetAccountSettings() AccountSettings

GetAccountSettings returns the account-level settings.

func (*InMemoryBackend) GetGroup

func (b *InMemoryBackend) GetGroup(ctx context.Context, nameOrARN string) (*Group, error)

GetGroup returns a resource group by name or ARN.

func (*InMemoryBackend) GetGroupConfigurationItems

func (b *InMemoryBackend) GetGroupConfigurationItems(
	ctx context.Context,
	nameOrARN string,
) ([]GroupConfigurationItem, error)

GetGroupConfigurationItems returns a deep copy of the stored configuration for a group.

func (*InMemoryBackend) GetTagSyncTask

func (b *InMemoryBackend) GetTagSyncTask(ctx context.Context, taskARN string) (*TagSyncTask, error)

GetTagSyncTask returns a copy of a tag-sync task by ARN.

func (*InMemoryBackend) GetTagsByARN

func (b *InMemoryBackend) GetTagsByARN(ctx context.Context, resourceARN string) (map[string]string, error)

GetTagsByARN returns the tags for the resource group identified by ARN.

func (*InMemoryBackend) GroupResources

func (b *InMemoryBackend) GroupResources(
	ctx context.Context,
	nameOrARN string,
	resourceARNs []string,
) ([]string, error)

GroupResources associates a list of resource ARNs with a group. Duplicate ARNs are silently ignored; each ARN is only added once.

func (*InMemoryBackend) ListGroupResources

func (b *InMemoryBackend) ListGroupResources(
	ctx context.Context,
	nameOrARN string,
	filters []ListGroupResourcesFilter,
	nextToken string,
	maxResults int,
) ([]ResourceIdentifier, string, error)

ListGroupResources returns resource identifiers associated with a group, optionally filtered and paginated. Supported filter Name: "resource-type" (filter by AWS resource type). Returns identifiers, a continuation token (empty when no more results), and any error.

func (*InMemoryBackend) ListGroupingStatuses

func (b *InMemoryBackend) ListGroupingStatuses(
	ctx context.Context,
	nameOrARN string,
	nextToken string,
	maxResults int,
) ([]GroupingStatusItem, string, error)

ListGroupingStatuses returns the grouping/ungrouping status history for a group, paginated. Returns statuses, a continuation token (empty when no more results), and any error.

func (*InMemoryBackend) ListGroups

func (b *InMemoryBackend) ListGroups(
	ctx context.Context,
	filters []ListGroupsFilter,
	nextToken string,
	maxResults int,
) ([]Group, string)

ListGroups returns resource groups sorted by name, optionally filtered and paginated. Supported filter names: "configuration-type", "resource-type", "name-prefix". An empty filters slice returns all groups (up to maxResults). Returns the page of groups and a continuation token (empty when no more results).

func (*InMemoryBackend) ListTagSyncTasks

func (b *InMemoryBackend) ListTagSyncTasks(
	ctx context.Context,
	filters []ListTagSyncTasksFilter,
	nextToken string,
	maxResults int,
) ([]TagSyncTask, string, error)

ListTagSyncTasks returns all tag-sync tasks, optionally filtered by group ARN or name, paginated. Inactive tasks older than tagSyncTaskTTL are evicted before results are assembled. Results are sorted by TaskArn for deterministic ordering. Returns tasks, a continuation token (empty when no more results), and any error.

func (*InMemoryBackend) PutGroupConfiguration

func (b *InMemoryBackend) PutGroupConfiguration(
	ctx context.Context,
	nameOrARN string,
	items []GroupConfigurationItem,
) error

PutGroupConfiguration stores a deep copy of items for the named group. It validates each item's Type and Parameters against the known allow-list.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the AWS region this backend is configured for.

func (*InMemoryBackend) RemoveTagsByARN

func (b *InMemoryBackend) RemoveTagsByARN(ctx context.Context, resourceARN string, keys []string) error

RemoveTagsByARN removes the specified tag keys from the resource group identified by ARN.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory state. It closes all group Tags to release Prometheus metrics before discarding the groups table.

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) SearchResources

func (b *InMemoryBackend) SearchResources(
	ctx context.Context,
	q *ResourceQuery,
	nextToken string,
	maxResults int,
) ([]ResourceIdentifier, string, error)

SearchResources returns resource identifiers that have been grouped into any group within the request's region, filtered by the ResourceQuery. For TAG_FILTERS_1_0 queries, ResourceTypeFilters are applied when non-empty. A nil query matches all grouped resources (match-all). Results are de-duplicated and paginated. Returns identifiers, a continuation token (empty when no more results), and any error.

func (*InMemoryBackend) Snapshot

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

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

func (*InMemoryBackend) StartTagSyncTask

func (b *InMemoryBackend) StartTagSyncTask(
	ctx context.Context,
	nameOrARN, roleARN, tagKey, tagValue string,
	resourceQuery *ResourceQuery,
) (*TagSyncTask, error)

StartTagSyncTask creates a new tag-sync task for an application group.

func (*InMemoryBackend) UngroupResources

func (b *InMemoryBackend) UngroupResources(
	ctx context.Context,
	nameOrARN string,
	resourceARNs []string,
) (*UngroupResourcesResult, error)

UngroupResources removes a list of resource ARNs from a group. ARNs that are not currently in the group are returned in Failed[].

func (*InMemoryBackend) UpdateAccountSettings

func (b *InMemoryBackend) UpdateAccountSettings(desiredStatus string) error

UpdateAccountSettings updates the account-level lifecycle event desired status.

func (*InMemoryBackend) UpdateGroup

func (b *InMemoryBackend) UpdateGroup(
	ctx context.Context,
	nameOrARN, description, displayName string,
	criticality int,
) (*Group, error)

UpdateGroup updates the description, display name, and criticality of a resource group. Pass an empty displayName to leave it unchanged. Pass criticality=0 to leave it unchanged. Criticality must be 1-5 if non-zero.

func (*InMemoryBackend) UpdateGroupQuery

func (b *InMemoryBackend) UpdateGroupQuery(
	ctx context.Context,
	nameOrARN string,
	query *ResourceQuery,
) (*Group, error)

UpdateGroupQuery updates the resource query of a resource group identified by name or ARN.

type ListGroupResourcesFilter

type ListGroupResourcesFilter struct {
	Name   string   `json:"Name"`
	Values []string `json:"Values"`
}

ListGroupResourcesFilter holds a single filter criterion for ListGroupResources. Supported Name: "resource-type" (filter by AWS CloudFormation resource type string).

type ListGroupsFilter

type ListGroupsFilter struct {
	Name   string   `json:"Name"`
	Values []string `json:"Values"`
}

ListGroupsFilter holds a single filter for the ListGroups operation.

type ListTagSyncTasksFilter

type ListTagSyncTasksFilter struct {
	GroupArn  string `json:"GroupArn,omitempty"`
	GroupName string `json:"GroupName,omitempty"`
}

ListTagSyncTasksFilter holds filter criteria for listing tag-sync tasks.

type Provider

type Provider struct{}

Provider implements service.Provider for Resource Groups.

func (*Provider) Init

Init initializes the Resource Groups service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type ResourceIdentifier

type ResourceIdentifier struct {
	ResourceArn  string `json:"ResourceArn,omitempty"`
	ResourceType string `json:"ResourceType,omitempty"`
}

ResourceIdentifier holds an ARN and resource type.

type ResourceQuery

type ResourceQuery struct {
	Type  string `json:"Type"`
	Query string `json:"Query"`
}

ResourceQuery represents a tag-based resource query for a group.

type StorageBackend

type StorageBackend interface {
	// Group CRUD operations.
	CreateGroup(
		ctx context.Context,
		name, description string,
		resourceQuery *ResourceQuery,
		inputTags *tags.Tags,
		configuration []GroupConfigurationItem,
	) (*Group, error)
	GetGroup(ctx context.Context, nameOrARN string) (*Group, error)
	UpdateGroup(ctx context.Context, nameOrARN, description, displayName string, criticality int) (*Group, error)
	UpdateGroupQuery(ctx context.Context, nameOrARN string, query *ResourceQuery) (*Group, error)
	DeleteGroup(ctx context.Context, nameOrARN string) (*Group, error)
	// ListGroups returns groups sorted by name with optional filtering and pagination.
	// Returns the page of groups and a continuation token (empty when exhausted).
	ListGroups(ctx context.Context, filters []ListGroupsFilter, nextToken string, maxResults int) ([]Group, string)

	// Tag operations on group resources.
	GetTagsByARN(ctx context.Context, resourceARN string) (map[string]string, error)
	AddTagsByARN(ctx context.Context, resourceARN string, newTags map[string]string) (map[string]string, error)
	RemoveTagsByARN(ctx context.Context, resourceARN string, keys []string) error

	// Account-level settings (not region-scoped).
	GetAccountSettings() AccountSettings
	UpdateAccountSettings(desiredStatus string) error

	// Group configuration.
	PutGroupConfiguration(ctx context.Context, nameOrARN string, items []GroupConfigurationItem) error
	GetGroupConfigurationItems(ctx context.Context, nameOrARN string) ([]GroupConfigurationItem, error)

	// Resource grouping.
	GroupResources(ctx context.Context, nameOrARN string, resourceARNs []string) ([]string, error)
	UngroupResources(ctx context.Context, nameOrARN string, resourceARNs []string) (*UngroupResourcesResult, error)
	// ListGroupResources returns resource identifiers for a group with optional filtering and pagination.
	// Returns identifiers, a continuation token (empty when exhausted), and any error.
	ListGroupResources(
		ctx context.Context,
		nameOrARN string,
		filters []ListGroupResourcesFilter,
		nextToken string,
		maxResults int,
	) ([]ResourceIdentifier, string, error)
	// ListGroupingStatuses returns grouping/ungrouping status history with optional pagination.
	// Returns statuses, a continuation token (empty when exhausted), and any error.
	ListGroupingStatuses(
		ctx context.Context,
		nameOrARN string,
		nextToken string,
		maxResults int,
	) ([]GroupingStatusItem, string, error)
	// SearchResources searches grouped resources filtered by the ResourceQuery.
	// Returns identifiers, a continuation token (empty when exhausted), and any error.
	SearchResources(
		ctx context.Context,
		q *ResourceQuery,
		nextToken string,
		maxResults int,
	) ([]ResourceIdentifier, string, error)

	// Tag-sync tasks.
	StartTagSyncTask(
		ctx context.Context,
		nameOrARN, roleARN, tagKey, tagValue string,
		resourceQuery *ResourceQuery,
	) (*TagSyncTask, error)
	CancelTagSyncTask(ctx context.Context, taskARN string) error
	GetTagSyncTask(ctx context.Context, taskARN string) (*TagSyncTask, error)
	// ListTagSyncTasks returns tasks with optional filtering and pagination.
	// Returns tasks, a continuation token (empty when exhausted), and any error.
	ListTagSyncTasks(
		ctx context.Context,
		filters []ListTagSyncTasksFilter,
		nextToken string,
		maxResults int,
	) ([]TagSyncTask, string, error)

	// Lifecycle.
	Reset()
	Region() string
	AccountID() string
	Snapshot(ctx context.Context) []byte
	Restore(ctx context.Context, data []byte) error
}

StorageBackend defines the interface for Resource Groups backend implementations. All mutating methods must be safe for concurrent use.

type TagSyncTask

type TagSyncTask struct {
	CreatedAt     time.Time      `json:"CreatedAt"`
	ResourceQuery *ResourceQuery `json:"ResourceQuery,omitempty"`
	GroupArn      string         `json:"GroupArn"`
	GroupName     string         `json:"GroupName"`
	RoleArn       string         `json:"RoleArn"`
	TagKey        string         `json:"TagKey,omitempty"`
	TagValue      string         `json:"TagValue,omitempty"`
	TaskArn       string         `json:"TaskArn"`
	Status        string         `json:"Status"`
	ErrorMessage  string         `json:"ErrorMessage,omitempty"`
}

TagSyncTask represents a tag-sync task for an application group.

type UngroupResourcesResult

type UngroupResourcesResult struct {
	Succeeded []string
	Failed    []GroupingFailedItem
}

UngroupResourcesResult holds the result of an UngroupResources call.

Jump to

Keyboard shortcuts

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