Files
floci/docs/services/cloudcontrol.md
T
Priamo GermosenandChuck Swanberg 543a236747 feat(cloudformation): provision Verified Permissions policy stores, templates and policies (#9162)
A template declaring AWS::VerifiedPermissions::PolicyStore, PolicyTemplate or Policy failed its stack
as unsupported, although Floci serves the API behind them. VerifiedPermissionsCfnProvisioner now
provisions the three over VerifiedPermissionsService.

A policy store answers Ref with its id and sets Arn, PolicyStoreId and EncryptionState; its schema is
put once the store stands, and deletion protection is turned on only after that, so a store whose
schema the Cedar sidecar refuses is still removed. A template answers Ref with
PolicyStoreId|PolicyTemplateId and a policy with its id alone, as the Template Reference documents
each; a policy's store is found from its id, and Cloud Control names a policy
PolicyId|PolicyStoreId. PolicyStoreId is create-only on both, and a template or a policy is replaced
in the new store when the engine says the update replaces it. A schema, Description,
DeletionProtection or Name the template drops is cleared, what the stack never declared is left as
the service has it, and a create leaves out an optional field the template does not give. An update
of a stack from before this provisioner, which holds the dispatcher's stub, creates the entity.

An in-place change of a store, a template or a static policy is snapshotted first, so a step that
fails is undone and a later resource failing the update puts it back. A store's settings are
written before its schema, its tags are reconciled only over the keys the stack owns, and a change
of its EncryptionSettings is refused, since Verified Permissions sets encryption at create. Cloud
Control's model names a store by PolicyStoreId and a template by PolicyTemplateId.

Co-authored-by: Chuck Swanberg <cswanberg@mad-swan.com>
2026-11-21 19:47:19 -04:00

68 lines
4.0 KiB
Markdown

# Cloud Control API
**Protocol:** JSON 1.1 (`X-Amz-Target: CloudApiService.*`)
**Endpoint:** `POST http://localhost:4566/`
Cloud Control provides a uniform CRUD(L) surface over CloudFormation resource types
(`AWS::S3::Bucket`, `AWS::EC2::Instance`, ...) instead of a bespoke API per service.
Floci's emulator reuses the same resource provisioner CloudFormation stacks call, so a
resource behaves consistently whether it's provisioned by a stack or directly through
Cloud Control.
## Supported Operations
| Operation | Description |
| --- | --- |
| `CreateResource` | Provision a resource of the given `TypeName` from a `DesiredState` JSON document |
| `DeleteResource` | Delete a resource by `TypeName` and `Identifier` |
| `GetResource` | Read a resource's current properties by `TypeName` and `Identifier` |
| `ListResources` | List resources of a `TypeName` |
| `GetResourceRequestStatus` | Poll a `CreateResource`/`DeleteResource` request by its token |
## Behavior
- **Asynchronous create/delete**: `CreateResource` returns an `IN_PROGRESS` `ProgressEvent`
and a request token immediately; provisioning runs in the background. Poll
`GetResourceRequestStatus` with the token until the status is `SUCCESS` or `FAILED`.
`DeleteResource` is synchronous (deletes are fast enough not to need polling) but
still returns a `ProgressEvent` for API-shape consistency.
- **Create backpressure**: creates run on 4 workers with room for 64 more queued, both
set in [Configuration](#configuration). This is a Floci limit, not an AWS quota. A
`CreateResource` beyond that fails with `ThrottlingException` (HTTP 400) and no
request token; the AWS SDKs retry it automatically. Outside `memory` storage mode,
creates still `IN_PROGRESS` when Floci stopped are replayed on the next start, even
past that limit.
- **`ListResources` / `GetResource` type coverage**: the read side lists
`AWS::S3::Bucket`, `AWS::EC2::VPC`, `AWS::EC2::Subnet`, `AWS::EC2::SecurityGroup`,
`AWS::EC2::Instance`, `AWS::EC2::LaunchTemplate`, `AWS::IAM::Role`, `AWS::IAM::User`,
and `AWS::IAM::InstanceProfile`. `CreateResource` accepts any type the underlying
CloudFormation resource provisioner supports (the same set stacks can provision),
which is broader than the read side. A resource created through Cloud Control but
outside the read-side type list is still readable via `GetResource`, from
create-time state, but will not appear in `ListResources`.
- **`ListResources` on an unlisted type**: `TypeName` values outside the list above
fail with `UnsupportedActionException` (HTTP 400) instead of returning an empty
`ResourceDescriptions`. This applies to any type Floci does not enumerate on the
read side, whether or not the type is real in AWS, since Floci has no CloudFormation
type registry to tell the two apart.
- **Identifiers**: a resource is identified by its type's primary identifier, which for
most types is the physical id CloudFormation's `Ref` returns. A compound one joins its
parts with `|`, as Cloud Control does: an `AWS::ApiGatewayV2::ApiMapping` is
`<ApiMappingId>|<DomainName>` and an `AWS::VerifiedPermissions::Policy`
`<PolicyId>|<PolicyStoreId>`.
- **Delete needs create-time state**: types whose delete depends on attributes
captured at create time (currently `AWS::EKS::Nodegroup` and `AWS::IAM::Policy`, plus
any `Custom::*` / `AWS::CloudFormation::CustomResource`) fail `DeleteResource` with a
clear error if that state isn't held, rather than reporting `SUCCESS` over a resource
that's still there.
- **No account context**: Cloud Control requests don't carry an account id; Floci uses
its default test account (`000000000000`) for all resources.
## Configuration
| Variable | Default | Description |
|---|---|---|
| `FLOCI_SERVICES_CLOUDCONTROL_ENABLED` | `true` | Enable or disable the service |
| `FLOCI_SERVICES_CLOUDCONTROL_CREATE_WORKER_THREADS` | `4` | Threads that run `CreateResource` provisioning |
| `FLOCI_SERVICES_CLOUDCONTROL_CREATE_QUEUE_CAPACITY` | `64` | Creates that may wait for a free thread; past that a new `CreateResource` fails with `ThrottlingException` |