Files
floci/src/main/java/io/github/hectorvent
Sam Fakhreddine ac94232910 feat(cloudformation): CodeBuild/CodePipeline CFN provisioning (#2685)
* feat(cloudformation): provision CodePipeline pipelines and actions

New CodePipelineCfnProvisioner handles AWS::CodePipeline::Pipeline,
AWS::CodePipeline::CustomActionType, and AWS::CodePipeline::Webhook by
lowering the PascalCase CloudFormation properties into the camelCase
CodePipeline API shapes and delegating to the service, so stacks and the
API produce identical pipelines.

Ref resolves to the pipeline name (generated CloudFormation-style when
Name is omitted), Fn::GetAtt Version and webhook Url are populated, an
existing physical ID routes updates through UpdatePipeline instead of
recreating, DisableInboundStageTransitions is applied after creation,
and deletes tolerate already-removed resources.

(cherry picked from commit 8007d0b7e872d573217309fccd756c66a2d339a4)

* fix(cloudformation): bundle cfn-response into inline ZipFile Lambdas

AWS injects the cfn-response (Node.js) and cfnresponse (Python) modules
into functions created through CloudFormation's inline ZipFile property,
and custom-resource handlers across AWS Solutions templates rely on
that — Landing Zone Accelerator's installer stack fails its very first
Custom::CreateUUID resource with 'Cannot find module cfn-response'
without it.

The bundled modules follow the documented AWS implementations but pick
the transport and port from the ResponseURL instead of hardcoding
https:443, because Floci's custom-resource callback URL is plain http
on the emulator's port.

(cherry picked from commit 7028f5a85daba6ba9d83032dc940cebe45c0b348)

* refactor(cloudformation): extract inline ZipFile packaging

CloudFormationResourceProvisioner is a monolith being dismantled, so the
cfn-response bundling added there moves to its own InlineZipPackager,
ready to travel with the eventual Lambda provisioner extraction. No
behavior change.

(cherry picked from commit d0d4bff84bda9c143606a8922500515dbe5bc0c0)

* fix(cloudformation): keep CodePipeline action config keys verbatim

Action and rule configuration maps carry provider-defined string keys
(Owner, Repo, ProjectName, ...) that executors match exactly; the
PascalCase-to-camelCase property transform was rewriting them, so
CloudFormation-created pipelines could never run their GitHub source or
CodeBuild actions. Configuration subtrees now pass through untouched.

(cherry picked from commit 213e33d9f005ee4df6a66272a91f47ac67a3b7a3)

* feat(cloudformation): provision CodeBuild projects

AWS::CodeBuild::Project was falling through to the stub path, so
CloudFormation-created pipelines referenced build projects that did not
exist — Landing Zone Accelerator's installer pipeline failed its
Install stage with 'Project not found'. The new provisioner lowers the
PascalCase properties into the CodeBuild API shape (including the
irregular all-lowercase buildspec field), supports update-in-place, and
exposes Ref as the project name and Fn::GetAtt Arn.

(cherry picked from commit 7d616b87c7fa58693537dfe7d9d86cd63437ea75)

* fix(codepipeline): correct three CFN provisioning bugs in CodePipelineCfnProvisioner

- DisableInboundStageTransitions is a declarative list: a stage removed from it on
  update must be re-enabled, not left disabled after UPDATE_COMPLETE.
- CustomActionType has no update operation; a change to Category/Provider/Version
  is a replacement (create the new identity, delete the superseded one) rather than
  a silent physicalId swap with no corresponding service call.
- Webhook's RegisterWithThirdParty must be read from the resolved/lowercased node,
  not the raw unresolved props, so intrinsics (Ref, Fn::If) are honored.

* fix(codebuild): convert the JSON handler's Map entity instead of dropping it

CodeBuildJsonHandler.handle(...) returns Response.ok(Map.of(...)), never a
JsonNode, so the instanceof check in CodeBuildCfnProvisioner.handle always
missed and silently fell back to an empty ObjectNode -- forcing the guessed
ARN fallback even when the handler returned the real project ARN. Convert
non-JsonNode entities with ObjectMapper.valueToTree, and close the Response.

* fix(cloudformation): UTF-8 encode the injected Python cfn-response callback body

http.client encodes a str request body as latin-1, raising UnicodeEncodeError
for any response Reason/Data containing non-Latin-1 characters and failing
the callback before it's sent. Encode the JSON body to UTF-8 bytes first.

* docs(cloudformation): merge the duplicate Lambda resource-type row

Two Lambda rows in the supported-resource-types table gave inconsistent
descriptions (one had Version/Alias, the other the cfn-response detail).
Consolidate into a single row.

* fix(codepipeline): fix stage-transition and rename bugs found in re-review

- Only re-enable stage transitions this stack previously disabled (tracked via a
  new __FlociCodePipelineDisabledStages attribute); a stage disabled externally
  (a manual gate, a human) and never listed in DisableInboundStageTransitions is
  no longer touched by an unrelated update.
- Pipeline Name has no rename operation in CodePipeline; a template Name that
  differs from the tracked physical ID is now treated as a replacement (create
  under the new name, delete the old one) instead of calling UpdatePipeline
  against a pipeline that doesn't exist or belongs to someone else.
- Webhook Name rename now deletes the previously-owned webhook after PutWebhook
  upserts under the new name, instead of orphaning it.

* fix(codepipeline): handle legacy stage tracking and failed-replacement cleanup

- A resource stored before __FlociCodePipelineDisabledStages existed has no
  tracking record; fall back to reconciling every declared stage on its first
  post-upgrade update instead of skipping reconciliation and leaving a removed
  entry disabled forever.
- If stage-transition reconciliation fails after a rename's replacement (or a
  fresh create) already succeeded, best-effort delete the just-created pipeline
  before rethrowing. CloudFormation reverts this resource to its previous
  physicalId on a failed update, so without this the new pipeline is orphaned
  and a corrected retry hits PipelineNameInUseException.
2026-08-28 20:23:18 -04:00
..