# Tidewater's Configuration Tree

> **Status:** Draft 0.2, 2026-11-23. Tidewater's whole Gravity Keep tree, as `show configuration` prints it after the sessions in this folder. Long resource bodies are shortened with `...`. Read with [Tree Model](../tree-model.md).

# The shape

```
/tidewater
  /tidewater/organization          management account: OUs, accounts, SCPs, tag policies
  /tidewater/gravity-keep       the control plane itself (protected, reviewed, confirmed)
  /tidewater/foundation/prod       Postgres, WAF, DNS, KMS, Verified Permissions
  /tidewater/lending/dev           Lending, development
  /tidewater/lending/prod          Lending, production: sourced from Git (lending/prod.conf)
  /tidewater/lending/prod/east     Lending, production, us-east-2
  /tidewater/lending/prod/west     Lending, production, us-west-2 (warm standby)
  /tidewater/payments/prod
  /tidewater/support/prod
  /tidewater/sandbox
```

# The tree

```
namespace tidewater {
    /* Company-wide: where things may live and what everything must have. */
    placement {
        organization o-tw7exampl3;
        region us-east-2;
    }
    guardrails {
        placement region in [ us-east-2 us-west-2 us-east-1 ];
        tags {
            application required;
            environment required;
            owner required;
            data-classification required;
            cost-center required;
        }
        s3.bucket {
            public-access-block-configuration {
                block-public-acls true;
                block-public-policy true;
                ignore-public-acls true;
                restrict-public-buckets true;
            }
            bucket-encryption required;
        }
        logs.log-group {
            kms-key-id required;
            retention-in-days minimum 731;    /* a guardrail since COMMIT-66, session 9 */
        }
        lambda.function {
            architectures in [ arm64 ];
        }
        rds.db-instance {
            storage-encrypted true;
            publicly-accessible false;
            deletion-protection true;
            destroy { deletion in [ retain snapshot ]; }
        }
        types deny [ ec2.instance ec2.key-pair ];
    }
    defaults {
        tags { cost-center 4100; owner platform-team; }
        s3.bucket {
            bucket-encryption {
                server-side-encryption-configuration {
                    server-side-encryption-by-default {
                        sse-algorithm aws:kms;
                        kms-master-key-id @/tidewater/foundation/prod/kms.key/data:arn;
                    }
                    bucket-key-enabled true;
                }
            }
        }
        logs.log-group {
            kms-key-id @/tidewater/foundation/prod/kms.key/logs:arn;
            retention-in-days 731;
        }
    }
    policy {
        drift remediate;
        deletion retain;
        commit confirmed required [ ec2.security-group ec2.network-acl wafv2.web-acl wafv2.ip-set iam.role ] minutes 10;
    }
    access {
        group platform-engineers { view; edit; commit; approve; adopt; hold; revert; }
        group on-call { view; hold; revert; }
        group auditors { view; }
    }
    templates {
        library gravity-standard {
            source git+https://github.com/tidewater/gravity-templates;
            version "~> 1.2";
        }
    }

    namespace organization {
        placement { account 111100000001; }
        binding { application foundation; environment production; data-classification internal; }
        policy { commit mode reviewed; protect; }
        resource organizations.organizational-unit workloads { name Workloads; parent-id r-tw01; }
        resource organizations.organizational-unit sandbox { name Sandbox; parent-id r-tw01; }
        resource organizations.account lending-dev {
            account-name tidewater-lending-dev;
            email aws+lending-dev@tidewater.example;
            parent-ids [ @../organizations.organizational-unit/workloads:id ];
        }
        resource organizations.account lending-prod { ... }
        resource organizations.account payments-prod { ... }
        resource organizations.account support-prod { ... }
        resource organizations.account sandbox { ... }
        resource organizations.policy deny-leave-and-disable-logging {
            type SERVICE_CONTROL_POLICY;
            target-ids [ @../organizations.organizational-unit/workloads:id ];
            content { ... }
        }
        resource organizations.policy tag-standard {
            type TAG_POLICY;
            target-ids [ r-tw01 ];
            content { ... }
        }
    }

    namespace gravity-keep {
        placement { account 111100000002; }
        binding { application keep; environment production; data-classification confidential; }
        policy {
            commit mode reviewed;
            commit confirmed required all minutes 10;
            protect;
        }
        resource rds.db-instance store { ... }
        resource apigatewayv2.api sessions { ... }
        namespace session { apply gs-lambda { memory 512; ... } }
        namespace reactor { apply gs-lambda { memory 1024; ... } }
        namespace action-runner { apply gs-lambda { memory 512; ... } }
        namespace sweeper { apply gs-lambda { memory 1024; timeout 900; ... } }
        apply gs-process { name converge; ... }
        apply gs-process { name revert; ... }
        /* One per managed account: trail forwarding and the reactor role. */
        namespace accounts {
            namespace lending-prod {
                placement { account 111100000021; }
                apply gk-managed-account { control-plane-bus @/tidewater/gravity-keep/events.event-bus/main:arn; }
            }
            ...
        }
    }

    namespace foundation {
        binding { application foundation; data-classification restricted; }
        namespace prod {
            placement { account 111100000010; }
            binding { environment production; }
            policy { commit mode reviewed; }
            resource kms.key data {
                description "Default key for data at rest";
                enable-key-rotation true;
                key-policy { ... }
            }
            resource kms.key logs { ... }
            resource kms.key pii {
                description "Per-tenant envelope encryption for PII";
                enable-key-rotation true;
                multi-region true;
                key-policy { ... }
                protect;
            }
            resource sns.topic lending-alarms { ... }
            resource sns.subscription lending-alarms-email { ... }
            resource wafv2.ip-set office {
                placement { region us-east-1; }
                scope CLOUDFRONT;
                ip-address-version IPV4;
                addresses [ 198.51.100.0/24 ];
            }
            resource wafv2.web-acl shared {
                placement { region us-east-1; }
                scope CLOUDFRONT;
                default-action { allow; }
                rules { ... }
            }
            resource route53.hosted-zone tidewater-com { name tidewater.com; }
            resource rds.db-instance foundation {
                engine postgres;
                engine-version 17;          /* major version held; AWS applies minor upgrades (version-prefix) */
                manage-master-user-password true;   /* the password lives in Secrets Manager, never in the tree */
                create { allocated-storage 200; }   /* storage autoscaling owns it after creation */
                destroy { deletion snapshot; final-snapshot-identifier tidewater-foundation-final; }
                db-instance-class db.r8g.large;
                multi-az true;
                ...
                protect;
            }
            resource verifiedpermissions.policy-store production { ... }
        }
    }

    namespace lending {
        binding { application lending; data-classification restricted; }
        defaults { tags { owner lending-team; } }
        access {
            group lending-engineers { view; edit; commit-request; }
        }
        /* Production is changed by pull request to Lending's file, loaded by Lending's pipeline. */
        source prod {
            git https://github.com/tidewater/infrastructure;
            branch main;
            file lending/prod.conf;
        }
        namespace dev {
            placement { account 111100000020; }
            binding { environment dev; }
            resource s3.bucket documents { bucket-name tidewater-lending-dev-documents; ... }
            namespace intake {
                apply gs-lambda {
                    version "~> 1.3.0";
                    memory 1024;
                    code s3://tidewater-artifacts/lending/intake/2.5.0-rc.2/bootstrap.zip;
                    log-key @/tidewater/foundation/prod/kms.key/logs;
                    alarm-topic @/tidewater/foundation/prod/sns.topic/lending-alarms;
                }
            }
        }
        namespace prod {
            placement { account 111100000021; }
            binding { environment production; }
            policy { commit mode reviewed; }
            namespace east {
                placement { region us-east-2; }
                resource s3.bucket documents {
                    bucket-name tidewater-lending-prod-documents;
                    versioning-configuration { status Enabled; }
                    replication-configuration { ... }
                }
                resource s3.bucket legacy-documents {
                    /* Adopted from Anchor Core's document export, COMMIT-31. */
                    adopt-from arn:aws:s3:::tidewater-legacy-documents;
                    bucket-name tidewater-legacy-documents;
                    ...
                }
                namespace intake {
                    apply gs-lambda {
                        version "~> 1.3.0";
                        memory 1024;
                        code s3://tidewater-artifacts/lending/intake/2.4.1/bootstrap.zip;
                        log-key @/tidewater/foundation/prod/kms.key/logs;
                        alarm-topic @/tidewater/foundation/prod/sns.topic/lending-alarms;
                    }
                }
                apply gs-application-stack {
                    subdomain lending;
                    web-acl @/tidewater/foundation/prod/wafv2.web-acl/shared;
                    zone @/tidewater/foundation/prod/route53.hosted-zone/tidewater-com;
                }
            }
            namespace west {
                placement { region us-west-2; }
                /* Warm standby: the same templates, scaled down. */
                namespace intake { apply gs-lambda { version "~> 1.3.0"; memory 512; ... } }
                resource s3.bucket documents-replica { bucket-name tidewater-lending-prod-documents-west; ... }
            }
        }
    }

    namespace payments {
        binding { application payments; data-classification restricted; }
        defaults { tags { owner payments-team; } }
        namespace prod { placement { account 111100000031; } binding { environment production; } ... }
    }

    namespace support {
        binding { application support; data-classification confidential; }
        defaults { tags { owner support-team; } }
        namespace prod { placement { account 111100000041; } binding { environment production; } ... }
    }

    namespace sandbox {
        placement { account 111100000090; }
        binding { application sandbox; environment dev; data-classification internal; }
        policy { ownership learning; deletion delete; }
        guardrails { types allow [ s3.bucket lambda.function iam.role logs.log-group dynamodb.table sqs.queue sns.topic ]; }
    }
}
```

# What to notice

- **Placement is stated once per account**, at the namespace that owns it. Region is stated once at the top and overridden only for `west`, the WAF, and anything CloudFront needs in `us-east-1`.
- **Encryption, public-access blocks, log retention, and arm64 are never written in an application namespace.** They come from `/tidewater`.
- **Tags are almost never written.** `application`, `environment`, and `data-classification` come from bindings, `owner` from the application namespace, and `cost-center` from the top.
- **`/tidewater/gravity-keep` manages its own trail forwarding and reactor role in every account**, so bringing an account under management is one commit there.
- **Lending's production namespace is sourced from Git**, declared at `/tidewater/lending`. Everything else is sourced in the control plane and copied to the export repository after every commit. `/tidewater/lending/prod` was handed to Git after the adoption in session 7, so its file carries `adopt-from` for the legacy bucket.
- **The sandbox runs the other way round**: it learns from the console instead of correcting it, deletions are real, and only a short list of types is allowed ([session 10](session-10-explore-learn-evict.md)).
