resourcegroupstaggingapi

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 21 Imported by: 0

README

Resource Groups Tagging API

Parity grade: A · SDK aws-sdk-go-v2/service/resourcegroupstaggingapi@v1.31.8 · last audited 2026-07-13 (0e933737)

Coverage

Operations audited 9 (8 ok, 1 partial)
Feature families 2 (2 ok)
Known gaps 2
Deferred items 1
Resource leaks clean
Known gaps
  • GetComplianceSummary/ListRequiredTags always report zero noncompliant / zero required tags because no tag-policy engine exists anywhere in gopherstack (bd: gopherstack-i710)
  • Cross-service tag wiring (cli.go wireResourceGroupsTagging) only covers dynamodb/sqs/sns/lambda/kms/secretsmanager; ~90 other services with native TagResource support are not registered, so their tags are invisible to GetResources/GetTagKeys/GetTagValues and their ARNs always fail TagResources/UntagResources. Requires editing cli.go (shared file, out of scope for this service-scoped pass) (bd: gopherstack-3xne)
Deferred
  • Full TagsPerPage/ResourcesPerPage interaction edge cases beyond the cumulative-tag-count cap added this sweep (e.g. exact AWS behavior when a single oversized resource's tag count alone exceeds TagsPerPage across multiple such resources in a row) -- current fix always keeps at least one resource per page, matching the 'never split a resource across pages' rule, but has not been stress-tested against arbitrarily adversarial tag-count distributions

More

Documentation

Overview

Package resourcegroupstaggingapi provides a mock implementation of the AWS Resource Groups Tagging API service. It provides a cross-service tag-based resource lookup layer on top of the existing per-service backends.

Index

Constants

This section is empty.

Variables

View Source
var ErrConcurrentModification = errors.New("ConcurrentModificationException")

ErrConcurrentModification is returned when StartReportCreation is called while a report is still running. AWS requires waiting for the current report to finish.

View Source
var ErrMissingS3Bucket = errors.New("S3Bucket is required")

ErrMissingS3Bucket is returned when StartReportCreation is called without an S3 bucket.

View Source
var ErrNilAppContext = errors.New("nil AppContext passed to ResourceGroupsTaggingAPI Provider.Init")

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

View Source
var ErrUnknownOperation = errors.New("UnknownOperationException")

ErrUnknownOperation is returned when the requested Tagging API operation is not supported.

View Source
var ErrValidation = errors.New(errCodeInvalidParameter)

ErrValidation is returned when a request fails parameter validation; its wire error code is errCodeInvalidParameter.

Functions

This section is empty.

Types

type ARNTagger

type ARNTagger func(ctx context.Context, arn string, tags map[string]string) (bool, error)

ARNTagger applies a set of tags to the resource identified by the given ARN. It returns true when it handled the ARN (even on error) and false when the ARN belongs to a different service and should be tried by the next registered tagger. The context carries the per-request AWS region.

type ARNUntagger

type ARNUntagger func(ctx context.Context, arn string, keys []string) (bool, error)

ARNUntagger removes the specified tag keys from the resource identified by the given ARN. Same handled/not-handled semantics as ARNTagger. The context carries the per-request AWS region.

type ComplianceDetails

type ComplianceDetails struct {
	KeysWithNoncompliantValues []string `json:"KeysWithNoncompliantValues,omitempty"`
	NoncompliantKeys           []string `json:"NoncompliantKeys,omitempty"`
	ComplianceStatus           bool     `json:"ComplianceStatus"`
}

ComplianceDetails records tag-policy compliance information for a resource.

type ComplianceSummary

type ComplianceSummary struct {
	LastUpdated           *string `json:"LastUpdated,omitempty"`
	Region                *string `json:"Region,omitempty"`
	ResourceType          *string `json:"ResourceType,omitempty"`
	TargetID              *string `json:"TargetId,omitempty"`
	TargetIDType          *string `json:"TargetIdType,omitempty"`
	NonCompliantResources int64   `json:"NonCompliantResources"`
}

ComplianceSummary is a count of noncompliant resources.

type DescribeReportCreationInput

type DescribeReportCreationInput struct{}

DescribeReportCreationInput is the request payload for DescribeReportCreation.

type DescribeReportCreationOutput

type DescribeReportCreationOutput struct {
	// ErrorMessage is set when Status is FAILED.
	ErrorMessage *string `json:"ErrorMessage,omitempty"`
	// S3Location is the path to the report in the S3 bucket.
	S3Location *string `json:"S3Location,omitempty"`
	// StartDate is the date and time that the report was started.
	StartDate *string `json:"StartDate,omitempty"`
	// Status is the current status of the report (RUNNING, SUCCEEDED, FAILED). Nil when no report exists.
	Status *string `json:"Status"`
}

DescribeReportCreationOutput is the response payload for DescribeReportCreation.

type FailureInfo

type FailureInfo struct {
	// ErrorCode is the error code.
	ErrorCode string `json:"ErrorCode"`
	// ErrorMessage is the human-readable error message.
	ErrorMessage string `json:"ErrorMessage"`
	// StatusCode is the HTTP status code.
	StatusCode int `json:"StatusCode"`
}

FailureInfo describes why a particular resource could not be tagged.

type FilteredResourceProvider

type FilteredResourceProvider func(ctx context.Context, tagFilters []TagFilter, typeFilters []string) []TaggedResource

FilteredResourceProvider is a resource provider that accepts tag and resource-type filters so that it can perform provider-side filter pushdown. When filters are non-empty the provider is expected to return only resources that satisfy them; when both slices are empty the provider must return all resources. The context carries the per-request AWS region.

type GetComplianceSummaryInput

type GetComplianceSummaryInput struct {
	// GroupBy specifies attributes to group noncompliant resource counts by.
	GroupBy []string `json:"GroupBy,omitempty"`
	// MaxResults is the maximum number of results per page.
	MaxResults *int32 `json:"MaxResults,omitempty"`
	// PaginationToken is the cursor from a previous call.
	PaginationToken *string `json:"PaginationToken,omitempty"`
	// RegionFilters restricts output to specified regions.
	RegionFilters []string `json:"RegionFilters,omitempty"`
	// ResourceTypeFilters restricts output to specified resource types.
	ResourceTypeFilters []string `json:"ResourceTypeFilters,omitempty"`
	// TagKeyFilters restricts output to resources with specified tag keys.
	TagKeyFilters []string `json:"TagKeyFilters,omitempty"`
	// TargetIDFilters restricts output to specified target IDs.
	TargetIDFilters []string `json:"TargetIdFilters,omitempty"`
}

GetComplianceSummaryInput is the request payload for GetComplianceSummary.

type GetComplianceSummaryOutput

type GetComplianceSummaryOutput struct {
	// PaginationToken is the cursor for the next page.
	PaginationToken *string `json:"PaginationToken,omitempty"`
	// SummaryList contains the noncompliant resource counts.
	SummaryList []ComplianceSummary `json:"SummaryList"`
}

GetComplianceSummaryOutput is the response payload for GetComplianceSummary.

type GetResourcesInput

type GetResourcesInput struct {
	ResourcesPerPage          *int32      `json:"ResourcesPerPage,omitempty"`
	TagsPerPage               *int32      `json:"TagsPerPage,omitempty"`
	PaginationToken           string      `json:"PaginationToken,omitempty"`
	TagFilters                []TagFilter `json:"TagFilters,omitempty"`
	ResourceTypeFilters       []string    `json:"ResourceTypeFilters,omitempty"`
	ResourceARNList           []string    `json:"ResourceARNList,omitempty"`
	IncludeComplianceDetails  bool        `json:"IncludeComplianceDetails,omitempty"`
	ExcludeCompliantResources bool        `json:"ExcludeCompliantResources,omitempty"`
}

GetResourcesInput is the request payload for GetResources.

type GetResourcesOutput

type GetResourcesOutput struct {
	PaginationToken        *string              `json:"PaginationToken,omitempty"`
	ResourceTagMappingList []ResourceTagMapping `json:"ResourceTagMappingList"`
}

GetResourcesOutput is the response payload for GetResources.

type GetTagKeysInput

type GetTagKeysInput struct {
	// PaginationToken is the cursor from a previous call.
	PaginationToken *string `json:"PaginationToken,omitempty"`
}

GetTagKeysInput is the request payload for GetTagKeys.

type GetTagKeysOutput

type GetTagKeysOutput struct {
	PaginationToken *string  `json:"PaginationToken,omitempty"`
	TagKeys         []string `json:"TagKeys"`
}

GetTagKeysOutput is the response payload for GetTagKeys.

type GetTagValuesInput

type GetTagValuesInput struct {
	// Key is the tag key whose values to enumerate.
	Key *string `json:"Key,omitempty"`
	// PaginationToken is the cursor from a previous call.
	PaginationToken *string `json:"PaginationToken,omitempty"`
}

GetTagValuesInput is the request payload for GetTagValues.

type GetTagValuesOutput

type GetTagValuesOutput struct {
	PaginationToken *string  `json:"PaginationToken,omitempty"`
	TagValues       []string `json:"TagValues"`
}

GetTagValuesOutput is the response payload for GetTagValues.

type Handler

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

Handler is the Echo HTTP handler for Resource Groups Tagging API operations.

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new Resource Groups Tagging API 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 Tagging API 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 operation name from the X-Amz-Target header.

func (*Handler) ExtractResource

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

ExtractResource returns an empty string (the tagging API has no single resource concept).

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.

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 clears handler state by delegating to the backend if it supports it.

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 Tagging API requests.

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 the Resource Groups Tagging API. It maintains a registry of service-specific resource providers and tagging adapters. Report state and the resource cache are nested by region so that same-named resources created in different regions are fully isolated.

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

func (b *InMemoryBackend) DescribeReportCreation(ctx context.Context) *DescribeReportCreationOutput

DescribeReportCreation returns the status of the most recent StartReportCreation operation. A RUNNING report transitions to SUCCEEDED once reportRunningDuration has elapsed.

func (*InMemoryBackend) GetComplianceSummary

func (b *InMemoryBackend) GetComplianceSummary(
	ctx context.Context,
	input *GetComplianceSummaryInput,
) *GetComplianceSummaryOutput

GetComplianceSummary returns compliance summary data filtered by the supplied parameters. The in-memory backend has no tag policy, so all resources are always compliant and NonCompliantResources is always 0. Filters and pagination are honoured so callers get accurate (empty) results rather than a stub.

func (*InMemoryBackend) GetResources

func (b *InMemoryBackend) GetResources(ctx context.Context, input *GetResourcesInput) (*GetResourcesOutput, error)

GetResources queries resources across all registered providers. It applies tag filters, resource-type filters, compliance filters, and cursor-based pagination. When filtered providers are registered the filters are pushed down to them; the returned results are still post-filtered to ensure correctness from plain providers.

func (*InMemoryBackend) GetTagKeys

func (b *InMemoryBackend) GetTagKeys(ctx context.Context, input *GetTagKeysInput) *GetTagKeysOutput

GetTagKeys returns all unique tag keys across all registered resource providers. Keys are returned in sorted order, with optional cursor-based pagination.

func (*InMemoryBackend) GetTagValues

func (b *InMemoryBackend) GetTagValues(ctx context.Context, input *GetTagValuesInput) *GetTagValuesOutput

GetTagValues returns all unique values for the given tag key. Values are returned in sorted order, with optional cursor-based pagination.

func (*InMemoryBackend) ListRequiredTags

ListRequiredTags returns required tags for supported resource types. The in-memory backend always returns an empty list.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the default AWS region this backend is configured for.

func (*InMemoryBackend) RegisterARNTagger

func (b *InMemoryBackend) RegisterARNTagger(t ARNTagger)

RegisterARNTagger adds an ARN-based tagger to the registry. Taggers are tried in registration order; the first one that returns handled=true is used and the rest are skipped.

func (*InMemoryBackend) RegisterARNUntagger

func (b *InMemoryBackend) RegisterARNUntagger(u ARNUntagger)

RegisterARNUntagger adds an ARN-based untagger to the registry. Same semantics as RegisterARNTagger.

func (*InMemoryBackend) RegisterFilteredProvider

func (b *InMemoryBackend) RegisterFilteredProvider(p FilteredResourceProvider)

RegisterFilteredProvider adds a filter-aware resource provider to the registry. The provider receives the tag and resource-type filters from GetResources so that it can perform provider-side filter pushdown instead of returning all resources.

func (*InMemoryBackend) RegisterProvider

func (b *InMemoryBackend) RegisterProvider(p ResourceProvider)

RegisterProvider adds a tagged-resource provider to the registry. Providers are called in registration order on every GetResources request.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears dynamic per-test state (all region report states and caches) but intentionally preserves the registered providers, taggers, and untaggers. These are wired at server startup by wireResourceGroupsTagging and must persist across service resets, otherwise the cross-service tagging integration breaks.

func (*InMemoryBackend) Restore

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

Restore loads backend state from a JSON snapshot produced by Snapshot. Providers, taggers, and untaggers are runtime callbacks that cannot be serialized; they are always cleared by this call (regardless of whether the snapshot's version matches) and must be re-registered (e.g. via wireResourceGroupsTagging) afterward to re-enable cross-service tag operations. The per-region resource cache is likewise always invalidated.

func (*InMemoryBackend) Snapshot

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

Snapshot serializes the backend state to JSON.

func (*InMemoryBackend) StartReportCreation

func (b *InMemoryBackend) StartReportCreation(
	ctx context.Context,
	input *StartReportCreationInput,
) (*StartReportCreationOutput, error)

StartReportCreation records a new report creation request. The report begins in RUNNING state and transitions to SUCCEEDED after reportRunningDuration as observed through DescribeReportCreation. AWS rejects a new request when a report is currently RUNNING (ConcurrentModificationException).

func (*InMemoryBackend) TagResources

func (b *InMemoryBackend) TagResources(ctx context.Context, input *TagResourcesInput) (*TagResourcesOutput, error)

TagResources applies tags to the specified resources by routing to registered ARN taggers. Resources whose ARN does not match any registered tagger are reported in FailedResourcesMap with an InvalidParameterException, matching the AWS API behavior.

func (*InMemoryBackend) UntagResources

func (b *InMemoryBackend) UntagResources(
	ctx context.Context,
	input *UntagResourcesInput,
) (*UntagResourcesOutput, error)

UntagResources removes the specified tag keys from the given resources.

type ListRequiredTagsInput

type ListRequiredTagsInput struct {
	// MaxResults is the maximum number of results per page.
	MaxResults *int32 `json:"MaxResults,omitempty"`
	// NextToken is the cursor from a previous call.
	NextToken *string `json:"NextToken,omitempty"`
}

ListRequiredTagsInput is the request payload for ListRequiredTags.

type ListRequiredTagsOutput

type ListRequiredTagsOutput struct {
	// NextToken is the cursor for the next page.
	NextToken *string `json:"NextToken,omitempty"`
	// RequiredTags lists the required tags for supported resource types.
	RequiredTags []RequiredTag `json:"RequiredTags"`
}

ListRequiredTagsOutput is the response payload for ListRequiredTags.

type Provider

type Provider struct{}

Provider implements service.Provider for the Resource Groups Tagging API.

func (*Provider) Init

Init initializes the Resource Groups Tagging API backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type RequiredTag

type RequiredTag struct {
	ResourceType                *string  `json:"ResourceType,omitempty"`
	CloudFormationResourceTypes []string `json:"CloudFormationResourceTypes,omitempty"`
	ReportingTagKeys            []string `json:"ReportingTagKeys,omitempty"`
}

RequiredTag describes required tags for a resource type.

type Resettable

type Resettable interface {
	Reset()
}

Resettable is implemented by any type that supports being reset.

type ResourceProvider

type ResourceProvider func(ctx context.Context) []TaggedResource

ResourceProvider is a function that enumerates tagged resources for a service. Registered providers are called on every GetResources request. The context carries the per-request AWS region so providers can filter accordingly.

type ResourceTagMapping

type ResourceTagMapping struct {
	// ComplianceDetails is populated when IncludeComplianceDetails is true.
	ComplianceDetails *ComplianceDetails `json:"ComplianceDetails,omitempty"`
	// ResourceARN is the full ARN of the resource.
	ResourceARN string `json:"ResourceARN"`
	// Tags is the list of {Key, Value} pairs.
	Tags []Tag `json:"Tags"`
}

ResourceTagMapping associates a resource ARN with its tags.

type StartReportCreationInput

type StartReportCreationInput struct {
	// S3Bucket is the Amazon S3 bucket to store the report in.
	S3Bucket string `json:"S3Bucket"`
}

StartReportCreationInput is the request payload for StartReportCreation. The real AWS API (aws-sdk-go-v2/service/resourcegroupstaggingapi StartReportCreationInput) has no S3BucketRegion member -- only S3Bucket -- so no field for it is modeled here either.

type StartReportCreationOutput

type StartReportCreationOutput struct{}

StartReportCreationOutput is the response payload for StartReportCreation.

type StorageBackend

type StorageBackend interface {
	// Tag/resource operations
	GetResources(ctx context.Context, input *GetResourcesInput) (*GetResourcesOutput, error)
	GetTagKeys(ctx context.Context, input *GetTagKeysInput) *GetTagKeysOutput
	GetTagValues(ctx context.Context, input *GetTagValuesInput) *GetTagValuesOutput
	TagResources(ctx context.Context, input *TagResourcesInput) (*TagResourcesOutput, error)
	UntagResources(ctx context.Context, input *UntagResourcesInput) (*UntagResourcesOutput, error)

	// Report creation operations
	StartReportCreation(ctx context.Context, input *StartReportCreationInput) (*StartReportCreationOutput, error)
	DescribeReportCreation(ctx context.Context) *DescribeReportCreationOutput

	// Compliance and policy operations
	GetComplianceSummary(ctx context.Context, input *GetComplianceSummaryInput) *GetComplianceSummaryOutput
	ListRequiredTags(ctx context.Context, input *ListRequiredTagsInput) *ListRequiredTagsOutput

	// Provider registration
	RegisterProvider(p ResourceProvider)
	RegisterFilteredProvider(p FilteredResourceProvider)
	RegisterARNTagger(t ARNTagger)
	RegisterARNUntagger(u ARNUntagger)

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

StorageBackend is the interface for the Resource Groups Tagging API backend.

type Tag

type Tag struct {
	Key   string `json:"Key"`
	Value string `json:"Value"`
}

Tag is a single key-value pair.

type TagFilter

type TagFilter struct {
	// Key is the tag key to filter by.
	Key string `json:"Key"`
	// Values are the acceptable tag values; empty means any value.
	Values []string `json:"Values,omitempty"`
}

TagFilter represents a single tag filter: resources must have the given key and (if Values is non-empty) one of the given values.

type TagResourcesInput

type TagResourcesInput struct {
	Tags            map[string]string `json:"Tags"`
	ResourceARNList []string          `json:"ResourceARNList"`
}

TagResourcesInput is the request payload for TagResources.

type TagResourcesOutput

type TagResourcesOutput struct {
	// FailedResourcesMap maps ARN to failure reason for resources that could not be tagged.
	FailedResourcesMap map[string]FailureInfo `json:"FailedResourcesMap,omitempty"`
}

TagResourcesOutput is the response payload for TagResources.

type TaggedResource

type TaggedResource struct {
	Tags         map[string]string
	ResourceARN  string
	ResourceType string
}

TaggedResource represents a resource with its ARN, type, and tag set.

type UntagResourcesInput

type UntagResourcesInput struct {
	// ResourceARNList is the list of ARNs to untag.
	ResourceARNList []string `json:"ResourceARNList"`
	// TagKeys is the list of tag keys to remove.
	TagKeys []string `json:"TagKeys"`
}

UntagResourcesInput is the request payload for UntagResources.

type UntagResourcesOutput

type UntagResourcesOutput struct {
	// FailedResourcesMap maps ARN to failure reason.
	FailedResourcesMap map[string]FailureInfo `json:"FailedResourcesMap,omitempty"`
}

UntagResourcesOutput is the response payload for UntagResources.

Jump to

Keyboard shortcuts

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