# How to fix destroy provisioner without using null resource triggers

**URL:** <https://discuss.hashicorp.com/t/how-to-fix-destroy-provisioner-without-using-null-resource-triggers/32048>\
**Category:** Terraform\
**Created:** [November 17, 2021, 3:45pm UTC](https://discuss.hashicorp.com/t/how-to-fix-destroy-provisioner-without-using-null-resource-triggers/32048 "2021-11-17T15:45:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![akshaymodi-lm](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/akshaymodi-lm/32/23811_2.png) [@akshaymodi-lm](https://discuss.hashicorp.com/u/akshaymodi-lm)\
**Post date:** [November 17, 2021, 3:45pm UTC](https://discuss.hashicorp.com/t/how-to-fix-destroy-provisioner-without-using-null-resource-triggers/32048/1 "2021-11-17T15:45:16Z")

</div>

I know that we can use null resource and use triggers to set key,value of variables there and then refer them in provisioner local\_exec with self.triggers.key but in our case we are not using null resource . we want to fix it when we use destroy provisioner “local\_exec” within the resource “aws\_instance” . In this case we have to pass variables value like self.tags[“Region”] as below but we don’t want to set Region and NamingPrefix tags to our instances and just because destroy provisioner is deprecated to use external references as var.naming\_prefix , we have to unnecessarily add it into tags .  
Is there any other solution for this ? Please do share.

```auto
locals {
  ec2_tags = merge(var.std_tags, {
    Naming_Prefix = var.naming_prefix
    Region = var.region
  })
}

resource "aws_instance" "xyz" {
  ami = data.aws_ami.centos_7.id
  count = var.num
  instance_type = var.instance_type
  key_name = var.key_name
  subnet_id = element(split(",", var.subnet_ids), count.index)
  tags = local.ec2_tags

provisioner "local-exec" {
    command = "aws sns publish --topic-arn xxxxxxxxxxxxxxxxxxxx --message '{\"operation\": \"delete\", \"hostname\": \"${self.tags["NamingPrefix"]}-${self.id}.${self.tags["Region"]}\", \"param_name\": \"pod\", \"param_value\": \"${self.tags["Pod"]}\"}' --region us-east-1"
    when = destroy
  }

 provisioner "local-exec" {
    command = "aws sns publish --topic-arn xxxxxxxxxxxxx --message '{\"hostname\": \"${var.naming_prefix}-${self.id}.${var.region}\", \"param_name\": \"pod\", \"param_value\": \"${var.pod}\"}' --region us-east-1"
  }
}

```
