Powerful feature. I just did a quick hands-on to realize the power. Sharing the recorded demo in case anyone wants to see this feature in action. https://youtu.be/ilXROl36J5Q
Did you actually managed to re-create your setup using the generated template? I did a similar test where I had an EC2 instance and EBS volume. The code that come out had resources for both instance & volume and then also the attachment like below. While this work fine for importing the existing resources into a new stack, you won't be able to run this to re-create the instance as hard-coded InstanceId and VolumeId wouldn't match with the resources created from the template :-/
EC2VolumeAttachment00vol06b7d183e4bb867a700jaYoF:
UpdateReplacePolicy: "Retain"
Type: "AWS::EC2::VolumeAttachment"
DeletionPolicy: "Retain"
Properties:
InstanceId: "i-060079affca8f6dba"
VolumeId: "vol-06b7d183e4bb867a7"
Device: "/dev/xvda"
But I agree this gives you a template as a starting point, it just wouldn't work out-of-the-box.
I did not attempt an immediate re-import, I needed the generated code as a starting point to augment a different CF template.
You can use aspects to put the correct properties on the resource and then it should work.
Just try it, do a cdk diff
and you will see that there are no differences between your stack and the resources in your account.
This looks great, is this possible to do the import to stack step without accessing AWS Management Console. Official documentation mentions steps to scan, create or update template through cli. But import to stack possible through cli or sdk? This will help in automating import of lot our resources
I am not interested in creating new resource but trying to import existing resource into a new stack through IaC generator
Are you trying to do something like this? See the AWS CLI syntax toward the bottom. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-existing-stack.html
Relevant content
- asked 3 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago