On 13/04/2021 09:43, Bartosz Dopke wrote:
> It went like that:
>
> 1. I created netapp volume in a terraform code without assigning
> snapshot policy to it (not available in Terraform).
> 2. I attached a snapshot policy to it in Azure Portal.
> 3. I did a change in netapp volume in a terraform code not related to
> snapshot policy (change touched export policy rules).
> 4. Terraform plan showed that only thing in netapp volume which will
> be changed is export policy rules.
> 5. After terraform apply, the result is that export policy rules are
> changed and snapshot policy association has been deleted.
>
That does sound fairly expected.
Presumably the API call used to edit the export policy rules also
controls the snapshot policy, so when Terraform called that API with the
new settings it did not include the snapshot policy details (as
Terraform knows nothing about that feature) causing Azure to remove it.
If the APIs worked differently (separate calls for snapshot & policy
settings) this wouldn't have happened. The only real fix is for
Terraform to start supporting the config for snapshots, otherwise every
time you run an apply that does some other change to the volume it will
be deleted (if the plan doesn't need to touch the volume for other
reasons you are safe).
--
Stuart Clark