Can you convert (as opposed to import) a CloudFormation template into CDK code?

1

Based on this documentation, which is all about importing an already deployed CloudFormation stack and referencing it, I'm guessing the answer is no, but just wanted to double-check, since I didn't see this question being asked before on re:Post.

If my CloudFormation template were this:

{
  "Resources": {
    "MyBucket": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": "MyBucket",
      }
    }
  }
}

Instead of using:

import aws_cdk as cdk
from aws_cdk import cloudformation_include as cfn_inc
from constructs import Construct

class MyStack(cdk.Stack):

    def __init__(self, scope: Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        template = cfn_inc.CfnInclude(self, "Template",  
            template_file="my-template.json")

to reference the template, is there a way to generate from the template something kinda like:

# import statements blablabla
  bucket = cfnBucket(self, "myBucket")
AWS
gefragt vor 2 Jahren133 Aufrufe
Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen