0

Few days back I asked a question to stack overflow community at about custom construct library Question

Although I didn’t got the exact answer I was looking for. But somehow I managed to create a custom construct library. But now I have another query on how to host the CDK App as an API.

Below is the snapshot of custom construct library:

test_ec2 = ec2.Instance(self, "APIInstance", 
                                vpc=my_vpc,
                                machine_image=ec2.AmazonLinuxImage(
                                        generation=ec2.AmazonLinuxGeneration.AMAZON_LINUX
                                ),
                                key_name="test-cdk",
                                instance_name=inst-name
                                )

If I want to host above AWS CDK Application as an API that will accept a string for the variable inst-name and will create a EC2 instance. I tried creating it as an lambda function but not sure how to manage “node dependencies and python dependencies” at same time.

Can it be done using an already created EC2 Instance(attaching an IAM Role with permission of cloudformation) and accepting HTTP requests (But don’t know how?) Is this making sense?

Thank You in advance to all the devs.