Documentation
¶
Index ¶
- Constants
- func ClusterOf(serviceArn string) string
- func DescribeCriterion(c Criterion) string
- func GlobMatches(pattern, value string) bool
- func LBDimension(arn string) string
- func Matches(c Criterion, a Account, r ScannedRule, _ OrgInventory) bool
- func ResourceTagsMatch(wanted, tags map[string][]string) bool
- func TGDimension(arn string) string
- type ASGInstance
- type Account
- type AccountEvent
- type AccountPlan
- type Action
- type AllOptions
- type AutoScalingGroup
- type AutoScalingPort
- type Backend
- type CloudWatchPort
- type Condition
- type Config
- type Criterion
- type Database
- type Decision
- type DescribeAutoScalingGroupsInput
- type DescribeAutoScalingGroupsOutput
- type DescribeInstancesInput
- type DescribeInstancesOutput
- type DescribeListenersInput
- type DescribeListenersOutput
- type DescribeLoadBalancersInput
- type DescribeLoadBalancersOutput
- type DescribeRulesInput
- type DescribeRulesOutput
- type DescribeSecurityGroupsInput
- type DescribeSecurityGroupsOutput
- type DescribeServicesInput
- type DescribeServicesOutput
- type DescribeTagsInput
- type DescribeTagsOutput
- type DescribeTargetGroupsInput
- type DescribeTargetGroupsOutput
- type DescribeTargetHealthInput
- type DescribeTargetHealthOutput
- type Dimension
- type EC2Port
- type ECSPort
- type ELBv2Port
- type Filter
- type ForwardConfig
- type ForwardTarget
- type GetMetricDataInput
- type GetMetricDataOutput
- type IneligibleRule
- type Instance
- type InventoryProgress
- type IpPermission
- type ListAccountsForParentInput
- type ListAccountsForParentOutput
- type ListClustersInput
- type ListClustersOutput
- type ListOrganizationalUnitsForParentInput
- type ListOrganizationalUnitsForParentOutput
- type ListRootsInput
- type ListRootsOutput
- type ListServicesInput
- type ListServicesOutput
- type ListTagsForResourceInput
- type ListTagsForResourceOutput
- type Listener
- type LoadBalancer
- type Metric
- type MetricDataQuery
- type MetricDataResult
- type MetricStat
- type OU
- type OrgAccount
- type OrgInventory
- type OrganizationalUnit
- type OrganizationsPort
- type PairPlan
- type ProgressEvent
- type RegionDiscovery
- type RegionEC2Port
- type RegionPorts
- type Reservation
- type Root
- type Rule
- type RuleRef
- type RulesPort
- type ScanPorts
- type ScanResult
- type ScannedRule
- type SecurityGroup
- type Service
- type ServiceLoadBalancer
- type Tag
- type TagDescription
- type TagWant
- type TagWants
- type Target
- type TargetDescription
- type TargetGroup
- type TargetHealthDescription
- type UnreadableCluster
- type UserIdGroupPair
- type ValuesConfig
- type Where
- type Workload
- type WorkloadBackend
Constants ¶
const ( FromCache = "cache" FromAWS = "aws" )
Where a region came from.
const ( AccountStarted = "started" AccountDone = "done" )
Account states of an AccountEvent.
const ( KindInstance = "instance" KindASG = "asg" KindECS = "ecs" KindK8s = "k8s" )
Backend kinds of a candidate.
const ( Managed = "managed" Eligible = "eligible" Ineligible = "ineligible" )
Eligibility of a candidate.
const PhaseDiscovery = "discovery"
PhaseDiscovery is the Phase of the events discovery emits (Node's phases are discovery, requests and uptime).
const RefreshDiscovery = "discovery"
Refresh values: --refresh discovery scans everything again.
Variables ¶
This section is empty.
Functions ¶
func ClusterOf ¶
ClusterOf is the ECS cluster of a service ARN (arn:aws:ecs:<region>:<account>:service/<cluster>/<service>); the old format (service/<service>) is in the default cluster.
func DescribeCriterion ¶
DescribeCriterion says what the criterion sets ("account 111111111111, region eu-west-1"), for reasons and lint messages.
func GlobMatches ¶
GlobMatches reports whether value matches a pattern with * wildcards, ignoring case.
func LBDimension ¶
LBDimension is the CloudWatch LoadBalancer dimension of a load balancer ARN.
func Matches ¶
func Matches(c Criterion, a Account, r ScannedRule, _ OrgInventory) bool
Matches reports whether the criterion matches a scanned rule of an account: every dimension it sets must match.
func ResourceTagsMatch ¶
ResourceTagsMatch: each wanted key on the load balancer, the target group or the rule, with one of the values (none: any value).
func TGDimension ¶
TGDimension is the CloudWatch TargetGroup dimension of a target group ARN.
Types ¶
type ASGInstance ¶
type ASGInstance struct {
InstanceId string `json:"InstanceId,omitempty"`
}
ASGInstance is an instance of an Auto Scaling group.
type Account ¶
type Account struct {
ID string `json:"id"`
Name string `json:"name"`
OUPath []string `json:"ouPath"` // root first, parent last
Tags map[string]string `json:"tags"`
}
Account is an active account of the organization.
type AccountEvent ¶
type AccountEvent struct {
Account string `json:"account"`
State string `json:"state"` // started or done
Regions int `json:"regions"`
Error string `json:"error,omitempty"`
}
AccountEvent is an account of the discovery phase: started once its regions are known, done after the last (Error: its regions could not be listed, or its credentials not obtained).
type AccountPlan ¶
type AccountPlan struct {
Account string `json:"account"`
Scan bool `json:"scan"`
Reason string `json:"reason"`
}
AccountPlan says whether an account is scanned.
func ScanAccounts ¶
func ScanAccounts(cfg Config, inv OrgInventory) []AccountPlan
ScanAccounts says, for each account of the inventory, whether it is scanned.
type Action ¶
type Action struct {
Type string `json:"Type,omitempty"`
Order int `json:"Order,omitempty"`
TargetGroupArn string `json:"TargetGroupArn,omitempty"`
ForwardConfig *ForwardConfig `json:"ForwardConfig,omitempty"`
}
Action is a rule's action.
type AllOptions ¶
type AllOptions struct {
// Accounts in the organization's order; Unreachable says whether an account
// was listed apart as refusing its role (asked when it fails; nil: none).
Accounts []Target
Unreachable func(account string) bool
// Regions is --regions, used as given (never cached as an account's enabled
// regions); nil: each account's enabled ones (RegionsOf).
Regions []string
RegionsOf func(ctx context.Context, account string, creds *aws.Credentials) ([]string, error)
PortsOf func(ctx context.Context, account, region string, creds *aws.Credentials) (RegionPorts, error)
Cache *cache.Cache
// Refresh is "discovery" (scan everything again), "metrics" or "".
Refresh string
Now func() time.Time
// Progress and AccountProgress are called one at a time (a mutex), though
// accounts run at once.
Progress func(ProgressEvent)
AccountProgress func(AccountEvent)
// Concurrency is the accounts discovered at once (--parallel; 5 when < 1).
Concurrency int
}
AllOptions are the inputs of All.
type AutoScalingGroup ¶
type AutoScalingGroup struct {
AutoScalingGroupName string `json:"AutoScalingGroupName,omitempty"`
AutoScalingGroupARN string `json:"AutoScalingGroupARN,omitempty"`
TargetGroupARNs []string `json:"TargetGroupARNs,omitempty"`
Tags []Tag `json:"Tags,omitempty"`
DesiredCapacity int `json:"DesiredCapacity,omitempty"`
Instances []ASGInstance `json:"Instances,omitempty"`
}
AutoScalingGroup is the part of a group the scan reads.
type AutoScalingPort ¶
type AutoScalingPort interface {
DescribeAutoScalingGroups(ctx context.Context, in DescribeAutoScalingGroupsInput) (DescribeAutoScalingGroupsOutput, error)
}
AutoScalingPort is the Auto Scaling API.
type Backend ¶
type Backend struct {
Kind string `json:"kind"`
ID string `json:"id"`
ARN string `json:"arn,omitempty"` // from 2026-10-05 scans
Kubernetes *kubernetes.Candidate `json:"kubernetes,omitempty"`
}
Backend is the backend behind a target group: an instance, an Auto Scaling group, an ECS service or a Kubernetes owner (Kubernetes then says how).
type CloudWatchPort ¶
type CloudWatchPort interface {
GetMetricData(ctx context.Context, in GetMetricDataInput) (GetMetricDataOutput, error)
}
CloudWatchPort is the metrics API.
type Condition ¶
type Condition struct {
Field string
Values []string
HostHeaderConfig *ValuesConfig
PathPatternConfig *ValuesConfig
Raw string
}
Condition is a rule's condition. Raw keeps its JSON, as Node's JSON.stringify gives it for a field the scan does not know.
func (Condition) MarshalJSON ¶
MarshalJSON writes the condition as it was read.
func (*Condition) UnmarshalJSON ¶
UnmarshalJSON reads a condition and keeps its JSON.
type Config ¶
type Config struct {
Version int `json:"version"`
Mode string `json:"mode"`
Regions []string `json:"regions"`
RefreshHours int `json:"refreshHours"`
GlobalExcludes []Criterion `json:"globalExcludes"`
Filters []Filter `json:"filters"`
}
Config is the discovery configuration the perimeter reads.
type Criterion ¶
type Criterion struct {
Note string `json:"note,omitempty"`
AccountIDs []string `json:"accountIds,omitempty"`
OUIDs []string `json:"ouIds,omitempty"`
AccountTags TagWants `json:"accountTags,omitempty"`
Regions []string `json:"regions,omitempty"`
LoadBalancers []string `json:"loadBalancers,omitempty"`
Hosts []string `json:"hosts,omitempty"`
ResourceTags TagWants `json:"resourceTags,omitempty"`
BackendKinds []string `json:"backendKinds,omitempty"`
TargetGroups []string `json:"targetGroups,omitempty"`
Label string `json:"label,omitempty"`
}
Criterion selects accounts, regions and resources; every dimension it sets must match. A nil slice or TagWants is a dimension it does not set.
type Database ¶
type Database struct {
Kind string `json:"kind"` // rds-instance or rds-cluster
ID string `json:"id"`
Status string `json:"status"`
AllowedFrom []string `json:"allowedFrom"`
Tags map[string][]string `json:"tags"`
Stopped []stopped.Item `json:"stopped"`
NotStoppable string `json:"notStoppable,omitempty"`
}
Database is a companion database candidate of the region.
type Decision ¶
type Decision struct {
Scope string `json:"scope"` // in, out or excluded
Reason string `json:"reason"`
}
Decision is whether a rule is in the perimeter, and why.
func Decide ¶
func Decide(cfg Config, a Account, r ScannedRule, inv OrgInventory) Decision
Decide says whether a rule is in the perimeter: global excludes win, then any filter including it without excluding it.
type DescribeAutoScalingGroupsInput ¶
type DescribeAutoScalingGroupsInput struct {
NextToken string `json:"NextToken,omitempty"`
AutoScalingGroupNames []string `json:"AutoScalingGroupNames,omitempty"`
}
DescribeAutoScalingGroupsInput is a page of Auto Scaling groups.
type DescribeAutoScalingGroupsOutput ¶
type DescribeAutoScalingGroupsOutput struct {
AutoScalingGroups []AutoScalingGroup `json:"AutoScalingGroups,omitempty"`
NextToken string `json:"NextToken,omitempty"`
}
DescribeAutoScalingGroupsOutput is its answer.
type DescribeInstancesInput ¶
type DescribeInstancesInput struct {
InstanceIds []string `json:"InstanceIds"`
}
DescribeInstancesInput asks instances by id.
type DescribeInstancesOutput ¶
type DescribeInstancesOutput struct {
Reservations []Reservation `json:"Reservations,omitempty"`
}
DescribeInstancesOutput is its answer.
type DescribeListenersInput ¶
type DescribeListenersInput struct {
LoadBalancerArn string `json:"LoadBalancerArn"`
Marker string `json:"Marker,omitempty"`
}
DescribeListenersInput is a page of a load balancer's listeners.
type DescribeListenersOutput ¶
type DescribeListenersOutput struct {
Listeners []Listener `json:"Listeners,omitempty"`
NextMarker string `json:"NextMarker,omitempty"`
}
DescribeListenersOutput is its answer.
type DescribeLoadBalancersInput ¶
type DescribeLoadBalancersInput struct {
Marker string `json:"Marker,omitempty"`
}
DescribeLoadBalancersInput is a page of load balancers.
type DescribeLoadBalancersOutput ¶
type DescribeLoadBalancersOutput struct {
LoadBalancers []LoadBalancer `json:"LoadBalancers,omitempty"`
NextMarker string `json:"NextMarker,omitempty"`
}
DescribeLoadBalancersOutput is its answer.
type DescribeRulesInput ¶
type DescribeRulesInput struct {
ListenerArn string `json:"ListenerArn,omitempty"`
Marker string `json:"Marker,omitempty"`
RuleArns []string `json:"RuleArns,omitempty"` // rules by ARN (a managed workload's waker)
}
DescribeRulesInput is a page of a listener's rules.
type DescribeRulesOutput ¶
type DescribeRulesOutput struct {
Rules []Rule `json:"Rules,omitempty"`
NextMarker string `json:"NextMarker,omitempty"`
}
DescribeRulesOutput is its answer.
type DescribeSecurityGroupsInput ¶
type DescribeSecurityGroupsInput struct {
GroupIds []string `json:"GroupIds"`
}
DescribeSecurityGroupsInput asks security groups by id.
type DescribeSecurityGroupsOutput ¶
type DescribeSecurityGroupsOutput struct {
SecurityGroups []SecurityGroup `json:"SecurityGroups,omitempty"`
}
DescribeSecurityGroupsOutput is its answer.
type DescribeServicesInput ¶
type DescribeServicesInput struct {
Cluster string `json:"cluster"`
Services []string `json:"services"`
}
DescribeServicesInput asks up to 10 services of a cluster.
type DescribeServicesOutput ¶
type DescribeServicesOutput struct {
Services []Service `json:"services,omitempty"`
}
DescribeServicesOutput is its answer.
type DescribeTagsInput ¶
type DescribeTagsInput struct {
ResourceArns []string `json:"ResourceArns"`
}
DescribeTagsInput asks the tags of up to 20 resources.
type DescribeTagsOutput ¶
type DescribeTagsOutput struct {
TagDescriptions []TagDescription `json:"TagDescriptions,omitempty"`
}
DescribeTagsOutput is its answer.
type DescribeTargetGroupsInput ¶
type DescribeTargetGroupsInput struct {
Marker string `json:"Marker,omitempty"`
TargetGroupArns []string `json:"TargetGroupArns,omitempty"`
}
DescribeTargetGroupsInput is a page of target groups.
type DescribeTargetGroupsOutput ¶
type DescribeTargetGroupsOutput struct {
TargetGroups []TargetGroup `json:"TargetGroups,omitempty"`
NextMarker string `json:"NextMarker,omitempty"`
}
DescribeTargetGroupsOutput is its answer.
type DescribeTargetHealthInput ¶
type DescribeTargetHealthInput struct {
TargetGroupArn string `json:"TargetGroupArn"`
}
DescribeTargetHealthInput asks a target group's targets.
type DescribeTargetHealthOutput ¶
type DescribeTargetHealthOutput struct {
TargetHealthDescriptions []TargetHealthDescription `json:"TargetHealthDescriptions,omitempty"`
}
DescribeTargetHealthOutput is its answer.
type EC2Port ¶
type EC2Port interface {
DescribeInstances(ctx context.Context, in DescribeInstancesInput) (DescribeInstancesOutput, error)
}
EC2Port is read only where the region has EKS clusters (their nodes).
type ECSPort ¶
type ECSPort interface {
ListClusters(ctx context.Context, in ListClustersInput) (ListClustersOutput, error)
ListServices(ctx context.Context, in ListServicesInput) (ListServicesOutput, error)
DescribeServices(ctx context.Context, in DescribeServicesInput) (DescribeServicesOutput, error)
}
ECSPort is the ECS API.
type ELBv2Port ¶
type ELBv2Port interface {
DescribeLoadBalancers(ctx context.Context, in DescribeLoadBalancersInput) (DescribeLoadBalancersOutput, error)
DescribeListeners(ctx context.Context, in DescribeListenersInput) (DescribeListenersOutput, error)
DescribeRules(ctx context.Context, in DescribeRulesInput) (DescribeRulesOutput, error)
DescribeTags(ctx context.Context, in DescribeTagsInput) (DescribeTagsOutput, error)
DescribeTargetGroups(ctx context.Context, in DescribeTargetGroupsInput) (DescribeTargetGroupsOutput, error)
DescribeTargetHealth(ctx context.Context, in DescribeTargetHealthInput) (DescribeTargetHealthOutput, error)
}
ELBv2Port is the load balancers API.
type Filter ¶
type Filter struct {
Name string `json:"name"`
Include []Criterion `json:"include"`
Exclude []Criterion `json:"exclude"`
}
Filter includes what any of its includes match, minus its own excludes.
type ForwardConfig ¶
type ForwardConfig struct {
TargetGroups []ForwardTarget `json:"TargetGroups,omitempty"`
}
ForwardConfig is a forward action's target groups (nil: the action's own).
type ForwardTarget ¶
type ForwardTarget struct {
TargetGroupArn string `json:"TargetGroupArn,omitempty"`
Weight *int `json:"Weight,omitempty"`
}
ForwardTarget is a target group of a forward action, with its weight (absent: 1).
type GetMetricDataInput ¶
type GetMetricDataInput struct {
StartTime time.Time
EndTime time.Time
MetricDataQueries []MetricDataQuery
NextToken string
}
GetMetricDataInput is a GetMetricData call. Its times are written as Node's toISOString does (2026-10-12T08:00:00.000Z).
func (GetMetricDataInput) MarshalJSON ¶
func (in GetMetricDataInput) MarshalJSON() ([]byte, error)
MarshalJSON writes the input with its times as ISO strings.
type GetMetricDataOutput ¶
type GetMetricDataOutput struct {
MetricDataResults []MetricDataResult `json:"MetricDataResults,omitempty"`
NextToken string `json:"NextToken,omitempty"`
}
GetMetricDataOutput is its answer.
type IneligibleRule ¶
type IneligibleRule struct {
LoadBalancer string `json:"loadBalancer"`
TargetGroup *string `json:"targetGroup"`
Hosts []string `json:"hosts"`
Reason string `json:"reason"`
}
IneligibleRule is a rule that is not a workload, and why.
type Instance ¶
type Instance struct {
InstanceID string `json:"InstanceId,omitempty"`
Tags []Tag `json:"Tags,omitempty"`
}
Instance is an instance with its tags.
type InventoryProgress ¶ added in v0.2.0
type InventoryProgress struct {
Read, Found, Accounts int
}
InventoryProgress is the inventory's walk so far: the organizational units read (their accounts and children listed), of those found (the root included), and the active accounts found.
type IpPermission ¶
type IpPermission struct {
UserIdGroupPairs []UserIdGroupPair `json:"UserIdGroupPairs,omitempty"`
}
IpPermission is an ingress rule.
type ListAccountsForParentInput ¶
type ListAccountsForParentInput struct {
ParentID string `json:"ParentId"`
NextToken string `json:"NextToken,omitempty"`
}
ListAccountsForParentInput is a page of a parent's accounts.
type ListAccountsForParentOutput ¶
type ListAccountsForParentOutput struct {
Accounts []OrgAccount `json:"Accounts,omitempty"`
NextToken string `json:"NextToken,omitempty"`
}
ListAccountsForParentOutput is its answer.
type ListClustersInput ¶
type ListClustersInput struct {
NextToken string `json:"nextToken,omitempty"`
}
ListClustersInput is a page of ECS clusters.
type ListClustersOutput ¶
type ListClustersOutput struct {
ClusterArns []string `json:"clusterArns,omitempty"`
NextToken string `json:"nextToken,omitempty"`
}
ListClustersOutput is its answer.
type ListOrganizationalUnitsForParentInput ¶
type ListOrganizationalUnitsForParentInput struct {
ParentID string `json:"ParentId"`
NextToken string `json:"NextToken,omitempty"`
}
ListOrganizationalUnitsForParentInput is a page of a parent's OUs.
type ListOrganizationalUnitsForParentOutput ¶
type ListOrganizationalUnitsForParentOutput struct {
OrganizationalUnits []OrganizationalUnit `json:"OrganizationalUnits,omitempty"`
NextToken string `json:"NextToken,omitempty"`
}
ListOrganizationalUnitsForParentOutput is its answer.
type ListRootsInput ¶
type ListRootsInput struct {
NextToken string `json:"NextToken,omitempty"`
}
ListRootsInput is a page of the organization's roots.
type ListRootsOutput ¶
type ListRootsOutput struct {
Roots []Root `json:"Roots,omitempty"`
NextToken string `json:"NextToken,omitempty"`
}
ListRootsOutput is its answer.
type ListServicesInput ¶
type ListServicesInput struct {
Cluster string `json:"cluster"`
NextToken string `json:"nextToken,omitempty"`
}
ListServicesInput is a page of a cluster's services.
type ListServicesOutput ¶
type ListServicesOutput struct {
ServiceArns []string `json:"serviceArns,omitempty"`
NextToken string `json:"nextToken,omitempty"`
}
ListServicesOutput is its answer.
type ListTagsForResourceInput ¶
type ListTagsForResourceInput struct {
ResourceID string `json:"ResourceId"`
NextToken string `json:"NextToken,omitempty"`
}
ListTagsForResourceInput is a page of an account's tags.
type ListTagsForResourceOutput ¶
type ListTagsForResourceOutput struct {
Tags []Tag `json:"Tags,omitempty"`
NextToken string `json:"NextToken,omitempty"`
}
ListTagsForResourceOutput is its answer.
type Listener ¶
type Listener struct {
ListenerArn string `json:"ListenerArn,omitempty"`
Port int `json:"Port,omitempty"`
Protocol string `json:"Protocol,omitempty"`
}
Listener is an ELBv2 listener.
type LoadBalancer ¶
type LoadBalancer struct {
LoadBalancerArn string `json:"LoadBalancerArn,omitempty"`
LoadBalancerName string `json:"LoadBalancerName,omitempty"`
Type string `json:"Type,omitempty"`
}
LoadBalancer is the part of an ELBv2 load balancer the scan reads.
type Metric ¶
type Metric struct {
Namespace string `json:"Namespace"`
MetricName string `json:"MetricName"`
Dimensions []Dimension `json:"Dimensions"`
}
Metric names a CloudWatch metric.
type MetricDataQuery ¶
type MetricDataQuery struct {
ID string `json:"Id"`
ReturnData bool `json:"ReturnData"`
MetricStat MetricStat `json:"MetricStat"`
}
MetricDataQuery is one query of GetMetricData.
type MetricDataResult ¶
type MetricDataResult struct {
ID string `json:"Id,omitempty"`
Values []float64 `json:"Values,omitempty"`
}
MetricDataResult is the values of one query.
type MetricStat ¶
type MetricStat struct {
Metric Metric `json:"Metric"`
Period int `json:"Period"`
Stat string `json:"Stat"`
}
MetricStat is a metric with its period and statistic.
type OrgAccount ¶
type OrgAccount struct {
ID string `json:"Id,omitempty"`
Name string `json:"Name,omitempty"`
State string `json:"State,omitempty"`
Status string `json:"Status,omitempty"`
}
OrgAccount is an account of the organization; State replaces the deprecated Status.
type OrgInventory ¶
OrgInventory is the organization's accounts and OU tree.
func LoadInventory ¶
func LoadInventory(ctx context.Context, org OrganizationsPort, tags bool) (OrgInventory, error)
LoadInventory reads the organization's OU tree and its active accounts, each with its OU path from the root; with tags, their tags too.
func LoadInventoryProgress ¶ added in v0.2.0
func LoadInventoryProgress(ctx context.Context, org OrganizationsPort, tags bool, progress func(InventoryProgress)) (OrgInventory, error)
LoadInventoryProgress is LoadInventory saying how far it is after each organizational unit (progress nil: silent).
type OrganizationalUnit ¶
type OrganizationalUnit struct {
ID string `json:"Id,omitempty"`
Name string `json:"Name,omitempty"`
}
OrganizationalUnit is an OU.
type OrganizationsPort ¶
type OrganizationsPort interface {
ListRoots(ctx context.Context, in ListRootsInput) (ListRootsOutput, error)
ListOrganizationalUnitsForParent(ctx context.Context, in ListOrganizationalUnitsForParentInput) (ListOrganizationalUnitsForParentOutput, error)
ListAccountsForParent(ctx context.Context, in ListAccountsForParentInput) (ListAccountsForParentOutput, error)
ListTagsForResource(ctx context.Context, in ListTagsForResourceInput) (ListTagsForResourceOutput, error)
}
OrganizationsPort is the read-only Organizations delegation.
type PairPlan ¶
type PairPlan struct {
Account string `json:"account"`
Region string `json:"region"`
Scan bool `json:"scan"`
Reason string `json:"reason"`
}
PairPlan says whether an account and region are scanned.
func TargetPairs ¶
func TargetPairs(cfg Config, inv OrgInventory, enabled map[string][]string) []PairPlan
TargetPairs says, for each account and region, whether it is scanned; enabled gives each account's enabled regions, for the regions ["*"].
type ProgressEvent ¶
type ProgressEvent struct {
Phase string `json:"phase"` // discovery, requests or uptime
Account string `json:"account"`
Region string `json:"region"`
From string `json:"from"` // cache or aws
Workloads int `json:"workloads"`
Error string `json:"error,omitempty"`
}
ProgressEvent says a region is done: where it came from (the cache or AWS), how many workloads it holds and why it failed, if it did. JSON names as Node's.
type RegionDiscovery ¶
type RegionDiscovery struct {
Account string
Region string
Workloads []Workload
Ineligible []IneligibleRule
Clusters []UnreadableCluster
Error string
Databases []Database
DatabasesError string
}
RegionDiscovery is what discovery kept of an account and region (the cache's value). Databases nil: not read (a file kept before the databases existed).
func All ¶
func All(ctx context.Context, o AllOptions) ([]RegionDiscovery, error)
All discovers every account's regions, the accounts at most Concurrency at a time, each account's regions one after the other. The regions come back in the organization's order, whatever finished first. A region that fails is a RegionDiscovery with its Error; an account that fails (not a refused role, already listed apart) is one with region "*". The error is the context's.
func Region ¶
func Region(ctx context.Context, ports RegionPorts, where Where) (RegionDiscovery, error)
Region discovers one account and region: the scan, the workloads described eight at a time in the scan's order, the clusters unreadable and the companion databases. A scan that fails (or a rule whose waker cannot be read) fails the region.
func (RegionDiscovery) MarshalJSON ¶
func (r RegionDiscovery) MarshalJSON() ([]byte, error)
MarshalJSON writes Node's shape: workloads and ineligible always arrays, clusters, error and databasesError only when there are some, databases when they were read (an empty array included).
func (*RegionDiscovery) UnmarshalJSON ¶
func (r *RegionDiscovery) UnmarshalJSON(b []byte) error
UnmarshalJSON reads the shape MarshalJSON writes (and the Node estimate's files).
type RegionEC2Port ¶
type RegionEC2Port interface {
stopped.EC2Port
DescribeSecurityGroups(ctx context.Context, in DescribeSecurityGroupsInput) (DescribeSecurityGroupsOutput, error)
}
RegionEC2Port is what a region's discovery reads of EC2: instances (with their state and security groups) and security groups.
type RegionPorts ¶
type RegionPorts struct {
// Scan is discovery's scan of the region (ScanRegion with the region's
// ports); its clusters the profile could not read are listed by Region.
Scan func(ctx context.Context) (ScanResult, error)
AutoScaling AutoScalingPort
ELBv2 RulesPort
EC2 RegionEC2Port
Stopped stopped.Ports
}
RegionPorts are what one region's discovery reads (Node's RegionPorts, which extends StoppedPorts): the scan, the Auto Scaling groups, a rule by ARN, EC2 (instances, security groups) and what a nap stops (ECS services, RDS instances and clusters, the clusters' clients). Stopped.RDS nil: the databases are not read. Stopped.EC2 and EC2 are the same client.
type Reservation ¶
type Reservation struct {
Instances []Instance `json:"Instances,omitempty"`
}
Reservation groups instances.
type Rule ¶
type Rule struct {
RuleArn string `json:"RuleArn,omitempty"`
Priority string `json:"Priority,omitempty"`
IsDefault bool `json:"IsDefault,omitempty"`
Conditions []Condition `json:"Conditions,omitempty"`
Actions []Action `json:"Actions,omitempty"`
}
Rule is an ELBv2 listener rule.
type RuleRef ¶
type RuleRef struct {
ID string `json:"id"` // rule ARN
Listener string `json:"listener"`
Priority string `json:"priority"`
Conditions string `json:"conditions"`
Hosts []string `json:"hosts"`
Managed bool `json:"managed"` // tagged dormeto:workload
}
RuleRef is a listener rule of a candidate.
type RulesPort ¶
type RulesPort interface {
DescribeRules(ctx context.Context, in DescribeRulesInput) (DescribeRulesOutput, error)
}
RulesPort is the ELBv2 call discovery makes beyond the scan: rules by ARN.
type ScanPorts ¶
type ScanPorts struct {
ELBv2 ELBv2Port
AutoScaling AutoScalingPort
EC2 EC2Port
ECS ECSPort
CloudWatch CloudWatchPort
Kubernetes *kubernetes.Ports
}
ScanPorts are the read-only calls of a scan. ELBv2 is required; a port left nil is one the scan does not read (no Auto Scaling groups, ECS services, idle hours, nodes or clusters). Kubernetes is the region's EKS clusters and their API.
type ScanResult ¶
type ScanResult struct {
Rules []ScannedRule `json:"rules"`
Clusters []kubernetes.Cluster `json:"clusters"`
}
ScanResult is a region's scan: its candidates in the scan's order and the region's clusters as read (the estimate lists those it cannot read).
func ScanRegion ¶
func ScanRegion(ctx context.Context, ports ScanPorts, where Where, now time.Time) (ScanResult, error)
ScanRegion scans an account and region. now gives the end of the idle window (the hour before it). A call that fails fails the scan, except the clusters' listing when the role lacks EKS rights (the region is scanned as before).
type ScannedRule ¶
type ScannedRule struct {
ID string `json:"id"`
Account string `json:"account"`
Region string `json:"region"`
LoadBalancer string `json:"loadBalancer"`
LoadBalancerArn string `json:"loadBalancerArn"`
Listener string `json:"listener"`
Priority string `json:"priority"`
Conditions string `json:"conditions"`
Hosts []string `json:"hosts"`
TargetGroup *string `json:"targetGroup"`
TargetGroupArn *string `json:"targetGroupArn"`
Backend *Backend `json:"backend"`
Tags map[string][]string `json:"tags"` // every value of each tag on the load balancer, the target group or the rule
Rules []RuleRef `json:"rules"`
Eligibility string `json:"eligibility"`
Reason string `json:"reason,omitempty"`
WorkloadID string `json:"workloadId,omitempty"`
IdleHours7d *int `json:"idleHours7d"`
Requests7d *int `json:"requests7d"`
}
ScannedRule is a candidate: an application target group with every rule forwarding to it (ID the target group ARN), or a rule that forwards to no single application target group (ID the rule ARN).
type SecurityGroup ¶
type SecurityGroup struct {
GroupId string `json:"GroupId,omitempty"`
IpPermissions []IpPermission `json:"IpPermissions,omitempty"`
}
SecurityGroup is a security group and its ingress rules.
type Service ¶
type Service struct {
ServiceArn string `json:"serviceArn,omitempty"`
LoadBalancers []ServiceLoadBalancer `json:"loadBalancers,omitempty"`
}
Service is the part of an ECS service the scan reads.
type ServiceLoadBalancer ¶
type ServiceLoadBalancer struct {
TargetGroupArn string `json:"targetGroupArn,omitempty"`
}
ServiceLoadBalancer is a service's load balancer attachment.
type TagDescription ¶
type TagDescription struct {
ResourceArn string `json:"ResourceArn,omitempty"`
Tags []Tag `json:"Tags,omitempty"`
}
TagDescription is the tags of a resource.
type TagWants ¶
type TagWants []TagWant
TagWants are the tags of a criterion, in the order the configuration lists them (the order of their description). It reads and writes a JSON object {"key": ["value", ...]}. A nil TagWants is a dimension the criterion does not set; an empty one is set, and asks for nothing.
func (TagWants) MarshalJSON ¶
MarshalJSON writes the object in order.
func (*TagWants) UnmarshalJSON ¶
UnmarshalJSON reads an object, keeping its key order.
type Target ¶
type Target struct {
Account string
Credentials func(ctx context.Context) (*aws.Credentials, error)
}
Target is a reached account and how to get its credentials (nil credentials: the profile's own).
type TargetDescription ¶
type TargetDescription struct {
ID string `json:"Id,omitempty"`
}
TargetDescription is a registered target.
type TargetGroup ¶
type TargetGroup struct {
TargetGroupArn string `json:"TargetGroupArn,omitempty"`
TargetGroupName string `json:"TargetGroupName,omitempty"`
TargetType string `json:"TargetType,omitempty"`
LoadBalancerArns []string `json:"LoadBalancerArns,omitempty"`
VpcId string `json:"VpcId,omitempty"`
}
TargetGroup is an ELBv2 target group.
type TargetHealthDescription ¶
type TargetHealthDescription struct {
Target TargetDescription `json:"Target"`
}
TargetHealthDescription is a target and its health.
type UnreadableCluster ¶
UnreadableCluster is an EKS cluster the profile cannot read, and why.
type UserIdGroupPair ¶
type UserIdGroupPair struct {
GroupId string `json:"GroupId,omitempty"`
}
UserIdGroupPair is a security group a rule names.
type ValuesConfig ¶
type ValuesConfig struct {
Values []string `json:"Values,omitempty"`
}
ValuesConfig holds the values of a host or path condition.
type Workload ¶
type Workload struct {
Account string `json:"account"`
Region string `json:"region"`
LoadBalancer string `json:"loadBalancer"`
LoadBalancerArn string `json:"loadBalancerArn"`
TargetGroup string `json:"targetGroup"`
TargetGroupArn string `json:"targetGroupArn"`
Hosts []string `json:"hosts"`
Backend WorkloadBackend `json:"backend"`
Stopped []stopped.Item `json:"stopped"`
// Every value of each tag on its load balancer, target group or rule.
Tags map[string][]string `json:"tags"`
// An instance's state when discovered (not one Dormeto manages).
InstanceState string `json:"instanceState,omitempty"`
// An ECS service's desired count when discovered (not one Dormeto manages).
EcsDesired *int `json:"ecsDesired,omitempty"`
// Already managed by Dormeto, with its waker target group when found.
Managed bool `json:"managed,omitempty"`
WakerTargetGroupArn string `json:"wakerTargetGroupArn,omitempty"`
// Its backend's security groups: a database letting one in is its companion.
SecurityGroups []string `json:"securityGroups"`
}
Workload is an eligible (or managed) workload of a region, described as the router would: what a nap stops, its tags and its security groups.
type WorkloadBackend ¶
WorkloadBackend is a workload's backend as kept: its kind and id.