question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

📊Tracking: migrating CloudFormation templates to the CDK

See original GitHub issue

Add your +1 👍 to help us prioritize this feature!


Overview:

We want to expand the capabilities of the CfnInclude class from the core package to allow retrieving and modifying the resources that form the template. Example experience:

import * as cfn_inc from '@aws-cdk/cloudformation-include';

const cfnTemplate = new cfn_inc.CfnInclude(this, 'Template', {
  templateFile: 'my-template.json',
});
const cfnBucket = cfnTemplate.getResource('Bucket') as s3.CfnBucket;

// now, we can modify the bucket, and all of those modifications will be reflected in the resulting template!
// for example, we can change its name
cfnBucket.bucketName = 'my-bucket-name';

// or, reference it in other constructs, including L2s
import * as iam from '@aws-cdk/aws-iam';

const role = new iam.Role(this, 'Role', {
  assumedBy: new iam.AnyPrincipal(),
});
role.addToPolicy(new iam.PolicyStatement({
  actions: ['s3:*'],
  resources: [cfnBucket.attrArn],
}));

// or, reference an L2 bucket from the L1
const bucket = s3.Bucket.fromBucketName(this, 'L2Bucket', cfnBucket.ref);

Maturity: Experimental

See the AWS Construct Library Module Lifecycle doc for more information about maturity levels.

Implementation:

  • Support YAML templates in addition to JSON ones

  • Retrieving Resources by their logical ID

  • Retrieving Parameters by their logical ID

  • Retrieving Conditions by their logical ID

  • Retrieving Outputs by their logical ID

  • Support for the Properties CloudFormation resource attribute

  • Support for the Condition CloudFormation resource attribute

  • Support for the DependsOn CloudFormation resource attribute

  • Support for the CreationPolicy CloudFormation resource attribute

  • Support for the UpdatePolicy CloudFormation resource attribute

  • Support for the UpdateReplacePolicy CloudFormation resource attribute

  • Support for the DeletionPolicy CloudFormation resource attribute

  • Support for the Metadata CloudFormation resource attribute

  • Full support for all CloudFormation functions

  • Support nested Stacks


This is a 📊Tracking Issue

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:35
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Lock128commented, Jun 19, 2020

Thanks for sharing the link, I wasn’t aware of that project. That’s what I was looking for 😉

The cocern I have: it will essentially mean for us to keep the CloudFormation code “forever”…or until we migrate it…and do the enhancements in CDK… which is kind of … weird…because it breaks languages “in the middle” 😃 But its a good starting point, definitely, I was not trying to narrow this down, please don’t understand me wrong.

1reaction
Lock128commented, Jun 8, 2020

Well, no, not exactly. That will most certainly be helpful.

But: We have a hell lot of CloudFormation already, this option would only give us the option to “keep” it and “adjust” it on the fly when using CDK.

If I want to go “all in” on CDK I would need an option to “transform” the CloudFormation code to CDK code (in whatever language).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrating CloudFormation templates to the AWS Cloud ...
You can use AWS CloudFormation's sample templates or create your own ... Next, you'll need a CloudFormation Stack to migrate to the CDK....
Read more >
How to migrate from CloudFormation to AWS CDK - part 1
The first step to get started with using AWS CDK to migrate from AWS CloudFormation is to install AWS CDK command-line tool. The...
Read more >
Hey CDK, how can I migrate my existing CloudFormation ...
How can I migrate my existing CloudFormation templates? There are multiple options that we will go through. Let's imagine we have the following ......
Read more >
Migrate resources across CDK stacks - Binx
Step 1 – Remove the resource from the existing stack. Download the existing CloudFormation template: aws cloudformation get-template \ --output ...
Read more >
CDK vs CloudFormation: is the latter somehow deprecated, in ...
I've come across different tools explaining how to migrate from a CloudFormation template to CDK - I seem to understand CDK comes with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found