resourcegroupstaggingapi

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 21 Imported by: 0

README

Resource Groups Tagging API

Parity grade: A · SDK aws-sdk-go-v2/service/resourcegroupstaggingapi@v1.35.4 · last audited 2026-08-07 (pending (uncommitted this pass -- see git log at merge time))

Coverage

Metric Value
Operations audited 9 (8 ok, 1 partial)
Feature families 2 (2 ok)
Known gaps 9
Deferred items 2
Resource leaks clean
Known gaps
  • GetComplianceSummary always reports zero noncompliant resources. This is NOT simply 'no tag-policy engine exists' (services/organizations does model TAG_POLICY content, attachment, and effective-policy merging) -- the real blocker is architectural: real GetComplianceSummary is a management-account-only operation that aggregates noncompliant counts across every member account in an organization (verified against the AWS API reference, whose example response returns rows for three distinct account IDs), and gopherstack has no multi-account resource-store simulation anywhere to aggregate across. A single-account approximation would misrepresent the operation's actual (cross-account) contract, so was not built. Documented, not fabricated (bd: gopherstack-i710).
  • CLOSED 2026-08-07 (gopherstack-3xfq): ListRequiredTags now parses a policy's report_required_tag_for element for real -- see the ListRequiredTags ops row above. NEEDS CENTRAL WIRING (cli.go, out of this service's scope): nothing currently calls resourcegroupstaggingapi.RegisterTagPolicyProvider. The wiring should look up the current account's effective TAG_POLICY via services/organizations' DescribeEffectivePolicy("TAG_POLICY", accountID) and register a closure returning (content, ok) from it -- mirroring how other cross-service registrations already happen in cli.go's wireResourceGroupsTagging for RegisterProvider/RegisterARNTagger. Until wired, ListRequiredTags continues to correctly return an empty list (no tag policy configured), not an error.
  • cli.go's wireResourceGroupsTagging covers only ~91 of gopherstack's ~90 services (RegisterProvider/RegisterARNTagger/RegisterARNUntagger for cross-service resource discovery) -- a pre-existing gap, out of this service's scope, tracked separately (bd: gopherstack-3xne).
  • ResourceTypeFilters validation uses a regex stricter than the real (unconstrained) schema, and ResourceARN has no enforced 1011-character max -- not investigated or fixed this pass (gopherstack-3xfq's stated scope also named these; ran out of time after the tag-policy engine and the SRP-6a work prioritized elsewhere this session).
  • Cross-service tag wiring (cli.go wireResourceGroupsTagging) now covers 55 of the ~90 services with native TagResource support -- see cli.go's wireResourceGroupsTagging doc comment for the exact wired list. Latest sweep added accessanalyzer, dlm, ce, mediapackage, swf, fis, codeconnections, mediastore, mwaa, pipes (10 services, bringing the count from 45 to 55). Every new service fit the existing resourceTypeFromARN/constantResourceType dispatch without needing further generalization: accessanalyzer (analyzer/{name}), dlm (policy/{id}), mediastore (container/{name}), pipes (pipe/{name}), and mwaa (environment/{name}) tag exactly one resource kind each, so each uses a constant resource type; ce (costcategory/anomalymonitor/anomalysubscription), mediapackage (channels/origin_endpoints), fis (safety-lever/experiment-template/experiment), and codeconnections (connection/host/repository-link) mix several kinds in one flat ARN-keyed store, so each uses resourceTypeFromARN to derive the type per-ARN. Two needed a documented exception rather than a code change: swf's domain ARN has a literal leading slash before its resource segment ("arn:aws:swf:region:account:/domain/{name}", confirmed against swfARNRegex in services/swf/tags.go), which would make resourceTypeFromARN read an empty type from the leading separator, so it uses a constant resource type instead; mwaa's ARNs use the real AWS "airflow" service namespace rather than "mwaa" (confirmed against every arn.Build call in services/mwaa), which the wiring passes explicitly rather than the package's own name. Several other candidate services (macie2, managedblockchain, mediaconvert, datasync, codedeploy, inspector2, and more) have native TagResource support with what looks like the same flat-ARN shape this sweep wired, but were not pursued this pass -- each would need its own TaggedResources()-style accessor added to its backend (like the ten added this sweep) before it could be wired, and none of that accessor work was started or verified, so none of it is claimed done. s3control remains blocked as before (its taggable ARNs live under the "s3"/"s3-object-lambda" service namespaces rather than "s3control" itself, so the current arnServiceIs single-namespace dispatch doesn't fit it) (bd: gopherstack-3xne).
  • This pass (gopherstack-3xne) wired the six services the prior sweep named but did not pursue: macie2, managedblockchain, mediaconvert, datasync, codedeploy, inspector2 -- bringing the count from 55 to 61. Each needed its own new TaggedResources() accessor (none had one): macie2 (allow-list/custom-data-identifier/findings-filter/classification-job, flat b.tags map), managedblockchain (accessors/members/nodes/networks via arnToResource type-switch on each resource's own Tags field -- invitations carry no Tags field and are never tagged), mediaconvert (jobTemplates/jobs/presets/queues, flat b.tags map), datasync (agent/location/task, flat b.tags map -- task executions build a nested ARN but isKnownResource never recognizes them so they can never be tagged), codedeploy (application/deploymentgroup, tags live on Application.Tags/DeploymentGroup.Tags via pkgs/tags.Tags, not a flat map), inspector2 (filter only in practice -- resourceExists gates tagging to filter ARNs or an ARN already seeded into b.tags, and only CreateFilter does that seeding). All six ARN shapes were confirmed against each service's own arn.Build call sites before wiring; none needed a namespace or nested-segment exception like the SWF/MWAA/DAX/Cognito traps found in earlier passes, except codedeploy's application/deploymentgroup ARNs use a colon (not slash) before the resource segment -- resourceTypeFromARN already handles both separators, so no change was needed there. s3control remains blocked as documented (bd: gopherstack-3xne).
  • ResourceTypeFilters format validation (resourceTypeFilterRE, requiring lowercase 'service[:type]' shape) is stricter than the real API's AmazonResourceType schema, which declares pattern [\s\S]* (i.e. no server-side pattern constraint beyond max length 256). Predates this sweep; left unchanged because there is no confirmed evidence of real AWS's actual runtime rejection behavior for malformed resource-type filters (docs describe the convention but the schema doesn't enforce it), and changing validation behavior without positive confirmation risks trading one mismatch for another. Flagged for a future sweep with real-AWS or integration-test verification.
  • This pass (gopherstack-3xne, fourth sweep) wired eight more: RAM, Rekognition, Translate, AppStream, MediaTailor, VPCLattice, CodePipeline, KinesisAnalyticsV2 -- bringing the count from 61 to 69. Each needed its own new TaggedResources() accessor (none had one). Two new ARN-namespace traps found, both confirmed against the service's own arn.Build call sites before wiring: VPC Lattice's real ARN service is "vpc-lattice", not "vpclattice" (services/vpclattice/store.go's arnService constant); Kinesis Data Analytics v2's ARNs use the real AWS "kinesisanalytics" namespace, not "kinesisanalyticsv2" (services/kinesisanalyticsv2/tags.go), which it shares with the separate, still-unwired kinesisanalytics (v1) service -- wiring v1 later needs the same registration-order ownership check wireTaggingDocDB/wireTaggingNeptune use for their shared "rds" namespace, not a plain registerTaggingService call, or it will shadow v2. RAM's real TagResource only ever tags resource shares (confirmed: TagResource checks only b.resourceShares, never the permission or invitation ARNs also built via arn.Build elsewhere in the package), so it uses a constant resource type rather than resourceTypeFromARN. CodePipeline mixes two ARN shapes in one flat store -- a bare-name pipeline ARN (no separator) and a colon-separated "webhook:{name}" ARN -- so a small codepipelineResourceType wrapper turns resourceTypeFromARN's bare-name fallback into an explicit "codepipeline:pipeline" instead of leaving it as the ambiguous service-alone string. Rekognition's resourceExists gate (already documented in rekognition/tags.go) is narrower than its arn.Build call sites: bare project ARNs are never accepted, only collection, stream processor, and project version ARNs are, matching the real API. AppStream only tags the resource kinds it seeds into its tag store at creation time (stacks, app blocks, fleets, applications, images); directory configs and users build ARNs too but are never seeded, so they can never be tagged. opsworks was examined and explicitly skipped: it has native tagging support and a real resourceExists gate already correctly scoped to stack/layer ARNs (per its own doc comment), but the service itself is never registered in cli.go's getServiceProviders chain at all -- no &opsworksbackend.Provider{} entry anywhere -- so it isn't a running service and wiring its tagging would be a no-op (byName["OpsWorks"] is always nil). fsx was also examined and skipped: every one of its CreateFileCache/CreateBackup/CreateDataRepositoryTask/CreateVolume/CreateFileSystem/CreateSnapshot/CreateStorageVirtualMachine functions takes an unexported *createXInput struct, so it cannot be exercised from cli_test.go via the established direct-backend-call pattern without adding HTTP-layer test scaffolding no other subtest in this table uses. s3control remains blocked as documented (bd: gopherstack-3xne).
  • This pass (gopherstack-3xne, fifth sweep) wired 21 more: Comprehend, Shield, Transcribe, VerifiedPermissions, WAF Classic, SecurityHub, AppRunner, Route53Resolver, Timestream Write, S3 Tables, WorkMail, Pinpoint, Application Auto Scaling, CodeArtifact, Clean Rooms, App Mesh, Personalize, SESv2, X-Ray, AWS Config, and EventBridge Scheduler -- bringing the count from 69 to 91 (of the roughly 90 originally estimated; the true total was always an approximation). Each got a new TaggedResources() accessor. New ARN-namespace traps, each confirmed against the service's own arn.Build call sites: Timestream Write uses "timestream", not "timestreamwrite"; Pinpoint uses "mobiletargeting", not "pinpoint"; SESv2 shares the real "ses" namespace with SES v1 (which builds no ARNs of its own today, so unlike kinesisanalytics v1/v2 there is no registration-order collision to guard against yet); AWS Config uses "config", not "awsconfig" (hand-built ARN strings, not pkgs/arn); Application Auto Scaling's scalable targets build ARNs under the real "application-autoscaling" namespace while its scheduled actions and scaling policies build ARNs under "autoscaling" instead (matching real AWS's own historical split) -- but TagResource only ever resolves scalable targets, so only "application-autoscaling" is wired. Two new nested-ARN shapes needed the existing nestedResourceType helper ("parent/id/kind/id", already handled, no new helper needed): WorkMail nests users/groups/resources one level under their organization, Clean Rooms nests seven sub-resource kinds one level under their membership. App Mesh and S3 Tables needed dedicated derivation closures (appmeshResourceType, s3tablesResourceType) since App Mesh nests to varying depths (mesh -> virtualNode/virtualRouter/etc -> route/gatewayRoute, 2/4/6 segments) and S3 Tables nests a table under a namespace under a bucket (5 segments) -- both deeper than nestedResourceType's fixed 4-segment check. The acceptance-gate-narrower-than-arn.Build trap paid off twice more: Shield's TagResource never resolves protection-group ARNs (only protections), and Application Auto Scaling's TagResource never resolves scheduled-action or scaling-policy ARNs (only scalable targets). EXAMINED AND SKIPPED: forecast's only resource-creation path (b.create) is unexported and reachable solely from its own handler's JSON operation dispatch, not a direct backend method the established cli_test.go pattern can call -- wiring was written, then backed out once this was confirmed, rather than shipped untested. s3control remains blocked as documented (bd: gopherstack-3xne). NOT PURSUED, no code written: acm (tags live behind a Handler-level, not Backend-level, ARN dispatch spanning four distinct resource kinds -- not read deeply enough to confirm the pattern fits), amplify, apigateway (leading-slash "/restapis/{id}" ARN with no account segment), apigatewayv2, appsync (TagResource takes an apiID, not a full ARN), databrew, emrserverless (leading-slash ARN), iot (TagResourceGeneric's acceptance-gate breadth was not traced), iotanalytics, kafka, organizations (TagResource takes a bare resourceID, not an ARN, so the generic ARN-keyed dispatch needs an adapter that was not written), ssoadmin (TagResource takes both an instanceArn and a resourceArn, and its ARNs use the "sso" namespace), and textract -- see cli.go's wireResourceGroupsTagging doc comment for the current exact wired list.
Deferred
  • Full TagsPerPage/ResourcesPerPage interaction edge cases beyond the cumulative-tag-count cap (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
  • ResourceARN max-length (1011 chars per the real ResourceARN shape) is not validated in validateARNList; only structural parseability (awsarn.Parse) is checked. Low-value edge case, not exercised by any known test.

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 ErrPaginationTokenExpired = errors.New("PaginationTokenExpiredException")

ErrPaginationTokenExpired is returned when a GetResources/GetTagKeys/GetTagValues PaginationToken does not correspond to any item in the current result set. Real AWS pagination tokens are valid for a maximum of 15 minutes (see aws-sdk-go-v2/service/resourcegroupstaggingapi/types/errors.go); this in-memory backend has no encoded timestamp to check, so any token that fails to resolve -- malformed, stale, or referencing a since-removed resource -- is treated as expired, matching real AWS's documented behavior for an unresolvable token.

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. When no report has ever been started for the region, or the most recent non-RUNNING report is older than reportStaleAfter, Status is reportStatusNoReport ("NO REPORT") -- a real, documented AWS status value, not an absent/nil field.

func (*InMemoryBackend) GetComplianceSummary

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

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, error)

GetTagKeys returns all unique tag keys across all registered resource providers. Keys are returned in sorted order, with optional cursor-based pagination. Returns ErrPaginationTokenExpired when PaginationToken does not resolve against the current key set.

func (*InMemoryBackend) GetTagValues

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

GetTagValues returns all unique values for the given tag key. Values are returned in sorted order, with optional cursor-based pagination. Returns ErrPaginationTokenExpired when PaginationToken does not resolve against the current value set.

func (*InMemoryBackend) ListRequiredTags

ListRequiredTags returns the required tags for supported resource types, derived from the account's effective tag policy (see RegisterTagPolicyProvider). With no provider registered, or no TAG_POLICY attached, this accurately returns an empty list -- the real AWS behavior for an account with no required-tag reporting configured, not a stub.

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) RegisterTagPolicyProvider added in v1.3.1

func (b *InMemoryBackend) RegisterTagPolicyProvider(p TagPolicyProvider)

RegisterTagPolicyProvider sets the single provider ListRequiredTags consults for this account's effective TAG_POLICY document. A second call replaces the first -- there is exactly one effective tag policy per account, unlike the many-provider registries above.

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, error)
	GetTagValues(ctx context.Context, input *GetTagValuesInput) (*GetTagValuesOutput, error)
	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, error)
	ListRequiredTags(ctx context.Context, input *ListRequiredTagsInput) *ListRequiredTagsOutput

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

	// 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 TagPolicyProvider added in v1.3.1

type TagPolicyProvider func() (content string, ok bool)

TagPolicyProvider returns this account's effective TAG_POLICY document content -- the same JSON a real DescribeEffectivePolicy(PolicyType=TAG_POLICY) call against AWS Organizations would return (see services/organizations/effective_policy.go) -- and whether one is configured at all. ListRequiredTags uses this to derive real required-tag data instead of always returning an empty list. Central wiring (cli.go) is expected to register the organizations backend's effective policy for this account; with no provider registered, ListRequiredTags accurately reports the real AWS behavior for an account with no tag policy attached: an empty list.

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