I would like to inform you that attaching an existing EC2 instance to an AutoScalingGroup created via CDK or CloudFormation is not directly possible.
If you would check the CDK Documentation for class AutoScalingGroup - https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_autoscaling/AutoScalingGroup.html
You will find there's no such property or method available that can help in attaching existing EC2 instance to ASG.
Due to this limitation, your requirement can be completed using AWS Console or AWS CLI, and the process to do so is given in the document - https://docs.aws.amazon.com/autoscaling/ec2/userguide/attach-instance-asg.html
The API that is responsible for doing this is 'AttachInstances' - https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_AttachInstances.html
So, as a workaround, you may use custom resources in CDK to trigger this API and attach the ec2 instance via CDK if you do not wish to do so via the console. https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.custom_resources/README.html
If this is only a one-time requirement, then I'd suggest doing this via console, but if it is something that you would be doing in multiple accounts or regions, then I would recommend using custom resources to automate this process.
Sagemaker studio performance issues - why so slow, or am I missing a trick?asked 20 days ago
i have 1 instances and i am using application load balancerasked 2 months ago
How do I see the posts I am following?asked 9 months ago
Why am I not able to create alerts and set alert thresholds?asked 5 months ago
How to create AutoScalling Group using CDK for existing EC2 instance?asked 23 days ago
Am I billed while a RDS instance is starting/backing up?Accepted Answerasked 10 months ago
I am not able to stop or terminate the serverasked 5 months ago
i am using free tier as a new user. i am connecting my EC-2 instance from my laptop through putty.Accepted Answerasked 4 months ago
I am not able to ssh to EC2 instancesasked 8 months ago
My website is very Slow an I am using $40 amazon light sailasked 4 years ago