Repository navigation
fix(cloudformation): provision AWS::CodeDeploy::Application - #8882
Conversation
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
|
🎉 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:
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. |
PR Summary by QodoProvision CodeDeploy applications through CloudFormation
AI Description
Merge Risk
|
Code Review by Qodo
1.
|
|
@jonathanmorley welcome, and thanks for opening #8626 first. A stack created before this provisioner, or while CodeDeploy was off, holds the dispatcher's stub, so an update takes
The integration test builds its own CreateStack, UpdateStack and DescribeStacks calls, which |
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
left a comment
There was a problem hiding this comment.
@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
ListDeploymentson a recreated application of the same name still returns the old ones. createApplicationrepeatsgetApplication'sApplicationNameRequiredExceptionandInvalidApplicationNameExceptionthrows, which could come from one helper.
|
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 |
Summary
AWS::CodeDeploy::Applicationhad no provisioner, so it fell through to the generic stub: the stack reportedCREATE_COMPLETEwith a random physical id and no application existed in CodeDeploy.This adds
CodeDeployCfnProvisioner, which wrapsCodeDeployService:CreateApplicationwithApplicationName(or a generated name, max 100 characters),ComputePlatform(defaultServer) andTags.Refreturns the application name. The registry schema has noreadOnlyProperties, so there is noFn::GetAttattribute.ApplicationNameandComputePlatformare 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.ComputePlatformreplaces an unnamed application and is refused for a named one, as CloudFormation does.ApplicationDoesNotExistException.It also changes two CodeDeploy API behaviors in
CodeDeployService:CreateApplicationvalidates its input as the API reference specifies. It answers 400ApplicationNameRequiredExceptionfor a missing or empty name (previously aNullPointerException), 400InvalidApplicationNameExceptionfor a name over 100 characters or outside[A-Za-z0-9+=,.@_-], and 400InvalidComputePlatformExceptionfor a platform other thanServer,Lambda,ECSorKubernetes.DeleteApplicationdeletes 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,
CfnProvisionerFixturewiring,schema-surface.tsvandcreate-only-properties.jsonregenerated (only this type changed), docs table viamake docs-sync, andProvisionContext.resolveOptionalWritten, shared withresolveOptionalIntandresolveOptionalBigInteger.Closes #8626
Type of change
fix:)feat:)feat!:orfix!:)AWS Compatibility
Incorrect behavior:
CreateStackwith anAWS::CodeDeploy::ApplicationreachedCREATE_COMPLETE, butGetApplicationreturnedApplicationDoesNotExistExceptionandRefwas a random stub id rather than the application name. On the CodeDeploy API,CreateApplicationstored any name and compute platform, andDeleteApplicationleft the application's deployment groups and tags behind for the next application of that name.Now the application exists with the template's
ComputePlatformand tags, andRefis the name. AnUpdateStackthat 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. AnUpdateStackthat changesComputePlatformreplaces an unnamed application with a new name and deletes the old one, andDeleteStackremoves it. A blankApplicationNameorComputePlatformwritten into the template fails the stack with CodeDeploy's error.Behavior follows the
AWS::CodeDeploy::Applicationregistry schema (create-onlyApplicationName/ComputePlatform, tag-only update handler, no read-only properties) and the CodeDeployCreateApplicationAPI reference.CodeDeployApplicationCfnIntegrationTestchecks it through the SDK withCfnTestStackand reads the applications back over the CodeDeploy wire API.Checklist
./mvnw testpasses locally (ran the CodeDeploy, CloudFormation provisioner andCfn*Testsuites, 3511 tests; not the full suite)