首页 > 解决方案 > Terraform import identifying resource has been deleted but it hasn't

问题描述

I'm attempting to import a Cloudtrail trail that was manually created in the console into my terraform, so I don't recreate a cloudtrail. When I attempt to import one resource for example, terraform import module.aws_cloudtrail.aws_cloudwatch_log_group.cloudtrail cloudtrail-logs, and then run the plan I get the following:

# module.aws_cloudtrail.aws_cloudwatch_log_group.cloudtrail has been deleted
  - resource "aws_cloudwatch_log_group" "cloudtrail" {
      - arn               = "arn:aws:logs:us-east-1:123456:log-group:cloudtrail-logs" -> null
      - id                = "cloudtrail-logs" -> null
      - name              = "cloudtrail-logs" -> null
      - retention_in_days = 7 -> null
      - tags              = {} -> null
      - tags_all          = {} -> null
    }

I'm not sure, why it's identifying as being deleted when it hasn't been, and it seems like it's going to remove it. It's the same bevaior for all the resources related to the cloudtrail. What am I missing, is it going to destroy my cloudtrail already created? The only thing I should mention is that the Cloudtrail name in my terraform is identical to the already existing Cloudtrail, but that's why I want to import so I don't recreate it.

标签: amazon-web-servicesterraformamazon-cloudtrail

解决方案


推荐阅读