awsinv

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

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

Documentation

Overview

Package awsinv reads an AWS resource's tags from an organization-level inventory.

It exists because the tags patchy needs are not reliably in the payload that brought the finding: a scanner delivery describes the resource (ARN, type, account) but its tags are optional, point-in-time extras, so ownership has to be looked up separately. Two inventories can answer, and which one an estate has is a deployment fact, not patchy's choice: AWS Config with an organization aggregator (common in large enterprises, where Config already runs estate-wide for compliance) or an organization-wide AWS Resource Explorer view (free, and available without Config). Exactly one is configured; both answer the same question, so nothing downstream can tell them apart.

Credentials come from the SDK default chain — in-cluster that means EKS Pod Identity, IRSA, or web-identity federation, so no key material exists anywhere — and the lookup is the only reason context-controller talks to AWS. It is read-only.

The client is deliberately thin — one method, one struct — so the enhancer that uses it can be tested against a hand-written fake and neither the enhancer nor anything in pkg/ ever names an AWS SDK type.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("resource not found in aws inventory")

ErrNotFound reports that the inventory has no record of the resource. This is a permanent answer, not a transient one: the resource may have been deleted between the finding being raised and this lookup, it may be of a type the inventory does not record, or it may not be indexed yet. Callers use it to decide against retrying.

Functions

This section is empty.

Types

type Client

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

Client reads resource tags from one of the two inventories. There is no interface here on purpose: the consumer declares the one-method seam it needs and this satisfies it.

func New

func New(ctx context.Context, cfg Config) (*Client, error)

New builds a client for the configured backend and verifies the backend is usable — the aggregator exists, or the view exists and includes the tags property (without it every lookup would "succeed" tagless, which must fail loudly here instead). Credentials come from the SDK default chain — EKS Pod Identity or IRSA on EKS, web-identity federation elsewhere — so no key material exists anywhere.

func (*Client) Close

func (c *Client) Close() error

Close releases nothing — the SDK clients hold no connection of their own — and exists so the enhancer can treat both cloud clients alike.

func (*Client) TagsFor

func (c *Client) TagsFor(ctx context.Context, arn string) (*Tags, error)

TagsFor returns the tags of one resource, named by its ARN. The ARN is an exact identifier in both inventories, so there is no fallback search: a miss means the resource is unrecorded, not misspelled.

Errors are classified for the caller: ErrNotFound is final, everything else is worth retrying. That distinction is what lets the enhancer chain decide between advancing a finding and holding it for another try.

type Config

type Config struct {
	// ConfigAggregator queries an AWS Config aggregator.
	ConfigAggregator *ConfigAggregator
	// ResourceExplorer searches a Resource Explorer view.
	ResourceExplorer *ResourceExplorer
}

Config selects exactly one inventory backend.

func (Config) Validate

func (c Config) Validate() error

Validate reports whether the configuration names exactly one usable backend. Checked at construction so a bad Integration fails at client build rather than on the first finding.

type ConfigAggregator

type ConfigAggregator struct {
	// Name of the aggregator.
	Name string
	// Region the aggregator lives in.
	Region string
}

ConfigAggregator names the AWS Config configuration aggregator to query.

type ResourceExplorer

type ResourceExplorer struct {
	// ViewARN of the organization-wide view.
	ViewARN string
}

ResourceExplorer names the Resource Explorer view to search. The region the view lives in is read from its ARN.

type Tags

type Tags struct {
	// Name is the resource's own name when the inventory reports one, else
	// its ARN.
	Name string
	// Tags are the resource's tags.
	Tags map[string]string
}

Tags are one resource's tags, plus enough identity to log about it.

Jump to

Keyboard shortcuts

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