I have manually launch the EC2 Instances on AWS Amazon Management web Console. Can i add cloudwatch Alarm to an Existing EC2 Instance from terraform, without deleting it.
A resource is either managed by Terraform or not. If you want to change what is being managed you can use the
terraform import and
terraform state rm commands to add or remove things into state, and therefore into Terraform’s control.
So you could add some code to represent the new EC2 instance, import it and then run
terraform apply. The EC2 instance would then be adjusted to match the code (for example to enable enhanced monitoring).
If you are referring to CloudWatch alarms they are separate resources from EC2 instances, so you can manage them without any reference to EC2:
Thank you, It was very helpful. Another question, Can we add an SNS topic from Terraform with Email subscription.
Yes, that’s possible. Check the aws resources.
It was helpful. I managed to solve my issue.