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
preguntada hace 2 años133 visualizaciones
No hay respuestas

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas