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 ¶
- Variables
- type ARNTagger
- type ARNUntagger
- type ComplianceDetails
- type ComplianceSummary
- type DescribeReportCreationInput
- type DescribeReportCreationOutput
- type FailureInfo
- type FilteredResourceProvider
- type GetComplianceSummaryInput
- type GetComplianceSummaryOutput
- type GetResourcesInput
- type GetResourcesOutput
- type GetTagKeysInput
- type GetTagKeysOutput
- type GetTagValuesInput
- type GetTagValuesOutput
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(_ *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) AccountID() string
- func (b *InMemoryBackend) DescribeReportCreation(ctx context.Context) *DescribeReportCreationOutput
- func (b *InMemoryBackend) GetComplianceSummary(ctx context.Context, input *GetComplianceSummaryInput) *GetComplianceSummaryOutput
- func (b *InMemoryBackend) GetResources(ctx context.Context, input *GetResourcesInput) (*GetResourcesOutput, error)
- func (b *InMemoryBackend) GetTagKeys(ctx context.Context, input *GetTagKeysInput) *GetTagKeysOutput
- func (b *InMemoryBackend) GetTagValues(ctx context.Context, input *GetTagValuesInput) *GetTagValuesOutput
- func (b *InMemoryBackend) ListRequiredTags(_ context.Context, _ *ListRequiredTagsInput) *ListRequiredTagsOutput
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) RegisterARNTagger(t ARNTagger)
- func (b *InMemoryBackend) RegisterARNUntagger(u ARNUntagger)
- func (b *InMemoryBackend) RegisterFilteredProvider(p FilteredResourceProvider)
- func (b *InMemoryBackend) RegisterProvider(p ResourceProvider)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartReportCreation(ctx context.Context, input *StartReportCreationInput) (*StartReportCreationOutput, error)
- func (b *InMemoryBackend) TagResources(ctx context.Context, input *TagResourcesInput) (*TagResourcesOutput, error)
- func (b *InMemoryBackend) UntagResources(ctx context.Context, input *UntagResourcesInput) (*UntagResourcesOutput, error)
- type ListRequiredTagsInput
- type ListRequiredTagsOutput
- type Provider
- type RequiredTag
- type Resettable
- type ResourceProvider
- type ResourceTagMapping
- type StartReportCreationInput
- type StartReportCreationOutput
- type StorageBackend
- type Tag
- type TagFilter
- type TagResourcesInput
- type TagResourcesOutput
- type TaggedResource
- type UntagResourcesInput
- type UntagResourcesOutput
Constants ¶
This section is empty.
Variables ¶
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.
var ErrMissingS3Bucket = errors.New("S3Bucket is required")
ErrMissingS3Bucket is returned when StartReportCreation is called without an S3 bucket.
var ErrNilAppContext = errors.New("nil AppContext passed to ResourceGroupsTaggingAPI Provider.Init")
ErrNilAppContext is returned by Init when a nil AppContext is passed.
var ErrUnknownOperation = errors.New("UnknownOperationException")
ErrUnknownOperation is returned when the requested Tagging API operation is not supported.
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 ¶
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 ¶
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 ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this Resource Groups Tagging API instance handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation extracts the operation name from the X-Amz-Target header.
func (*Handler) ExtractResource ¶
ExtractResource returns an empty string (the tagging API has no single resource concept).
func (*Handler) GetSupportedOperations ¶
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 ¶
MatchPriority returns the routing priority.
func (*Handler) Reset ¶
func (h *Handler) Reset()
Reset clears handler state by delegating to the backend if it supports it.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches Resource Groups Tagging API requests.
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 ¶
func (b *InMemoryBackend) ListRequiredTags(_ context.Context, _ *ListRequiredTagsInput) *ListRequiredTagsOutput
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 ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the Resource Groups Tagging API backend and handler.
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 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 ¶
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.