I have a critical service running in EC2 instance. I want to bring it under Terraform control. I imported the aws instance with terraform import command. But whenever I run terraform plan, its asking to destroy and create a new instance as user_data is changed. The instance was launched manually with user_data. I cant shut down or destroy and recreate the instance. Is there any way to import the aws instance without touching the user_data.
My main aim to manage the security groups and rules attached to instance with terraform. I dont have to modify other parameters like user_data. So please suggest a way to import the instance.
You can ignore some changes if you don't need them
lifecycle {
ignore_changes = [
"user_data"
]
}
@manjitsingh664 - it's hard to advise without seeing your configuration, but @Victorion 's suggestion is sound. Either remove user_data from your terraform configuration altogether or set the lifecycle as suggested above.
@Victorion @mildwonkey - Thanks for the answer..It works.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.