Using aws_opensearch_package_association to track OpenSearch packages when upgrading cluster version isn't really possible

Hi there,

I’ve noticed using the aws_opensearch_package_association resource associate and track packages installed on your OpenSearch cluster isn’t really practical / possible once you’ve upgraded your cluster version.

The issue is, when you perform a cluster version upgrade the upgrade process automatically updates all of the packages associated with the cluster automatically. This in turn changes all of the package ids in the AWS environment. Unfortunately this means the package ids are then out of sync with the terraform state file. Any subsequent terraform deployments will try to reinstall the old OpenSearch package against the cluster, ultimately resulting in a failed deployment because the package is incompatible with the upgraded cluster.

I’ve tried to work around this issue by updating the package_id of the aws_opensearch_package_association resource to the id of the package installed on the cluster, but this results in a “package with the same name is already installed” error.

It seems the only option here is to remove the aws_opensearch_package_association resource from the terraform state file, and import the new aws_opensearch_package_association resource from AWS. This is not a great developer experience.

Clusters go through a blue green when packages are installed. It would be great if packages were actually installed at the same time that an opensearch cluster was being created, or a change was being applied to the domain. it feels like packages really need to be apart of the aws_opensearch_domain resource, if that were at all possible.

Has anyone else run into this issue? Any wisdoms to share?