rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
258 stars 223 forks source link

EKS Launch Template not deleted #834

Open ahmedfourti opened 2 years ago

ahmedfourti commented 2 years ago

Hello,

When deploying EKS on rancher using terraform, rancher creates a launch template for each node group with a static name which composed as follow : rancher-managed-lt-{{node_group_name}} When deleting the cluster and its node group, the launch template is not deleted, which means after recreating another node-group with same name we get this error : Waiting for API to be available:InvalidLaunchTemplateName.AlreadyExistsException: Launch template name already in use. status code: 400, request id: 5b075b19-24ae-45b5-a096-7be0e87ccb13 Steps to reproduce :

  1. Create a cluster on rancher with terraform
  2. For example name the node_group test
  3. On AWS side you will see a launch template created with name rancher-managed-lt-test
  4. Terraform destroy
  5. And finally terraform apply again with the same name

I think 2 things to change here :

  1. Create the launch_template with a random strings
  2. Make sure that deleting the cluster will delete everything related to that cluster.

Thanks for your help,

herrbpl commented 2 years ago

Yes, have same issue

juliano-secondo commented 2 years ago

I got the same issue I got the log from EKS operator when it tried to remove it and decode error message.

"DecodedMessage": "{"allowed":false,"explicitDeny":false,"matchedStatements":{"items":[]},"failures":{"items":[]},"context":{"principal":{"id":"xxxxxx","name":"rancher-user","arn":"arn:aws:iam::00000:user/rancher-user"},"action":"ec2:DeleteLaunchTemplate","resource":"arn:aws:ec2:us-east-2:0000:launch-template/lt-0b76d1d8fb124d18c","conditions":{"items":[{"key":"aws:Region","values":{"items":[{"value":"us-east-2"}]}},{"key":"aws:ID","values":{"items":[{"value":"lt-0b76d1d8fb124d18c"}]}},{"key":"aws:Service","values":{"items":[{"value":"ec2"}]}},{"key":"aws:Resource","values":{"items":[{"value":"launch-template/lt-0b76d1d8fb124d18c"}]}},{"key":"ec2:ResourceTag/rancher-managed-template","values":{"items":[{"value":"do-not-modify-or-delete"}]}},{"key":"aws:Type","values":{"items":[{"value":"launch-template"}]}},{"key":"aws:Account","values":{"items":[{"value":"0000"}]}},{"key":"aws:ARN","values":{"items":[{"value":"arn:aws:ec2:us-east-2:0000:launch-template/lt-0b76d1d8fb124d18c"}]}}]}}}

maybe need to fix some order to exclude properly or a put timer before try to exclude it