{"modulePath":"github.com/agentshield-dev/agentshield","version":"v0.0.1-rc.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package aws\n\nPackage aws is a regional AWS EC2 source plugin for instances, elastic network interfaces, and security groups, with optional VPC Flow Log ingestion from Amazon Data Firehose.\n\n### Source and collections {#hdr-Source_and_collections}\n\nThe plugin polls EC2 Describe APIs with full pagination at startup, every poll interval, and immediately when an optional SQS subscriber reports a matching CloudTrail change. Polling, not the event stream, is authoritative: events only trigger a current-state read, so duplicates and reordering are harmless. Each object is content-digested so retries keep stable event IDs, and the plugin publishes the aws/ec2/\\\u003cregion\u003e/network-interfaces, instances, and security-groups collections.\n\n### Identity {#hdr-Identity}\n\nResources use the aws.amazon.com/v1 Resource scheme. The authority is each resource's 12-digit owner account, not the caller account, so shared-VPC resources owned by another account keep their owner's identity. Immutable keys are \\\u003cpartition\u003e/ec2/\\\u003cregion\u003e/\\\u003ctype\u003e/\\\u003cid\u003e. The source ID aws/\\\u003cpartition\u003e/\\\u003ccaller-account\u003e/\\\u003cregion\u003e identifies the observer only. [Plugin.ResolveIdentityReference](#Plugin.ResolveIdentityReference) turns a Kubernetes Node's aws:// provider ID into an instance claim so Kubernetes can assert Node backed-by instance.\n\n### Graph output and failure behavior {#hdr-Graph_output_and_failure_behavior}\n\nThe \"inventory\" contribution asserts instances, network interfaces, and security groups, network interface governed-by security group, and network interface exposes network destination for its current addresses, with an aws-security-group-rules facet carrying typed security semantics. An initial API failure prevents readiness. After a coherent publication, a failed poll republishes the last coherent input once with degraded health; recovery restores healthy status.\n\n### Telemetry {#hdr-Telemetry}\n\n[Plugin.FirehoseHandler](#Plugin.FirehoseHandler) authenticates Firehose HTTP endpoint deliveries for one stream and access key and decodes VPC Flow Log records with [NormalizeVPCFlowLog](#NormalizeVPCFlowLog). It acknowledges a delivery only after every event is accepted into the shared pipeline's bounded queue. A full queue blocks the delivery as backpressure, and a delivery abandoned while blocked returns 503 so Firehose retries. Raw events reach the sink before any graph rollup.\n\nSee [https://agent-shield.dev/docs/plugins/aws/](https://agent-shield.dev/docs/plugins/aws/).\n\n## Constants\n\n```go\nconst (\n\t// FirehosePath is the HTTP route the service mounts for Firehose HTTP endpoint\n\t// deliveries of VPC Flow Logs.\n\tFirehosePath = \"/v1/aws/firehose/vpc-flow-logs\"\n)\n```\n\n```go\nconst (\n\t// PluginID is the plugin and contribution owner ID.\n\tPluginID = \"aws\"\n)\n```\n\n## Functions\n\n```go\nfunc Descriptor() discovery.Descriptor\n```\nDescriptor registers the aws.amazon.com/v1 Resource identity scheme. The per-region collections are added by [Plugin.Descriptor](#Plugin.Descriptor).\n\n```go\nfunc IdentitySchemeDefinition() graph.SchemeDefinition\n```\nIdentitySchemeDefinition normalizes aws.amazon.com/v1 Resource claims: a 12-digit owner account authority and a lowercased \\\u003cpartition\u003e/ec2/\\\u003cregion\u003e/\\\u003ctype\u003e/\\\u003cid\u003e key for instances, network interfaces, and security groups.\n\n```go\nfunc NormalizeVPCFlowLog(scope ProjectionContext, line string) (telemetry.Event, error)\n```\nNormalizeVPCFlowLog maps one version 5 VPC Flow Log line in the 25-field custom order documented in [https://agent-shield.dev/docs/plugins/aws/](https://agent-shield.dev/docs/plugins/aws/) to a telemetry event between network-destination claims for the source and destination addresses. The event ID digests the source ID and the complete record so Firehose redelivery is idempotent. NODATA and SKIPDATA records carry no flow and return an error that the Firehose handler skips.\n\n```go\nfunc SourceID(partition, accountID, region string) (string, error)\n```\nSourceID returns aws/\\\u003cpartition\u003e/\\\u003caccount\u003e/\\\u003cregion\u003e, the stable source ID for the authenticated caller. Changing accounts therefore changes the source and its contribution ownership.\n\n## Types\n\n```go\ntype CLIConfig struct {\n\tRegion            string\n\tEventsQueueURL    string\n\tFirehoseStreamARN string\n\tFirehoseAccessKey string\n}\n```\nCLIConfig contains AWS-owned runtime options.\n\n```go\nfunc (config *CLIConfig) RegisterFlags(flags *pflag.FlagSet) error\n```\nRegisterFlags registers AWS flags in the aws-\\* namespace.\n\n```go\ntype ChangeBatch struct {\n\tSubscriptions []string\n\t// contains filtered or unexported fields\n}\n```\nChangeBatch is one received set of notifications. Subscriptions lists the matched subscription names; the batch must be acknowledged only after the resulting reconciliation is published.\n\n```go\ntype Config struct {\n\tPartition         string\n\tRegion            string\n\tSourceID          string\n\tEC2               EC2API\n\tSubscriber        EventSubscriber\n\tPollInterval      time.Duration\n\tFirehoseStreamARN string\n\tFirehoseAccessKey string\n}\n```\nConfig configures one regional source. SourceID should come from [SourceID](#SourceID) so it is bound to the authenticated caller account. Subscriber is optional; without it the plugin relies on PollInterval alone.\n\n```go\ntype EC2API interface {\n\tDescribeNetworkInterfaces(context.Context, *ec2.DescribeNetworkInterfacesInput, ...func(*ec2.Options)) (*ec2.DescribeNetworkInterfacesOutput, error)\n\tDescribeInstances(context.Context, *ec2.DescribeInstancesInput, ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error)\n\tDescribeSecurityGroups(context.Context, *ec2.DescribeSecurityGroupsInput, ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupsOutput, error)\n}\n```\nEC2API is the subset of the EC2 client used for inventory. Every method is fully paginated on each poll.\n\n```go\ntype EventSubscriber interface {\n\tReceive(context.Context) (ChangeBatch, error)\n\tAcknowledge(context.Context, ChangeBatch) error\n}\n```\nEventSubscriber delivers change notifications that trigger an immediate full reconciliation. Notifications are hints, not state: missing or duplicate notifications only change latency.\n\n```go\ntype EventSubscription struct {\n\tName        string\n\tSource      string\n\tEventSource string\n\tEventNames  []string\n}\n```\nEventSubscription names one inventory collection and the CloudTrail events that can change it.\n\n```go\nfunc InventoryEventSubscriptions() []EventSubscription\n```\nInventoryEventSubscriptions declares the CloudTrail EC2 events that affect each inventory collection. The EventBridge rule documented in [https://agent-shield.dev/docs/plugins/aws/](https://agent-shield.dev/docs/plugins/aws/) must cover the same event names.\n\n```go\ntype FirehoseConfig struct {\n\tStreamARN string\n\tAccessKey string\n}\n```\nFirehoseConfig binds the receiver to one Firehose stream. AccessKey is the shared secret Firehose sends in X-Amz-Firehose-Access-Key; it is compared in constant time and never logged.\n\n```go\ntype Instance struct {\n\tID               string `json:\"id\"`\n\tOwnerID          string `json:\"ownerId\"`\n\tVPCID            string `json:\"vpcId,omitempty\"`\n\tSubnetID         string `json:\"subnetId,omitempty\"`\n\tAvailabilityZone string `json:\"availabilityZone,omitempty\"`\n\tInstanceType     string `json:\"instanceType,omitempty\"`\n\tState            string `json:\"state,omitempty\"`\n\tRevision         string `json:\"-\"`\n\tEventID          string `json:\"-\"`\n}\n```\nInstance is the normalized EC2 instance observation.\n\n```go\ntype NetworkInterface struct {\n\tID                   string   `json:\"id\"`\n\tOwnerID              string   `json:\"ownerId\"`\n\tVPCID                string   `json:\"vpcId,omitempty\"`\n\tSubnetID             string   `json:\"subnetId,omitempty\"`\n\tAvailabilityZone     string   `json:\"availabilityZone,omitempty\"`\n\tInterfaceType        string   `json:\"interfaceType,omitempty\"`\n\tStatus               string   `json:\"status,omitempty\"`\n\tRequesterManaged     bool     `json:\"requesterManaged,omitempty\"`\n\tAttachmentInstanceID string   `json:\"attachmentInstanceId,omitempty\"`\n\tSecurityGroupIDs     []string `json:\"securityGroupIds,omitempty\"`\n\tAddresses            []string `json:\"addresses,omitempty\"`\n\tRevision             string   `json:\"-\"`\n\tEventID              string   `json:\"-\"`\n}\n```\nNetworkInterface is the normalized ENI observation published to the network-interfaces collection. Fields tagged json:\"-\" are delivery metadata excluded from the content digest.\n\n```go\ntype Plugin struct {\n\t// contains filtered or unexported fields\n}\n```\nPlugin is the AWS EC2 source plugin for one partition, account, and region.\n\n```go\nfunc New(config Config) (*Plugin, error)\n```\nNew validates config and applies the default five-minute poll interval.\n\n```go\nfunc (p *Plugin) Descriptor() discovery.Descriptor\n```\nDescriptor adds this region's published collections to [Descriptor](#Descriptor).\n\n```go\nfunc (p *Plugin) FirehoseHandler(config FirehoseConfig, ingestor telemetry.EventIngestor) (http.Handler, error)\n```\nFirehoseHandler returns an HTTP handler that accepts VPC Flow Log deliveries for the configured stream. The stream's account and region must match this plugin's source so flow endpoints resolve under the same authority as its inventory. A 200 response means the events are queued in the telemetry pipeline, not yet written to its sink.\n\n```go\nfunc (p *Plugin) ResolveIdentityReference(reference string) (graph.IdentityClaim, bool, error)\n```\nResolveIdentityReference resolves a Kubernetes Node spec.providerID of the form aws:///\\\u003czone\u003e/\\\u003cinstance-id\u003e to an instance claim in this source's account and region. It reports false for non-AWS references so other resolvers may claim them.\n\n```go\nfunc (p *Plugin) Run(ctx context.Context, runtime discovery.Runtime) error\n```\nRun polls and reconciles until ctx ends. See the package documentation for readiness and degraded-health behavior.\n\n```go\nfunc (p *Plugin) SourceID() string\n```\nSourceID returns the configured source ID.\n\n```go\nfunc (p *Plugin) TelemetryReceivers(ingestor telemetry.EventIngestor) ([]discovery.TelemetryReceiver, error)\n```\nTelemetryReceivers registers the optional Firehose transport owned by this AWS source. The host supplies only the shared event ingestor.\n\n```go\ntype ProjectionContext struct {\n\tPartition string\n\tRegion    string\n\tSourceID  string\n}\n```\nProjectionContext scopes projection to one partition, region, and source.\n\n```go\ntype ProjectionResult struct {\n\tInput graph.Input\n}\n```\nProjectionResult is the complete inventory contribution input.\n\n```go\nfunc Project(scope ProjectionContext, snapshot Snapshot) (ProjectionResult, error)\n```\nProject deterministically projects one coherent snapshot into the inventory contribution. Security group attachments are emitted only for groups present in the same snapshot with a known owner; others become bounded attributes.\n\n```go\ntype Rule struct {\n\tProtocol         string   `json:\"protocol\"`\n\tFromPort         *int32   `json:\"fromPort,omitempty\"`\n\tToPort           *int32   `json:\"toPort,omitempty\"`\n\tIPv4Ranges       []string `json:\"ipv4Ranges,omitempty\"`\n\tIPv6Ranges       []string `json:\"ipv6Ranges,omitempty\"`\n\tPrefixListIDs    []string `json:\"prefixListIds,omitempty\"`\n\tSecurityGroupIDs []string `json:\"securityGroupIds,omitempty\"`\n}\n```\nRule is one normalized security group permission. Lists are sorted so equivalent provider responses digest identically.\n\n```go\ntype SQSAPI interface {\n\tReceiveMessage(context.Context, *sqs.ReceiveMessageInput, ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error)\n\tDeleteMessageBatch(context.Context, *sqs.DeleteMessageBatchInput, ...func(*sqs.Options)) (*sqs.DeleteMessageBatchOutput, error)\n}\n```\nSQSAPI is the subset of the SQS client used by [SQSSubscriber](#SQSSubscriber).\n\n```go\ntype SQSSubscriber struct {\n\t// contains filtered or unexported fields\n}\n```\nSQSSubscriber long-polls an SQS queue that receives EventBridge CloudTrail events.\n\n```go\nfunc NewSQSSubscriber(client SQSAPI, config SQSSubscriberConfig) (*SQSSubscriber, error)\n```\nNewSQSSubscriber validates config and indexes the subscribed events.\n\n```go\nfunc (s *SQSSubscriber) Acknowledge(ctx context.Context, batch ChangeBatch) error\n```\nAcknowledge deletes every message in batch, matched or not.\n\n```go\nfunc (s *SQSSubscriber) Discarded() uint64\n```\nDiscarded returns how many malformed messages were discarded.\n\n```go\nfunc (s *SQSSubscriber) Receive(ctx context.Context) (ChangeBatch, error)\n```\nReceive long-polls up to ten messages. Valid but unmatched events, and messages that fail to decode or lack CloudTrail fields, are returned for acknowledgement without a subscription. A malformed message is discarded rather than returned as an error: it can never become valid, and failing would stop the plugin on every redelivery. Notifications are only hints, so the periodic poll covers whatever change it described. A message without a receipt handle cannot be deleted and is skipped.\n\n```go\ntype SQSSubscriberConfig struct {\n\tQueueURL      string\n\tAccountID     string\n\tRegion        string\n\tSubscriptions []EventSubscription\n}\n```\nSQSSubscriberConfig binds a queue to the account and region whose events are accepted; events for any other account or region are acknowledged without reconciliation.\n\n```go\ntype SecurityGroup struct {\n\tID       string `json:\"id\"`\n\tOwnerID  string `json:\"ownerId\"`\n\tVPCID    string `json:\"vpcId,omitempty\"`\n\tName     string `json:\"name,omitempty\"`\n\tIngress  []Rule `json:\"ingress\"`\n\tEgress   []Rule `json:\"egress\"`\n\tRevision string `json:\"-\"`\n\tEventID  string `json:\"-\"`\n}\n```\nSecurityGroup is the normalized security group observation with its ingress and egress rules.\n\n```go\ntype Snapshot struct {\n\tNetworkInterfaces []NetworkInterface\n\tInstances         []Instance\n\tSecurityGroups    []SecurityGroup\n}\n```\nSnapshot is one coherent, fully paginated read of all three EC2 APIs. The projector only ever sees a complete snapshot.\n\n","path":"github.com/agentshield-dev/agentshield/plugins/aws","name":"aws","synopsis":"Package aws is a regional AWS EC2 source plugin for instances, elastic network interfaces, and security groups, with optional VPC Flow Log ingestion from Amazon Data Firehose.","isRedistributable":true}
