Gravity Keep

05 · Supervision

Bringing resources in, and letting them go.

A resource is supervised when it's in the tree. Everything else in a managed account is listed as unmanaged and never touched. Four operations move resources across that line, and none of them creates or deletes anything in AWS.

Four operations

Three bring knowledge in. One lets go.

An area is a namespace's placement (its accounts and regions, inherited), narrowed by types, regions, and tags. Explore searches an area once; learning watches one continuously.

OperationDirectionScopeStarted byChanges in AWS
AdoptInOne named resourceA personTags only
ExploreInA targeted area, searched onceA personTags only, once committed
LearnInA namespace's area, as things happenCloudTrailTags only
EvictOutResources or a whole branchA personTags removed; nothing else

The inventory

Nothing unknown, and nothing unknown silently.

Every resource in a managed account and region is either in the tree or on the unmanaged list. The list needs only what a resource is (ARN, type, region, tags), not its properties, so it comes from an inventory source rather than from listing hundreds of types through Cloud Control.

The default is AWS Resource Explorer with an organization-wide index: no charge of its own, one search for every account. It is eventually consistent, so CloudTrail create events fill the gap between searches. No source covers every type, so show unmanaged names the types it can't see. AWS Config can be the source instead, where a company already runs it.

eric@tidewater> show unmanaged /tidewater/support/prod | match reporting
s3.bucket          tidewater-support-reports         project=reporting
lambda.function    nightly-ticket-export             project=reporting
iam.role           nightly-ticket-export-role        project=reporting
athena.work-group  support-reporting                 project=reporting
inventory  Resource Explorer, indexed as of 08:00
           not covered here: none of these types

Adopt and explore

Into a candidate first, then a commit.

adopt reads one existing resource into your candidate; explore does the same for everything unmanaged in a narrowed area. You remove what you don't want, then commit. Nothing is supervised until then.

Adopting changes nothing but tags. If a default or guardrail would change a resource, the commit is refused: state what exists, adopt it, and change it in a second commit. In an observed namespace a violation becomes a finding instead, because reporting reality is the point. Explore won't search a whole account unless you say all.

[edit /tidewater/support/prod/reporting]
eric@tidewater# explore tags { project reporting; }
searching the inventory ... 6 unmanaged resources
reading 6 resources through Cloud Control ... done
added to candidate:
  s3.bucket 2   lambda.function 1   iam.role 1
  athena.work-group 1   glue.database 1
eric@tidewater# commit check
  adopt    6   (observed: no change to AWS, tags included)
findings +2
  s3.bucket/tidewater-support-reports  AES256, not the data key

Learning

A branch that fills itself from what people do.

In a sandbox, the console is the main tool. A namespace set to ownership learning writes whatever happens in its area outside a commit into the tree: a new resource is adopted, a change is written into its statements, a deletion removes it. Each is a commit, crediting the person CloudTrail names. Commits still change AWS, as in an owned namespace.

policy ownershipCommits change AWSChanges made outside a commit
ownedYesRemediated or reported, by policy drift
learningYesWritten into the tree
observedNoReported; nothing is ever changed, not even tags

Learning areas never overlap, so a new resource lands in exactly one place, and learning is never allowed beneath a Git source, where changes would have nowhere to be written but the file.

Evict

The opposite of adopt.

When a branch moves to another tool, or to a vendor, its resources must keep running and Gravity Keep must stop supervising them. evict removes them from the tree and their Gravity Keep tags from AWS. It never deletes, snapshots, or changes anything else, so it needs no destructive acknowledgment.

A reference from what stays to what's evicted fails commit check. Beneath a Git source, where removing a resource from the file would delete it, eviction is two pull requests: destroy { deletion evict; }, then the removal.

[edit /tidewater/support/prod]
eric@tidewater# evict reporting
removed from candidate: 7 resources and the namespace, to be evicted
eric@tidewater# commit check
  evict    7   /tidewater/support/prod/reporting/*
               (left in AWS; managed-by and gravity-path removed)
  references  none from the rest of the tree

Deleting safely

Some things can't be put back by recommitting.

Removing a resource from the tree, or changing a property that forces a replacement, is destructive when the type is stateful or identity-bearing. A destructive change needs an acknowledgment whose count matches the plan, and is refused under commit confirmed, because a revert couldn't undo it.

Stateful

Buckets, databases, tables, keys, log groups, secrets, volumes. Losing one loses data. Hosted zones and Elastic IPs are on the list too: a new zone gets new name servers and breaks delegation at the registrar, and a new address is missing from every partner's allowlist. Stateful resources are retained by default when they leave the tree, and a rollback re-adopts them.

Identity-bearing

An IAM role's unique ID is what every resource policy naming it actually stores. Recreate the role, even with the same name, and those policies point at nobody. A security group's ID is held by other groups and by network interfaces outside the tree. Inside the tree, references heal; outside, commit check says it can't see who's affected.

What deletion means

The resource's destroy { } block, or else the namespace's policy deletion: retain, snapshot, delete, or evict. A KMS key's deletion is always scheduled, thirty days by default. protect blocks deletion, moves, and renames until a separate commit removes it.

The rules

Ownership and deletion.

  1. CTL-029

    A rollback is a new commit, and its plan states every stateful resource whose data it cannot restore.

  2. CTL-034

    Every resource of a type the inventory source covers, in a managed account and region, is either in the tree or listed as unmanaged, and the types it doesn't cover are listed too.

  3. CTL-035

    An unmanaged resource is never changed or deleted, and a commit that adopts a resource changes nothing in AWS but its tags.

  4. CTL-047

    A stateful resource removed from the tree is retained unless its destroy block or its namespace's deletion policy says otherwise, and a KMS key's deletion is always scheduled, never immediate.

  5. CTL-048

    A protected namespace or resource can't be deleted, moved, or renamed until a separate commit removes its protection.

  6. CTL-049

    A resource in an observed namespace is compared and its drift reported, but it is never changed, including its tags.

  7. CTL-076

    The list of what exists comes from an inventory source that covers every managed account and region at least daily, chosen by each implementation; reading managed resources stays with Cloud Control and the reactor.

  8. CTL-077

    A learning namespace writes resources created, changed, or deleted in its area outside a commit into the tree, as commits (or commit requests beneath a reviewed namespace) crediting the identity CloudTrail names; learning areas never overlap, and learning is never allowed beneath a Git source.

  9. CTL-078

    Eviction removes resources from the tree and their Gravity Keep tags from AWS, and changes nothing else; it never deletes.

  10. CTL-079

    Adopt and explore only add to a candidate (or print a fragment beneath a Git source), so nothing is supervised until a commit; explore needs a filter narrower than the namespace's placement, or an explicit all.