I am installing CNI using null_resource in terraform. Now if the CNI is already installed the terraform script fails with error:
exit status 254. Output: │ An error occurred (ResourceInUseException) when calling the CreateAddon │ operation: Addon already exists.
How can I make terraform continue with execution if the CNI is already installed, rather than failing.
Below is my Configuration for installing CNI:
### Installing CNI Addon ###
resource "null_resource" "install-CNI" {
provisioner "local-exec" {
when = create
interpreter = ["bash", "-c"]
command = <<EOT
aws eks create-addon \
--cluster-name ${data.aws_eks_cluster.Custom_Dev-cluster-deploy.name} \
--addon-name vpc-cni \
--addon-version v1.11.2-eksbuild.1 \
--service-account-role-arn ${aws_iam_role.Custom_Dev-cluster.arn} \
--resolve-conflicts OVERWRITE
EOT
}
triggers = {
"before" = null_resource.eks-config-file.id
}
}