Answers: <p>after terraform 0.12 we have ways to control it using lifecycle we can simply skip resource by setting up lifecycle</p>
  <pre><code>resource &quot;aws_instance&quot; &quot;web&quot; {
      ami = &quot;foo&quot;
      lifecycle {
          ignore_changes = [&quot;ami&quot;]
      }
  }
  </code></pre>
  <p>Here is the link of bug
  <a href="https://github.com/hashicorp/terraform/pull/2525" rel="nofollow noreferrer">https://github.com/hashicorp/terraform/pull/2525</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2023-04-26T10:46:23.950Z
Answers: 2023-04-26T10:46:23.950Z
Answers: Mansur Ul Hasan
Answers: <p>No there is no way to tell Terraform to skip creating a resource if it already exists.</p>
  <p>Is there a reason why you want to skip resource creation? Why not import the existing resource into Terraform state file so it doesn't try to create the resource that already exists?</p>
  <p>You could provide more background information for this.</p>
  
Answers: CC BY-SA 4.0
Answers: 2023-12-13T08:02:44.827Z
Answers: Can you provide a simple example? The [docs](https://developer.hashicorp.com/terraform/cli/import) do not seem to help much...
Answers: stackprotector
Answers: CC BY-SA 4.0
Answers: 2022-11-14T08:03:16.870Z
Answers: 2022-11-14T08:03:16.870Z
Answers: hazmei
Answers: <p>One hack we can do is for every named resource you plan to create, perhaps do a check for the resource using data block and then use count in the resource block in order to create or skip.</p>
  <p>With this it will increase the execution time but recurring already exists errors could be mitigated.</p>
  
Answers: CC BY-SA 4.0
Answers: 2023-11-07T18:30:33.160Z
Answers: 2023-11-07T18:30:33.160Z
Answers: user42426
Body: <p>I'm Getting an error creating a secret because it was created manually.</p>
  <pre><code>Error: error creating Secrets Manager Secret: ResourceExistsException: The operation failed because the secret &lt;SECRET&gt; already exists.
  </code></pre>
  <p>Is there any way to tell Terraform to skip creating a resource if it already exists ?</p>
  
Comments: CC BY-SA 4.0
Comments: 2022-11-15T01:03:54.460Z
Comments: No, there is not. The idea of a tool like Terraform is to manage your complete infrastructure with it, not to cherry-pick things that you sometimes do and sometimes don't want to manage. You can use the `terraform import` functionality to import existing infrastructure into your state. The documentation for each resource type will show you how to import it.
Comments: Oldskool
Tags: <terraform>
Title: Skip terraform resource if it exists
UserDisplayName: DorAmar
ThreadText: # Skip terraform resource if it exists
  
  (Asked by: username_0 on 2022-11-13)
  
  I'm Getting an error creating a secret because it was created manually.
  
  ```
  Error: error creating Secrets Manager Secret: ResourceExistsException: The operation failed because the secret <SECRET> already exists.
  
  ```
  
  Is there any way to tell Terraform to skip creating a resource if it already exists ?
  
  **Tags:** terraform
  
  > **Comments:**
  > **username_1**: No, there is not. The idea of a tool like Terraform is to manage your complete infrastructure with it, not to cherry-pick things that you sometimes do and sometimes don't want to manage. You can use the `terraform import` functionality to import existing infrastructure into your state. The documentation for each resource type will show you how to import it.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2023-04-26. Score: 2 | Accepted answer
  
  after terraform 0.12 we have ways to control it using lifecycle we can simply skip resource by setting up lifecycle
  
  ```
  resource "aws_instance" "web" {
      ami = "foo"
      lifecycle {
          ignore_changes = ["ami"]
      }
  }
  
  ```
  
  Here is the link of bug
  <https://github.com/hashicorp/terraform/pull/2525>
  
  
  ---
  
  ### Answer by username_3 on 2022-11-14. Score: 1
  
  No there is no way to tell Terraform to skip creating a resource if it already exists.
  
  Is there a reason why you want to skip resource creation? Why not import the existing resource into Terraform state file so it doesn't try to create the resource that already exists?
  
  You could provide more background information for this.
  
  > **Comments:**
  > **username_4**: Can you provide a simple example? The [docs](https://developer.hashicorp.com/terraform/cli/import) do not seem to help much...  
  
  ---
  
  ### Answer by username_5 on 2023-11-07. Score: 0
  
  One hack we can do is for every named resource you plan to create, perhaps do a check for the resource using data block and then use count in the resource block in order to create or skip.
  
  With this it will increase the execution time but recurring already exists errors could be mitigated.
  
  
  ---
  
  