Skip to content

fix(cloudformation): provision AWS::CodeDeploy::Application - #8882

Merged
pgermosen merged 13 commits into
floci-io:mainfrom
cvent:fix/cfn-codedeploy-application
Nov 21, 2026
Merged

pgermosen merged 13 commits into
floci-io:mainfrom
cvent:fix/cfn-codedeploy-application

Conversation

@jonathanmorley

@jonathanmorley jonathanmorley commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

AWS::CodeDeploy::Application had no provisioner, so it fell through to the generic stub: the stack reported CREATE_COMPLETE with a random physical id and no application existed in CodeDeploy.

This adds CodeDeployCfnProvisioner, which wraps CodeDeployService:

  • Create calls CreateApplication with ApplicationName (or a generated name, max 100 characters), ComputePlatform (default Server) and Tags.
  • Ref returns the application name. The registry schema has no readOnlyProperties, so there is no Fn::GetAtt attribute.
  • Update changes tags on the same application, since ApplicationName and ComputePlatform are create-only. Only the tag keys the stack's templates set are managed, so a tag added outside the stack stays. The tags are snapshotted first and rolled back when a later resource fails.
  • Changing ComputePlatform replaces an unnamed application and is refused for a named one, as CloudFormation does.
  • A stack created before this provisioner, or while CodeDeploy was disabled, holds the dispatcher's stub. Its next update creates the application instead of retagging one that does not exist, and a rollback restores the stub.
  • An update whose application was deleted outside the stack creates it again, and a rollback of that update deletes it.
  • Delete removes the application and tolerates ApplicationDoesNotExistException.

It also changes two CodeDeploy API behaviors in CodeDeployService:

  • CreateApplication validates its input as the API reference specifies. It answers 400 ApplicationNameRequiredException for a missing or empty name (previously a NullPointerException), 400 InvalidApplicationNameException for a name over 100 characters or outside [A-Za-z0-9+=,.@_-], and 400 InvalidComputePlatformException for a platform other than Server, Lambda, ECS or Kubernetes.
  • DeleteApplication deletes the application's deployment groups with it, as on AWS, and drops the tags of the application and its groups, so an application created again under the same name starts with no groups and no tags.

Also: inventory row, CfnProvisionerFixture wiring, schema-surface.tsv and create-only-properties.json regenerated (only this type changed), docs table via make docs-sync, and ProvisionContext.resolveOptionalWritten, shared with resolveOptionalInt and resolveOptionalBigInteger.

Closes #8626

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

AWS Compatibility

Incorrect behavior: CreateStack with an AWS::CodeDeploy::Application reached CREATE_COMPLETE, but GetApplication returned ApplicationDoesNotExistException and Ref was a random stub id rather than the application name. On the CodeDeploy API, CreateApplication stored any name and compute platform, and DeleteApplication left the application's deployment groups and tags behind for the next application of that name.

Now the application exists with the template's ComputePlatform and tags, and Ref is the name. An UpdateStack that changes tags updates the same application and leaves tags set outside the stack alone, and an update whose later resource fails puts the tags back. An UpdateStack that changes ComputePlatform replaces an unnamed application with a new name and deletes the old one, and DeleteStack removes it. A blank ApplicationName or ComputePlatform written into the template fails the stack with CodeDeploy's error.

Behavior follows the AWS::CodeDeploy::Application registry schema (create-only ApplicationName/ComputePlatform, tag-only update handler, no read-only properties) and the CodeDeploy CreateApplication API reference. CodeDeployApplicationCfnIntegrationTest checks it through the SDK with CfnTestStack and reads the applications back over the CodeDeploy wire API.

Checklist

  • ./mvnw test passes locally (ran the CodeDeploy, CloudFormation provisioner and Cfn*Test suites, 3511 tests; not the full suite)
  • New or updated integration test added
  • Commit messages follow Conventional Commits
  • I have no more than 2 open, non-draft pull requests and no more than 4 open pull requests in total (drafts included) in this repository (maintainers and dependency bots are exempt).

The type had no provisioner, so the stack stub reported CREATE_COMPLETE
and no application existed. CodeDeployCfnProvisioner creates the
application with its ComputePlatform and Tags, returns the name for Ref,
reconciles tags on update, replaces on a create-only change and deletes
the application with the stack.

Closes floci-io#8626
@github-actions

Copy link
Copy Markdown

🎉 Thanks for your first pull request to Floci!

Your CI checks need a maintainer to approve them before they run. That is GitHub's standard gate on first-time contributors, not a problem with your PR — so if the checks look like they are doing nothing, that is why. Once a maintainer approves, CI and the compatibility suite start automatically. Nothing is needed from you in the meantime.

While you wait, a couple of things that make review faster:

  • Link the issue this fixes with Closes #N in the description
  • Commits follow Conventional Commits (feat(s3): ..., fix(dynamodb): ...)
  • Behaviour changes come with a test — see CONTRIBUTING.md

Come join us in Slack — it is the fastest way to reach maintainers if you get stuck, or want feedback on an approach before investing more time in it.

@qodo-code-review

qodo-code-review Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Provision CodeDeploy applications through CloudFormation

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Replace stubbed CodeDeploy applications with real resources whose Ref returns the application
 name.
• Reconcile tags, replace applications when create-only properties change, and clean up on deletion
 or rollback.
• Add unit and API integration tests, resource inventory entries, and documentation.
Merge Risk 🟡 Medium

Blast radius 🟡 Medium 💥 2 capabilities

  • 2 affected capabilities within one bounded functional scope: CodeDeploy application integration.
  • The provisioner, CodeDeploy application store, application tags, and CloudFormation Ref/replacement behavior jointly implement one bounded outcome: managing a CodeDeploy application from a CloudFormation stack.
  • These are propagation hops of the same application lifecycle, not independent capabilities.
  • Application deletion and removal of its dependent deployment groups/tags are one bounded CodeDeploy application lifecycle outcome.
  • Deployment-group records are downstream persistent state of the deleted application, not an independent functional scope.
Behavioral complexity 🔴 High 🧩 Multiple interactions

  • Before: AWS::CodeDeploy::Application was not provisioned as a real CodeDeploy application, and the existing CloudFormation flow did not coordinate application identity, create-only replacement, stack-owned tag sets, stub migration, and rollback state for this type.
  • After: the new path distinguishes create, reuse, vanished-application recreation, replacement, stub migration, in-place tag updates, commit, rollback, and delete.
  • New correctness conditions: the physical ID and CodeDeploy application must remain aligned across replacement and rollback; stack-owned tags must be distinguished from externally added tags; a created-during-update application must be deleted only when rollback requires it; and persisted snapshots must remain available until restoration succeeds.
  • The optional-property helper change reuses the prior absent-value rule and does not independently introduce algorithmic complexity.
Potential damage 🟡 Medium 🩹 Recoverable

  • The affected capability can be unavailable or incorrectly represented in the stack until the stack update is retried or rolled back.
  • Reverting code does not automatically repair an already-created or retagged CodeDeploy application; state repair may require a successful CloudFormation rollback/update or manual CodeDeploy cleanup.
  • The changed path does not show an irreversible external business effect beyond application and tag state.
  • Usually recoverable through CloudFormation retry/rollback when the application and rollback metadata remain reachable.
  • If rollback metadata or the CodeDeploy application is missing, manual reconciliation of the application, tags, and stack resource state is required.
Assessed commit 82a0186
Diagram

graph TD
  Stack["CloudFormation stack"] --> Registry["Resource registry"] --> Provisioner["CodeDeploy provisioner"] --> Change{"Property change?"}
  Change -->|Create or replace| Service["CodeDeploy service"] --> Store["Application storage"]
  Change -->|Tags only| Service
  Provisioner -->|Lifecycle hooks| Cleanup["Replacement cleanup"] -->|Delete displaced resource| Service
Loading
High-Level Assessment

Keep the dedicated provisioner: it follows the existing registry and replacement-cleanup patterns while reusing CodeDeployService. Renaming applications through the service instead would not model CloudFormation's create-only replacement behavior.

Files changed (9) +550 / -0

Bug fix (1) +120 / -0
CodeDeployCfnProvisioner.javaProvision CodeDeploy applications through their full lifecycle +120/-0

Provision CodeDeploy applications through their full lifecycle

• Creates applications with resolved names, compute platforms, and tags; uses the name as the physical ID for Ref. Reconciles tags in place, handles create-only replacements and rollback cleanup, and tolerates deletion of an already-absent application.

src/main/java/io/floci/aws/services/cloudformation/provisioners/CodeDeployCfnProvisioner.java

Tests (5) +423 / -0
CfnProvisionerFixture.javaWire CodeDeploy into CloudFormation test fixtures +11/-0

Wire CodeDeploy into CloudFormation test fixtures

• Lets fixture builders supply CodeDeployService and infer the new provisioner.

src/test/java/io/floci/aws/services/cloudformation/CfnProvisionerFixture.java

CodeDeployApplicationCfnIntegrationTest.javaVerify application lifecycle through CloudFormation and CodeDeploy APIs +167/-0

Verify application lifecycle through CloudFormation and CodeDeploy APIs

• Checks creation, Ref values, compute platforms, tags, in-place retagging, unnamed replacement, and stack deletion against wire APIs.

src/test/java/io/floci/aws/services/cloudformation/CodeDeployApplicationCfnIntegrationTest.java

CodeDeployCfnProvisionerTest.javaCover provisioner updates, replacements, and deletion +243/-0

Cover provisioner updates, replacements, and deletion

• Tests generated and explicit names, tag reconciliation, replacement refusal and cleanup, rollback, and idempotent deletion with a mocked CodeDeployService.

src/test/java/io/floci/aws/services/cloudformation/provisioners/CodeDeployCfnProvisionerTest.java

schema-surface.tsvRecord the CodeDeploy application schema surface +1/-0

Record the CodeDeploy application schema surface

• Adds ApplicationName, ComputePlatform, and Tags to the resource schema fixture, with no GetAtt attributes.

src/test/resources/cloudformation/schema-surface.tsv

supported-resource-types.tsvRegister CodeDeploy Application in the supported-type inventory +1/-0

Register CodeDeploy Application in the supported-type inventory

• Maps AWS::CodeDeploy::Application to CodeDeployCfnProvisioner in the inventory fixture.

src/test/resources/cloudformation/supported-resource-types.tsv

Documentation (1) +1 / -0
cloudformation.mdList CodeDeploy Application as a supported resource +1/-0

List CodeDeploy Application as a supported resource

• Adds CodeDeploy Application to the CloudFormation resource support table.

docs/services/cloudformation.md

Other (2) +6 / -0
create-only-properties.jsonDeclare CodeDeploy application create-only properties +4/-0

Declare CodeDeploy application create-only properties

• Marks ApplicationName and ComputePlatform as requiring replacement when changed.

src/main/resources/cloudformation/create-only-properties.json

cfn_resource_types.yamlConfigure CodeDeploy for generated resource documentation +2/-0

Configure CodeDeploy for generated resource documentation

• Adds CodeDeploy to the documentation order and service-label mappings.

tools/docs/cfn_resource_types.yaml

@qodo-code-review

qodo-code-review Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Tag updates can block stack rollback ✓ Resolved

Resolving commit: 9ac0f57

Resolution reason
Added a persisted tag snapshot (SNAPSHOT_ATTR) captured before an in-place tag update;
rollbackUpdate now restores the snapshotted tags when ReplacementCleanup.rollback returns false,
consumes the snapshot only after a successful restore, and completeUpdate/clearUpdate remove the
snapshot. Tests cover rollback of an in-place update and that committed updates have nothing to roll
back.
Description
rollbackUpdate delegates only to ReplacementCleanup.rollback, which returns false for an
in-place tag update and does not restore its previous tags. If another resource fails later in the
same stack update, the rollback walker marks this application UPDATE_FAILED and leaves the new
tags in CodeDeploy.

2. Existing stacks still lack applications ✓ Resolved

Resolving commit: 9ac0f57

Resolution reason
Stub updates now detect the stub via CfnResourceDispatcher.isStub and take the createApplication
path instead of the tag-reconciliation path, with the migration recorded in ReplacementCleanup so
rollback deletes the new application and restores the stub; regression tests added for stub update
and rollback.
Description
provision treats an unnamed stub's prior physical ID as an existing application and takes the
tag-reconciliation branch without calling createApplication. When a stack created before this fix
updates without changing a create-only property, it can report UPDATE_COMPLETE while
GetApplication still fails for its reference.


Remediation recommended

3. Deleted applications leave tags behind ✓ Resolved

Resolving commit: 9ac0f57

Resolution reason
deleteApplication now removes the application's tag-store entry (keyed by its ARN) after deleting
the application, so a subsequently created application with the same name has no leftover tags. A
regression test covers delete-then-recreate without tags.
Description
delete removes the application through CodeDeployService.deleteApplication, but that service
method does not remove the separate tag entry keyed by its ARN. After a tagged stack application is
deleted, creating an application with the same explicit name and no tags exposes the previous
application's tags through ListTagsForResource.

4. Invalid application settings reach creation ✓ Resolved

Resolving commit: 9ac0f57

Resolution reason
The commit adds validation in CodeDeployService.createApplication: a null/empty name throws
ApplicationNameRequiredException, names failing the 1-100 char pattern [A-Za-z0-9+=,.@_-] throw
InvalidApplicationNameException, and computePlatform outside Server/Lambda/ECS/Kubernetes throws
InvalidComputePlatformException. The provisioner now uses resolveOptionalWritten so a literal blank
name is kept and forwarded to be rejected instead of silently generating a name, and the
ComputePlatform/ApplicationName validation is covered by new tests. This addresses the blank-name,
overlong-name, and unsupported-platform complaints, though via service-level validation rather than
the provisioner-level check the fix prompt suggested.
Description
provision treats an explicitly blank ApplicationName as absent and forwards other explicit names
and nonblank ComputePlatform values without validating their permitted forms. A template with an
empty name gets an unexpected generated application, while an overlong name or unsupported platform
can be stored successfully because CodeDeployService.createApplication performs no corresponding
checks.

Grey Divider

Context sources
✅ Compliance rules (platform): 15 rules
✅ Web pages:
  +2 more
✅ Cross-repo context — repo relationships
Review mode: Auto: ⚖️ Balanced: Downgraded extended -> standard: change is below the extended eligibility bar (hunks 14/18, lines 550/200; both must reach the floor). Router rationale: Confidence 3/5: multiple replacement, tagging, lifecycle, and integration paths warrant redundant review.

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@pgermosen pgermosen added bug Something isn't working cloudformation AWS CloudFormation codedeploy AWS CodeDeploy labels Nov 18, 2026
@pgermosen

Copy link
Copy Markdown
Member

@jonathanmorley welcome, and thanks for opening #8626 first. Ref and the create-only handling match the schema. Three things before it goes in:

A stack created before this provisioner, or while CodeDeploy was off, holds the dispatcher's stub, so an update takes reusesPriorEntity and tags an application that doesn't exist. Could it create the application when CfnResourceDispatcher.isStub says so, as KmsCfnProvisioner does?

reconcileTags repeats CfnRollback.reconcileTags. Could it use that, snapshotting the tags first as KmsCfnProvisioner does, so rollbackUpdate can put them back when a later resource fails?

The integration test builds its own CreateStack, UpdateStack and DescribeStacks calls, which CfnTestStack already does through the SDK, cleanup included.

@pgermosen pgermosen added the waiting-author Review posted; waiting on the PR author to respond label Nov 18, 2026
DeleteApplication removed the application but left its tag entry, so an
application created again under the same name answered ListTagsForResource
with the old tags. Deleting a deployment group already drops its tags.
CreateApplication stored any name and compute platform, and a missing name
failed with a NullPointerException. It now answers as the CodeDeploy API
reference specifies: ApplicationNameRequiredException for a missing or
empty name, InvalidApplicationNameException for one over 100 characters
or outside [A-Za-z0-9+=,.@_-], and InvalidComputePlatformException for a
platform other than Server, Lambda, ECS or Kubernetes.

For AWS::CodeDeploy::Application, a blank ApplicationName or
ComputePlatform written into the template reaches CodeDeploy and fails the
stack, instead of silently generating a name or defaulting the platform.
One that resolves to AWS::NoValue is still absent.
… finds a stub

A stack created before AWS::CodeDeploy::Application had a provisioner, or
while CodeDeploy was disabled, holds the dispatcher's stub. An update that
kept the stub's id took the in-place path and retagged an application that
did not exist. Like KmsCfnProvisioner, it now checks
CfnResourceDispatcher.isStub and creates the application, dropping the
stub's Arn; a rollback deletes the new application and restores the stub.
An in-place update of AWS::CodeDeploy::Application changes only tags, but
rollbackUpdate covered replacements alone: when a later resource failed the
stack update, the new tags stayed and the application was reported
UPDATE_FAILED. Like KmsCfnProvisioner, the update now snapshots the tags it
is about to change, runs inside CfnRollback.guarded and reconciles through
CfnRollback.reconcileTags, and rollbackUpdate puts the snapshot back.

Only the keys the stack's templates set are managed, so a tag added outside
the stack now survives an update, as on AWS.
…fnTestStack

The integration test built its own CreateStack, UpdateStack and
DescribeStacks requests. It now creates and updates the stack through the
SDK with CfnTestStack, which also deletes it after the test, and adds an
update whose later resource fails, checking the application's tags come
back.
…sionContext

CodeDeployCfnProvisioner repeated resolveOptionalInt's check that keeps a
blank written into the template but treats one an intrinsic resolves to as
absent, and dropped its note that a Ref to a blank parameter cannot be told
apart from AWS::NoValue. Both now use ProvisionContext.resolveOptionalWritten,
which carries that note.
…r CodeDeploy

An update over a dispatcher stub whose template names the application
creates that name, drops the stub's Arn and deletes nothing when it
commits; a rollback deletes the new application and restores the stub.
clearUpdate drops the tag snapshot, leaving nothing for rollbackUpdate.
DeleteApplication removed the application but kept its deployment groups
and their tags, so an application created again under the same name listed
the old groups. On AWS, deleting an application deletes its deployment
groups; the groups and their tags are now removed with it.
…ploy provisioner test

CodeDeployCfnProvisionerTest built its own mocked template engine;
ProvisionContexts.passthroughEngine is the shared one provisioner tests use.
…s gone

The in-place update path assumed the prior application still existed and
only reconciled its tags, so an application deleted outside the stack
stayed gone while the update reported success. Like KmsCfnProvisioner, the
update now reads the application first; when it is gone it creates it and
records that with CfnRollback.recordCreatedByUpdate, so a rollback deletes
it again. Any failure other than not-found propagates.
Upstream extracted the same written-blank check as a private
resolveOptionalNumber, now also used by resolveOptionalBigInteger. Keep a
single check: both callers use the public resolveOptionalWritten, which
CodeDeployCfnProvisioner also needs, and keep both new ProvisionContextTest
methods.

@pgermosen pgermosen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanmorley thanks, this is ready: the merge leaves one written-blank check, resolveOptionalWritten, shared with the numeric resolvers; an update that finds the application gone creates it again and its rollback deletes it; and deleting an application now takes its deployment groups and their tags with it, as the CodeDeploy guide says ("including all related deployment group information").

(follow-up, separate PR)

  • The same sentence covers "deployment details", but an application's deployments stay behind, so ListDeployments on a recreated application of the same name still returns the old ones.
  • createApplication repeats getApplication's ApplicationNameRequiredException and InvalidApplicationNameException throws, which could come from one helper.

@pgermosen pgermosen removed the waiting-author Review posted; waiting on the PR author to respond label Nov 20, 2026
@jonathanmorley

Copy link
Copy Markdown
Contributor Author

Thanks! The two red checks look unrelated: the CloudFormation schema drift check fails on main too (AWS schema changes since the 16 Nov sync: Route 53, S3 Vectors, API Gateway authorizers, Bedrock AgentCore), and shard 1 is a one-off IMDS read timeout in AutoScalingConfigurationUserDataIntegrationTest. Could you re-run shard 1? Happy to open the schema resync as a separate chore PR if that helps. I'll follow up separately on deployments surviving a same-name recreate and the shared name check.

@pgermosen
pgermosen merged commit 16ca3a5 into floci-io:main Nov 21, 2026
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cloudformation AWS CloudFormation codedeploy AWS CodeDeploy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CloudFormation: AWS::CodeDeploy::Application reports CREATE_COMPLETE but creates no CodeDeploy application

2 participants