mirror of
https://github.com/floci-io/floci.git
synced 2026-12-06 11:38:06 -05:00
Organizations was one of the namespaces the request-resources table left unread ("a later batch"), so every request
of it was checked on *: a grant scoped to an account's or an OU's ARN never matched, a deny scoped to one never held,
and an aws:ResourceTag condition read nothing. organizations joins the table now, so each request is checked on the
resources the Service Reference gives its action, read from the request.
An Organizations ARN carries the organization's id beside the id a request gives
(account/o-<organization>/<account id>), so the table fills one variable of it and asks the service for the rest.
OrganizationsStoredResourceArns finds the account, OU, root or policy a request names by its id alone in the caller's
organization, as the caller's handler finds it, and a handshake where the caller sent it or receives it: the account
it invites, any account for an invitation by email naming none, which may claim it, and each member for one enabling
all features, as AcceptHandshake lets them act on it. It answers the tags Organizations keeps on an account,
root, OU, policy or resource policy, matched on the whole ARN without moving it, which an aws:ResourceTag condition
reads. The lookups of an OU or a policy by its id in an organization move into organizationalUnitIn and policyIn,
beside accountIn, which DescribeOrganizationalUnit's and DescribePolicy's handlers and the new lookups share.
An organization's resources belong to its management account, so a member's request on one is judged across
accounts, the organization's resource policy deciding beside the member's own policies, as the existing
OrganizationsResourcePolicyProvider already supplies it. A handshake's recipient acts on it on its own policies: an
invitee belongs to no organization, and AcceptHandshake and DeclineHandshake are no actions a delegation policy grants
(the Organizations User Guide's supported delegation policy actions). So a handshake the caller receives is reached in
the management account (reachedInItsAccount), as a RAM invitation is, and the provider supplies no delegation policy
for it.
TagResource, UntagResource and ListTagsForResource, and the calls naming a parent or a target by its id (ListChildren,
ListPoliciesForTarget), are checked on *, and AttachPolicy and DetachPolicy on the policy alone, as the generated table
reads them.
IamRequestResourceEnforcementIntegrationTest checks, in an organization of its own, that a grant on one account's ARN
reads it by its id and refuses another, that an aws:ResourceTag condition reads the tags of an OU, that a member's
read of an OU is refused on its own grant alone and allowed where the organization's resource policy grants it too,
and that the account the organization invites reads the handshake on its own policy naming the handshake's ARN, with
that resource policy in place, and is refused on another. OrganizationsServiceTest checks each lookup for a member,
the management account, an outsider, an invitee, a claimant of an invitation by email and the members receiving a
handshake enabling all features, and the stored tags of each kind, the resource policy among them, against another
management account, organization, kind or service.
217 lines
15 KiB
Markdown
217 lines
15 KiB
Markdown
# Organizations
|
|
|
|
**Protocol:** JSON 1.1 (`X-Amz-Target: AWSOrganizationsV20161128.*`)
|
|
**Endpoint:** `POST http://localhost:4566/`
|
|
|
|
Floci emulates the full AWS Organizations control plane: the organization and its root,
|
|
the organizational-unit tree, member accounts, policies of every type, tags, trusted
|
|
service access, delegated administrators, the organization resource policy, and the
|
|
invitation/handshake flow.
|
|
|
|
## Accounts are real Floci accounts
|
|
|
|
Floci resolves any 12-digit access key id straight to an AWS account, so an account created
|
|
by `CreateAccount` is immediately usable as a caller identity against every other service:
|
|
|
|
```bash
|
|
aws --endpoint-url http://localhost:4566 organizations create-organization --feature-set ALL
|
|
aws --endpoint-url http://localhost:4566 organizations create-account \
|
|
--email dev@example.com --account-name Dev
|
|
# ... then call as that account
|
|
AWS_ACCESS_KEY_ID=<new-account-id> AWS_SECRET_ACCESS_KEY=x \
|
|
aws --endpoint-url http://localhost:4566 organizations describe-organization
|
|
```
|
|
|
|
## Management account vs member accounts
|
|
|
|
Authorization mirrors AWS. Every mutating action is restricted to the **management account**
|
|
that called `CreateOrganization`, and returns HTTP 400 `AccessDeniedException` otherwise.
|
|
Member accounts can read the organization they belong to (`DescribeOrganization`, `ListRoots`,
|
|
`ListParents`, `DescribeAccount`, `DescribePolicy`), act on handshakes addressed to them, and
|
|
call `LeaveOrganization`. An account in no organization gets
|
|
`AWSOrganizationsNotInUseException`.
|
|
|
|
## Behaviour notes
|
|
|
|
- OU responses include `Path`, and account responses include a single-entry `Paths` array.
|
|
Both use the current organization/root/OU ancestry, include the resource ID and trailing slash,
|
|
and reflect account moves. Delegated-administrator responses retain their separate shape.
|
|
List rendering reuses request-local parent IDs rather than re-reading each selected resource.
|
|
Concurrent removals do not invalidate an already selected page; a stale row with an ancestor
|
|
that is no longer available is omitted only after confirming that the row was removed or moved.
|
|
- Management policy types include `INSPECTOR_POLICY`, `UPGRADE_ROLLOUT_POLICY`, `BEDROCK_POLICY`,
|
|
`S3_POLICY`, `NETWORK_SECURITY_DIRECTOR_POLICY`, and `GUARDDUTY_POLICY`. They use the existing
|
|
enable, create, attach, list, effective-policy, detach, delete, and disable flows. Policy content
|
|
is not validated against a per-type schema, and these policies do not configure the backing AWS services.
|
|
- The AWS-managed `p-FullAWSAccess` SCP is created with the organization and attached to the
|
|
root, every new OU and every new account. Detaching the last service control policy from a
|
|
target is rejected with `ConstraintViolationException`, as on AWS.
|
|
- A new root has no policy types enabled, whatever the feature set; `ListRoots` reports an
|
|
empty `PolicyTypes` until `EnablePolicyType` is called, and `CreatePolicy` / `AttachPolicy`
|
|
for a type that is not enabled fail with `PolicyTypeNotEnabledException`. SCPs only apply to
|
|
member accounts once `SERVICE_CONTROL_POLICY` is enabled. The deprecated
|
|
`AvailablePolicyTypes` on `DescribeOrganization` lists only `SERVICE_CONTROL_POLICY`, for an
|
|
`ALL` organization, as on AWS.
|
|
- A `CONSOLIDATED_BILLING` organization has no available policy types. `EnableAllFeatures`
|
|
promotes it to `ALL`; with no member accounts the handshake completes immediately. With member
|
|
accounts it stays `REQUESTED` until one of them calls `AcceptHandshake` — AWS requires *every*
|
|
member to approve, which Floci simplifies to the first acceptance.
|
|
- `CreateAccount` returns a `CreateAccountStatus` you can poll with
|
|
`DescribeCreateAccountStatus`, matching the asynchronous AWS contract. A duplicate email
|
|
produces `State=FAILED` with `FailureReason=EMAIL_ALREADY_EXISTS` rather than an error.
|
|
- As on AWS, `CreateAccount` preconfigures the account access role in the new member account:
|
|
the optional `RoleName` parameter names it, defaulting to `OrganizationAccountAccessRole`.
|
|
The role exists in the new account, its trust policy allows the management account
|
|
(`arn:<partition>:iam::<management-account-id>:root` to `sts:AssumeRole`), and it carries the
|
|
`AdministratorAccess` AWS-managed policy, so the management account can assume it immediately.
|
|
Accounts that join through `InviteAccountToOrganization` do not get the role, matching AWS.
|
|
A `RoleName` off the published pattern answers `InvalidInputException` with the reference's
|
|
`Reason` member (`INVALID_PATTERN`, or `INVALID_ROLE_NAME` for the reserved
|
|
`AWSServiceRoleFor` prefix), so SDK callers can read the cause.
|
|
- `CloseAccount` closes a member account at once, skipping the few minutes AWS holds it in
|
|
`PENDING_CLOSURE`. As on AWS during the 90-day post-closure period, the account stays in the
|
|
organization: `DescribeAccount`, `ListAccounts` and `ListAccountsForParent` report its `State` as
|
|
`CLOSED` and its legacy `Status` as `SUSPENDED`, and Account Management's `GetAccountInformation`
|
|
reports `CLOSED`. Closing it again fails with `AccountAlreadyClosedException`; registering it as a
|
|
delegated administrator, `RemoveAccountFromOrganization` and `LeaveOrganization` fail with
|
|
`ConstraintViolationException`. The post-closure period does not end in Floci, so the account
|
|
stays closed and keeps its resources.
|
|
- A request whose `Authorization` header, SigV4 presigned URL or S3 presigned POST form carries a
|
|
credential of a closed account (its 12-digit access key id, an IAM user's key, or a session in the
|
|
account) is refused, whether or not IAM enforcement is on. AWS documents that these calls fail but
|
|
not the error, so Floci answers as it does for a credential it does not recognize:
|
|
`InvalidClientTokenId` or `UnrecognizedClientException`, `InvalidAccessKeyId` on S3 and
|
|
`AuthFailure` on EC2.
|
|
- `DescribeEffectivePolicy` merges every policy of the requested type down the
|
|
root → OU → target chain, with the closest ancestor winning on conflicting keys. As on AWS,
|
|
the access-control types (`SERVICE_CONTROL_POLICY`, `RESOURCE_CONTROL_POLICY`) are rejected.
|
|
- A request member of the wrong JSON type, such as a `Tags` that is not a list or a string
|
|
`MaxResults`, fails with `SerializationException` before the operation runs, worded as DynamoDB's
|
|
deserializer words it (`Unexpected field type`, `STRING_VALUE cannot be converted to Integer`);
|
|
Organizations' own error and wording have not been measured. The request shapes are vendored in
|
|
`src/main/resources/aws/organizations-request-shapes.json`, generated by
|
|
`tools/aws/regen_organizations_shapes.py` from the botocore release pinned in
|
|
`tools/aws/requirements.txt`.
|
|
- Handshakes expire 15 days after they are created and report `EXPIRED` from then on.
|
|
- Organizations ARNs are global and carry no region:
|
|
`arn:aws:organizations::123456789012:organization/o-abc1234567`.
|
|
|
|
## Supported Actions
|
|
|
|
<!-- floci:actions:start -->
|
|
| Action | Description |
|
|
| --- | --- |
|
|
| `CreateOrganization` | Creates an organization with the calling account as the management account. |
|
|
| `DescribeOrganization` | Returns information about the organization the calling account belongs to. |
|
|
| `DeleteOrganization` | Deletes the organization; only the management account may remain in it. |
|
|
| `EnableAllFeatures` | Upgrades a consolidated-billing organization to all features via a handshake. |
|
|
| `ListRoots` | Lists the roots defined in the organization. |
|
|
| `CreateOrganizationalUnit` | Creates an OU under the specified root or parent OU. |
|
|
| `UpdateOrganizationalUnit` | Renames the specified organizational unit. |
|
|
| `DeleteOrganizationalUnit` | Deletes an organizational unit that contains no accounts or child OUs. |
|
|
| `DescribeOrganizationalUnit` | Returns information about the specified organizational unit. |
|
|
| `ListOrganizationalUnitsForParent` | Lists the OUs directly under the specified root or parent OU. |
|
|
| `ListParents` | Lists the parent of the specified account or organizational unit. |
|
|
| `ListChildren` | Lists the accounts or OUs directly under the specified root or parent OU. |
|
|
| `CreateAccount` | Creates a member account in the organization and returns its request status. |
|
|
| `CreateGovCloudAccount` | Creates a member account together with a linked AWS GovCloud (US) account. |
|
|
| `DescribeCreateAccountStatus` | Returns the status of an account-creation request. |
|
|
| `ListCreateAccountStatus` | Lists account-creation requests, optionally filtered by state. |
|
|
| `DescribeAccount` | Returns information about the specified member account. |
|
|
| `ListAccounts` | Lists every account in the organization. |
|
|
| `ListAccountsForParent` | Lists the accounts directly under the specified root or OU. |
|
|
| `ListAccountsWithInvalidEffectivePolicy` | Always returns an empty list; effective-policy validation is not modeled. |
|
|
| `MoveAccount` | Moves an account from one root or OU to another. |
|
|
| `RemoveAccountFromOrganization` | Removes a member account from the organization. |
|
|
| `LeaveOrganization` | Removes the calling member account from its organization. |
|
|
| `CloseAccount` | Closes a member account: its `State` becomes `CLOSED` and its credentials stop working. |
|
|
| `CreatePolicy` | Creates a policy of the specified type in the organization. |
|
|
| `UpdatePolicy` | Updates the name, description or content of a customer-managed policy. |
|
|
| `DeletePolicy` | Deletes a policy that is not attached to any target. |
|
|
| `DescribePolicy` | Returns a policy's summary and content. |
|
|
| `ListPolicies` | Lists the policies of the specified type in the organization. |
|
|
| `AttachPolicy` | Attaches a policy to a root, organizational unit or account. |
|
|
| `DetachPolicy` | Detaches a policy from a root, organizational unit or account. |
|
|
| `ListPoliciesForTarget` | Lists the policies of a given type attached directly to a target. |
|
|
| `ListTargetsForPolicy` | Lists the roots, OUs and accounts a policy is attached to. |
|
|
| `EnablePolicyType` | Enables a policy type on the specified root. |
|
|
| `DisablePolicyType` | Disables a policy type on the specified root. |
|
|
| `DescribeEffectivePolicy` | Returns the merged policy of the given type that applies to a target. |
|
|
| `TagResource` | Adds or overwrites tags on a root, OU, account, policy or resource policy. |
|
|
| `UntagResource` | Removes the specified tags from a root, OU, account, policy or resource policy. |
|
|
| `ListTagsForResource` | Lists the tags on a root, OU, account, policy or resource policy. |
|
|
| `EnableAWSServiceAccess` | Enables trusted access for an AWS service principal. |
|
|
| `DisableAWSServiceAccess` | Disables trusted access for an AWS service principal. |
|
|
| `ListAWSServiceAccessForOrganization` | Lists the service principals with trusted access enabled. |
|
|
| `RegisterDelegatedAdministrator` | Registers a member account as a delegated administrator for a service. |
|
|
| `DeregisterDelegatedAdministrator` | Removes a member account's delegated administrator role for a service. |
|
|
| `ListDelegatedAdministrators` | Lists the delegated administrators in the organization. |
|
|
| `ListDelegatedServicesForAccount` | Lists the services a member account is a delegated administrator for. |
|
|
| `PutResourcePolicy` | Creates or updates the organization's resource policy. |
|
|
| `DescribeResourcePolicy` | Returns the organization's resource policy. |
|
|
| `DeleteResourcePolicy` | Deletes the organization's resource policy. |
|
|
| `InviteAccountToOrganization` | Sends an invitation handshake to an account or email address. |
|
|
| `AcceptHandshake` | Accepts a handshake, joining the organization for an invitation. |
|
|
| `DeclineHandshake` | Declines a handshake addressed to the calling account. |
|
|
| `CancelHandshake` | Cancels an open handshake the calling account originated. |
|
|
| `DescribeHandshake` | Returns information about the specified handshake. |
|
|
| `ListHandshakesForAccount` | Lists the handshakes that involve the calling account. |
|
|
| `ListHandshakesForOrganization` | Lists the handshakes associated with the organization. |
|
|
<!-- floci:actions:end -->
|
|
|
|
With IAM enforcement on, each action is checked on the resources the AWS Service Authorization
|
|
Reference lists for it, read from the request. An account, OU, root, policy or handshake a request
|
|
names by its id alone is checked on the ARN its organization holds for it, such as
|
|
`arn:aws:organizations::<management account>:account/o-<organization id>/<account id>`, which carries
|
|
the organization's id beside the one the request gives: Floci finds it in the caller's organization,
|
|
and a handshake where the caller sent it or receives it (the account it invites, any account for an
|
|
invitation by email naming none, each member for one enabling all features). An organization's
|
|
resources belong to its management account, so a member's request on one is judged across accounts,
|
|
the organization's resource policy (`PutResourcePolicy`) deciding beside the member's own policies;
|
|
a handshake's recipient reads, accepts or declines it on its own policies alone, whatever that
|
|
policy grants. `TagResource`, `UntagResource` and `ListTagsForResource`, and the calls naming a
|
|
parent or a target by its id (`ListChildren`, `ListPoliciesForTarget`), are checked on `*`, and
|
|
`AttachPolicy` and `DetachPolicy` on the policy alone, as the generated table reads them. An
|
|
`aws:ResourceTag` condition reads the tags Floci keeps on an account, root, OU, policy or resource
|
|
policy.
|
|
|
|
## Configuration
|
|
|
|
| Environment variable | Default | Description |
|
|
| --- | --- | --- |
|
|
| `FLOCI_SERVICES_ORGANIZATIONS_ENABLED` | `true` | Enables the service |
|
|
| `FLOCI_SERVICES_ORGANIZATIONS_SCP_ENFORCEMENT_ENABLED` | `false` | When `true` (and IAM enforcement is enabled), attached service control policies participate in IAM policy evaluation |
|
|
| `FLOCI_SERVICES_ORGANIZATIONS_MANAGEMENT_ACCOUNT_EMAIL` | unset | Email reported for the organization's management account (`DescribeOrganization` master account, `ListAccounts`). Unset falls back to the built-in default |
|
|
| `FLOCI_STORAGE_SERVICES_ORGANIZATIONS_MODE` | inherits `FLOCI_STORAGE_MODE` | Storage mode override |
|
|
| `FLOCI_STORAGE_SERVICES_ORGANIZATIONS_FLUSH_INTERVAL_MS` | `5000` | Hybrid/WAL flush interval |
|
|
|
|
## SCP enforcement
|
|
|
|
With `FLOCI_SERVICES_IAM_ENFORCEMENT_ENABLED=true` and
|
|
`FLOCI_SERVICES_ORGANIZATIONS_SCP_ENFORCEMENT_ENABLED=true`, service control policies attached to
|
|
the root, OUs, and accounts participate in IAM policy evaluation: an action must be allowed at every
|
|
level of the account's chain, before the caller's identity policies are consulted. SCPs never grant
|
|
permissions on their own. See
|
|
[Service Control Policies (SCPs)](iam.md#service-control-policies-scps) for the evaluation order,
|
|
the account-root behaviour, and the cases that bypass enforcement.
|
|
|
|
The evaluation itself lives in the IAM enforcement layer — this service stores the policies and
|
|
resolves the chain, but with IAM enforcement off the flag has no effect.
|
|
|
|
## Example
|
|
|
|
```bash
|
|
aws --endpoint-url http://localhost:4566 organizations create-organization --feature-set ALL
|
|
|
|
ROOT_ID=$(aws --endpoint-url http://localhost:4566 organizations list-roots \
|
|
--query 'Roots[0].Id' --output text)
|
|
|
|
aws --endpoint-url http://localhost:4566 organizations create-organizational-unit \
|
|
--parent-id "$ROOT_ID" --name workloads
|
|
|
|
aws --endpoint-url http://localhost:4566 organizations create-account \
|
|
--email member@example.com --account-name "workload-account"
|
|
|
|
aws --endpoint-url http://localhost:4566 organizations list-accounts
|
|
```
|