[フレーム]
BT

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

We protect your privacy.

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Unlock the full InfoQ experience

Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.

Log In
or

Don't have an InfoQ account?

Register
  • Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
  • Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
  • Save articles and read at anytimeBookmark articles to read whenever youre ready.

Topics

Choose your language

InfoQ Homepage News AWS CDK Refactor Feature: Safe Infrastructure as Code Renaming

AWS CDK Refactor Feature: Safe Infrastructure as Code Renaming

Sep 25, 2025 2 min read

Write for InfoQ

Feed your curiosity. Help 550k+ global
senior developers
each month stay ahead.
Get in touch
Listen to this article - 0:00
Audio ready to play
0:00
0:00

AWS recently announced a new AWS Cloud Development Kit (CDK) feature that allows cloud engineers to refactor their infrastructure as code, preserving resources while renaming constructs and reorganizing applications.

With the new refactor feature, the company addresses a significant pain point: previously, any change to a resource's logical ID caused by renaming or moving a construct would force AWS CloudFormation to delete and then recreate the resource. This destructive process often led to data loss and downtime for stateful resources, such as databases, causing many developers to avoid refactoring altogether.

However, with the new CDK refactor command, cloud engineers can now detect, review, confirm, and safely apply refactored changes to their resources without requiring resource replacement. The authors of an AWS DevOps and Developer productivity blog write:

This feature leverages the recently-launched AWS CloudFormation refactor feature, but the CDK automatically computes the mappings that CloudFormation needs to redefine the refactored resources, providing a layer of abstraction that allows developers to focus on code rather than resource configuration.

The refactor feature is currently still in a pre-release state and requires the --unstable=refactor flag. Developers who want to try it out must also re-bootstrap their CDK environment to get the necessary permissions.

(Source: AWS DevOps & Developer Productivity blog post)

The company states that the CDK Refactor allows developers to apply object-oriented principles to their infrastructure, simplifying code, improving maintainability, and ultimately making their applications more robust and well-architected without the fear of destructive deployments.

Yet, Ran Isenberg, a principal software architect at CyberArk, cautioned on the feature in a LinkedIn post:

Bottom line - an important feature, BUT: That said, I wouldn’t recommend using it too often — it’s best reserved for cases where you really don’t have a better solution.

While the AWS CDK refactor provides a means for refactoring, other Infrastructure as Code (IaC) tools handle similar tasks differently. For instance, Pulumi relies on the concept of aliases, which are explicit properties cloud engineers can add to a resource definition to tell Pulumi to update an existing resource's identity rather than replacing it.

Another IaC offering, Terraform, has a more manual, declarative method using the moved block, which cloud engineers add to their HCL configuration to explicitly map an old resource address to a new one, ensuring the state file is updated without destroying the underlying resource. And finally, Bicep, as a stateless tool that compiles to ARM templates, doesn't have a dedicated refactor command. Instead, refactoring is handled through its native deployment model, which relies on Azure Resource Manager to manage the resource's lifecycle without requiring a local state file.

Lastly, more details on the refactor feature are available on the documentation pages.

About the Author

Steef-Jan Wiggers

Show moreShow less

Rate this Article

Adoption
Style

Related Content

The InfoQ Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

We protect your privacy.

BT

AltStyle によって変換されたページ (->オリジナル) /