Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data sources with non-deterministic IDs show perpetual diff with Terraform 0.13.0 #1148

Closed
tutorialbyexample opened this issue Aug 17, 2020 · 13 comments

Comments

@tutorialbyexample
Copy link

tutorialbyexample commented Aug 17, 2020

In terraform version 0.12.0, once we run plan after apply, while using the data source there will be no changes however, in version terraform 0.13.0 which doing the apply we are getting change in data source and causing for recreation of resource as ID of data source are getting change every time. This has been reported for aws provide as well in "hashicorp/terraform-provider-aws#14579"

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version and Provider Version

terraform -version
Terraform v0.13.0

  • provider registry.terraform.io/hashicorp/oci v3.89.0

Affected Resource(s)

data "oci_file_storage_export_sets" "test_export_sets"
or any data source which have module implementation and depends_on.

Terraform Configuration Files

data "oci_identity_compartments" "compartments" {
    #Required
    compartment_id = var.tenancy_ocid

    #Optional
    access_level = "ANY"
}

module "compartments" {
  source = "./tf_module_datasource/compartments"
  tenancy_ocid = var.tenancy_ocid
}  

# module.compartments_network.data.oci_identity_compartments.compartments will be read during apply
  # (config refers to values not yet known)
 <= data "oci_identity_compartments" "compartments"  {

Expected Behavior

data source id should not change.

Actual Behavior

data source id getting change.

# module.compartments_network.data.oci_identity_compartments.compartments will be read during apply
  # (config refers to values not yet known)
 <= data "oci_identity_compartments" "compartments"  {

Steps to Reproduce

  1. terraform init
  2. terraform apply
 # module.vcns.data.oci_core_vcns.vcns will be read during apply
  # (config refers to values not yet known)
 <= data "oci_core_vcns" "vcns"  {
        compartment_id   = "ocid1.compartment.oc1..aiq"
      **~ id               = "2020-08-17 15:14:46.103456 +0000 UTC" -> "2020-08-17 15:14:57.469126 +0000 UTC"**
        virtual_networks = [
            {
                cidr_block               = "xx.xx.0.0/xx"
                compartment_id           = "ocid1.compartment.oc1..aaaaaaaq"
                default_dhcp_options_id  = "ocid1.dhcpoptions.oc1.phx.aaaaaaao6ma"
                default_route_table_id   = "ocid1.routetable.oc1.phx.aaaaaaaawly75d7gdscyhahsa"
                default_security_list_id = "ocid1.securitylist.oc1.phx.aaaaqntzs74m5q"
                defined_tags             = {
                    "Oracle-Tags.CreatedBy" = "xxxxx"
                    "Oracle-Tags.CreatedOn" = "2020-08-03T10:40:55.234Z"
                }
                display_name             = "xxxxxx"
                dns_label                = "xxxx"
                freeform_tags            = {
                    "Environment"     = "xxx"
                    "Purpose"         = "Terraform"
                    "Region_function" = "Primary"
                }
                id                       = "ocid1.vcn.oc1.phx.amma"
                ipv6cidr_block           = ""
                ipv6public_cidr_block    = ""
                is_ipv6enabled           = false
                state                    = "AVAILABLE"
                time_created             = "2020-08-03 10:40:55.238 +0000 UTC"
                vcn_domain_name          = "xxxxxxxxxxx"
            },
        ]
    }

Plan: 2 to add, 0 to change, 2 to destroy.

Important Factoids

References

@varmax2511
Copy link
Member

Hi @tutorialbyexample -- thanks for raising this issue. We are tracking this issue with terraform core: hashicorp/terraform#25812

@alexng-canuck
Copy link
Member

@tutorialbyexample , this is an issue in the Terraform v0.13.0 CLI which broke compatibility with the previous v0.12.X behavior.

The v0.13.1 of the Terraform CLI was released recently and should resolve this issue. Closing the ticket.

https://www.terraform.io/downloads.html

https://github.com/hashicorp/terraform/blob/v0.13.1/CHANGELOG.md

@sblask
Copy link

sblask commented Aug 26, 2020

I just tried and I am still seeing this in 0.13.1

@alexng-canuck
Copy link
Member

alexng-canuck commented Aug 26, 2020

@sblask , what configuration are you trying this with and what output are you seeing?

For reference, I tried this with 0.13.1 and no longer get perpetual diffs on data source IDs:

// Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
// Licensed under the Mozilla Public License v2.0

variable "tenancy_ocid" {
}

variable "user_ocid" {
}

variable "fingerprint" {
}

variable "private_key_path" {
}

variable "compartment_ocid" {
}

variable "region" {
}

provider "oci" {
  tenancy_ocid     = var.tenancy_ocid
  user_ocid        = var.user_ocid
  fingerprint      = var.fingerprint
  private_key_path = var.private_key_path
  region           = var.region
}

data "oci_identity_compartments" "compartments" {
  #Required
  compartment_id = var.tenancy_ocid

  #Optional
  access_level = "ANY"
}

resource "oci_core_vcn" "vcn1" {
  cidr_block     = "10.0.0.0/16"
  dns_label      = "vcn1"
  compartment_id = var.compartment_ocid
  display_name   = "vcn1"
}

data "oci_core_vcns" "vcns" {
  compartment_id = var.compartment_ocid
  depends_on     = [oci_core_vcn.vcn1]
}

output "vcn_id" {
  value = oci_core_vcn.vcn1.id
}

I first ran terraform apply with above and it succeeded.

I then ran terraform plan and terraform apply and in both cases, I get this output, which shows no diffs.

alexng-macbook:vcn alexng$ terraform-0.13.1 plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.oci_identity_compartments.compartments: Refreshing state... [id=2020-08-26 23:21:40.830304 +0000 UTC]
oci_core_vcn.vcn1: Refreshing state... [id=ocid1.vcn.oc1.phx.<redacted>]
data.oci_core_vcns.vcns: Refreshing state... [id=2020-08-26 23:21:43.581415 +0000 UTC]

------------------------------------------------------------------------

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

@sblask
Copy link

sblask commented Aug 27, 2020

$ terraform --version
Terraform v0.13.1
+ provider registry.terraform.io/hashicorp/aws v2.70.0
+ provider registry.terraform.io/hashicorp/random v2.3.0
+ provider registry.terraform.io/hashicorp/template v2.1.2
+ provider registry.terraform.io/hashicorp/vault v2.12.2

This is what I am seeing (this is for an existing module, so I slightly modified the output to only show relevant stuff):

$ terraform plan -out plan

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.vault_generic_secret.database: Refreshing state... [id=703a9bea-d11d-72b4-2211-2436ae74229c]
data.aws_availability_zones.default: Refreshing state... [id=2020-08-26 22:51:16.104688 +0000 UTC]

...


------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
 <= read (data resources)

Terraform will perform the following actions:

  # data.vault_generic_secret.database will be read during apply
  # (config refers to values not yet known)
 <= data "vault_generic_secret" "database"  {
    ...
        )
      ~ id               = "55b7351e-df48-a5db-b499-8fda2dd87cb5" -> "a8c87908-5ce0-c3c9-0666-771f7722a67d"
        lease_duration   = 2764800
    ...
    }

  # data.aws_availability_zones.default will be read during apply
  # (config refers to values not yet known)
 <= data "aws_availability_zones" "default"  {
        group_names = [
            "ap-southeast-2",
        ]
      ~ id          = "2020-08-27 00:37:16.408711 +0000 UTC" -> "2020-08-27 00:38:10.30798 +0000 UTC"
        names       = [
            "ap-southeast-2a",
            "ap-southeast-2b",
            "ap-southeast-2c",
        ]
        zone_ids    = [
            "apse2-az1",
            "apse2-az3",
            "apse2-az2",
        ]
    }

Plan: 0 to add, 0 to change, 0 to destroy.

------------------------------------------------------------------------

This plan was saved to: plan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan"

Releasing state lock. This may take a few moments...

@alexng-canuck
Copy link
Member

alexng-canuck commented Aug 27, 2020

@sblask , it seems like you're encountering this issue with non-OCI providers like AWS/Vault/etc...

This github repo is for Oracle Cloud provider issues. Can you redirect your question to github.com/hashicorp/terraform? I believe the issue you're encountering is in Terraform core behavior.

@sblask
Copy link

sblask commented Aug 27, 2020

Sorry about that, this issue was linked in another issue and I didn't realise it's a different repository.

@tutorialbyexample
Copy link
Author

tutorialbyexample commented Aug 27, 2020

Hello Alexng, Still i'm facing this issue in OCI provider as well with terraform version 0.13.1.

`
terraform -v
Terraform v0.13.1

  • provider registry.terraform.io/hashicorp/oci v3.90.1

========================================
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
<= read (data resources)

Terraform will perform the following actions:

data.oci_file_storage_export_sets.export_sets will be read during apply
(config refers to values not yet known)
<= data "oci_file_storage_export_sets" "export_sets" {
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaarlvaqvz3b4gtd43ovqeu4nsnsz6cuzauk6kspmhz4qdbue2mnbka"
~ export_sets = [
- {
- availability_domain = "WrnJ:PHX-AD-1"
- compartment_id = "ocid1.compartment.oc1..aaaaaaaarl"
- display_name = "phxl1-mount_target-data-001 - export set"
- id = "ocid1.exportset.oc1.phx.aaaaaaa"
- max_fs_stat_bytes = ""
- max_fs_stat_files = ""
- mount_target_id = ""
- state = "ACTIVE"
- time_created = "2020-08-27 07:22:11.259 +0000 UTC"
- vcn_id = "ocid1.vcn.oc1.phx.amaaaaabva"
},
- {
- availability_domain = "WrnJ:PHX-AD-1"
- compartment_id = "ocid1.compartment.oc1..aaaaaaaarlvaqvka"
- display_name = "phxl1-dbbackend-001"
- id = "ocid1.exportset.oc1.phx.aaazaaaaa"
- max_fs_stat_bytes = ""
- max_fs_stat_files = ""
- mount_target_id = ""
- state = "ACTIVE"
- time_created = "2020-08-27 07:21:32.584 +0000 UTC"
- vcn_id = "ocid1.vcn.oc1.phx.amaaaabva"
},
] -> (known after apply)
- id = "2020-08-27 07:40:59.286727 +0000 UTC" -> null
}

data.oci_file_storage_file_systems.fss will be read during apply
(config refers to values not yet known)
<= data "oci_file_storage_file_systems" "fss" {
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaarlvaqvz3b4gtd43oka"
file_systems = [
{
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaarlvaqbka"
defined_tags = {
"Oracle-Tags.CreatedBy" = "emailid"
"Oracle-Tags.CreatedOn" = "2020-08-27T07:21:32.063Z"
}
display_name = "phxl1-filesystem-dbbackend-001"
freeform_tags = {
"Environment" = "Lab"
"Purpose" = "Terraform"
"Region_function" = "Primary"
}
id = "ocid1.filesystem.oc1.phx.aaaaaaaazaaaaa"
kms_key_id = ""
metered_bytes = "0"
state = "ACTIVE"
time_created = "2020-08-27 07:21:32.067 +0000 UTC"
},
]
~ id = "2020-08-27 07:40:54.78267 +0000 UTC" -> "2020-08-27 07:41:01.913177 +0000 UTC"
}

data.oci_file_storage_mount_targets.mount_targets will be read during apply
(config refers to values not yet known)
<= data "oci_file_storage_mount_targets" "mount_targets" {
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaarlvaqvz3b4g2mnbka"
~ id = "2020-08-27 07:40:58.563307 +0000 UTC" -> "2020-08-27 07:41:01.973742 +0000 UTC"
mount_targets = [
{
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaarlvaqvz3ka"
defined_tags = {
"Oracle-Tags.CreatedBy" = "email"
"Oracle-Tags.CreatedOn" = "2020-08-27T07:22:11.175Z"
}
display_name = "phxl1-mount_target-data-001"
export_set_id = "ocid1.exportset.oc1.phx.aaaaaa4aa"
freeform_tags = {
"Environment" = "Lab"
"Purpose" = "Terraform"
"Region_function" = "Primary"
}
hostname_label = ""
id = "ocid1.mounttarget.oc1.phx.aaaaaa4naa"
ip_address = ""
lifecycle_details = ""
nsg_ids = [
"ocid1.networksecuritygroup.oc1.phx.aaaaaaymkq",
]
private_ip_ids = [
"ocid1.privateip.oc1.phx.aaaaaaaagemhlsknpwya",
]
state = "ACTIVE"
subnet_id = "ocid1.subnet.oc1.phx.aaaaaashzwaelna"
time_created = "2020-08-27 07:22:11.259 +0000 UTC"
},
{
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaarlvabka"
defined_tags = {
"Oracle-Tags.CreatedBy" = "email"
"Oracle-Tags.CreatedOn" = "2020-08-27T07:21:32.537Z"
}
display_name = "phxl1-mount_target-control-001"
export_set_id = "ocid1.exportset.oc1.phx.afuzaaaaa"
freeform_tags = {
"Environment" = "Lab"
"Purpose" = "Terraform"
"Region_function" = "Primary"
}
hostname_label = ""
id = "ocid1.mounttarget.oc1.phx.aaaaaa4zaaaaa"
ip_address = ""
lifecycle_details = ""
nsg_ids = [
"ocid1.networksecuritygroup.oc1.phx.aaaaaaaat2zj2rymkq",
]
private_ip_ids = [
"ocid1.privateip.oc1.phx.aaaaaaaaqp6limr2b6lra",
]
state = "ACTIVE"
subnet_id = "ocid1.subnet.oc1.phx.aaaaaaaadm2qq"
time_created = "2020-08-27 07:21:32.584 +0000 UTC"
},
]
}

module.export["phxl1-dbbackend-001"].oci_file_storage_export.export[0] must be replaced
-/+ resource "oci_file_storage_export" "export" {
~ export_set_id = "ocid1.exportset.oc1.phx.aaaaaaaaa" -> (known after apply) # forces replacement
file_system_id = "ocid1.filesystem.oc1.phx.aaaaaaaaaa2ylefuzaaaaa"
~ id = "ocid1.export.oc1.phx.aaaaacylefuzaaaaa" -> (known after apply)
path = "/phxl1-dbbackend-001"
~ state = "ACTIVE" -> (known after apply)
~ time_created = "2020-08-27 07:22:25.572 +0000 UTC" -> (known after apply)

    export_options {
        access                         = "READ_WRITE"
        anonymous_gid                  = "65534"
        anonymous_uid                  = "65534"
        identity_squash                = "NONE"
        require_privileged_source_port = false
        source                         = "10.XXX.104.0/24"
    }
}

Plan: 1 to add, 0 to change, 1 to destroy.

Changes to Outputs:

  • export_sets_id = {
    • phxl1-dbbackend-001 = "ocid1.exportset.oc1.phx.aaaaaa4naa"
    • phxl1-mount_target-data-001 - export set = "ocid1.exportset.oc1.phx.aaaaaaaaa"
      } -> null

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
`

@alexng-canuck
Copy link
Member

Reopening this for investigation.

@alexng-canuck alexng-canuck reopened this Aug 31, 2020
@srishtipmishra
Copy link
Member

srishtipmishra commented Aug 31, 2020

@tutorialbyexample : Tried reproducing this error with the last plan output's config but i dont see a diff.

Following for your reference :
`2020/08/31 12:56:37 [INFO] backend/local: plan operation completed

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
<= read (data resources)

Terraform will perform the following actions:

data.oci_core_private_ips.ip_mount_target1 will be read during apply
(config refers to values not yet known)
<= data "oci_core_private_ips" "ip_mount_target1" {
~ id = "2020-08-31 19:56:35.947088 +0000 UTC" -> "2020-08-31 19:56:37.579995 +0000 UTC"
private_ips = [
{
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
defined_tags = {}
display_name = "privateip20200831193151"
freeform_tags = {}
hostname_label = ""
id = "ocid1.privateip.oc1.phx."
ip_address = "10.0.1.6"
is_primary = false
subnet_id = "ocid1.subnet.oc1.phx."
time_created = "2020-08-31 19:31:51.123 +0000 UTC"
vlan_id = ""
vnic_id = "ocid1.vnic.oc1.phx."
},
]
subnet_id = "ocid1.subnet.oc1.phx."

    filter {
        name   = "id"
        regex  = false
        values = [
            "ocid1.privateip.oc1.phx.",
        ]
    }
}

data.oci_file_storage_export_sets.export_sets will be read during apply
(config refers to values not yet known)
<= data "oci_file_storage_export_sets" "export_sets" {
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
export_sets = [
{
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
display_name = "export set for mount target 1"
id = "ocid1.exportset.oc1.phx."
max_fs_stat_bytes = ""
max_fs_stat_files = ""
mount_target_id = ""
state = "ACTIVE"
time_created = "2020-08-31 19:31:38.67 +0000 UTC"
vcn_id = "ocid1.vcn.oc1.phx."
},
{
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
display_name = "export set for mount target 2"
id = "ocid1.exportset.oc1.phx."
max_fs_stat_bytes = ""
max_fs_stat_files = ""
mount_target_id = ""
state = "ACTIVE"
time_created = "2020-08-31 19:31:27.404 +0000 UTC"
vcn_id = "ocid1.vcn.oc1.phx."
},
{
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
display_name = "displayName2 - export set"
id = "ocid1.exportset.oc1.phx."
max_fs_stat_bytes = ""
max_fs_stat_files = ""
mount_target_id = ""
state = "ACTIVE"
time_created = "2020-06-16 02:44:09.658 +0000 UTC"
vcn_id = "ocid1.vcn.oc1.phx."
},
]
~ id = "2020-08-31 19:56:35.139953 +0000 UTC" -> "2020-08-31 19:56:37.526298 +0000 UTC"
}

data.oci_file_storage_exports.exports will be read during apply
(config refers to values not yet known)
<= data "oci_file_storage_exports" "exports" {
compartment_id = "ocid1.compartment.oc1.."
exports = [
{
export_options = []
export_set_id = "ocid1.exportset.oc1.phx."
file_system_id = "ocid1.filesystem.oc1.phx."
id = "ocid1.export.oc1.phx."
path = "/myfsspaths/fs2/path1"
state = "ACTIVE"
time_created = "2020-08-31 19:31:53.948 +0000 UTC"
},
{
export_options = []
export_set_id = "ocid1.exportset.oc1.phx."
file_system_id = "ocid1.filesystem.oc1.phx."
id = "ocid1.export.oc1.phx."
path = "/myfsspaths/fs1/path1"
state = "ACTIVE"
time_created = "2020-08-31 19:31:53.782 +0000 UTC"
},
{
export_options = []
export_set_id = "ocid1.exportset.oc1.phx."
file_system_id = "ocid1.filesystem.oc1.phx."
id = "ocid1.export.oc1.phx."
path = "/myfsspaths/fs1/path2"
state = "ACTIVE"
time_created = "2020-08-31 19:31:37.706 +0000 UTC"
},
]
~ id = "2020-08-31 19:56:34.721041 +0000 UTC" -> "2020-08-31 19:56:37.793143 +0000 UTC"
}

data.oci_file_storage_file_systems.file_systems will be read during apply
(config refers to values not yet known)
<= data "oci_file_storage_file_systems" "file_systems" {
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
file_systems = [
{
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
defined_tags = {
"example-tag-namespace-all.example-tag" = "value"
}
display_name = "my_fs_1"
freeform_tags = {
"Department" = "Finance"
}
id = "ocid1.filesystem.oc1.phx."
kms_key_id = ""
metered_bytes = "0"
state = "ACTIVE"
time_created = "2020-08-31 19:31:25.483 +0000 UTC"
},
{
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
defined_tags = {
"example-tag-namespace-all.example-tag" = "value"
}
display_name = "my_fs_2"
freeform_tags = {
"Department" = "Accounting"
}
id = "ocid1.filesystem.oc1.phx."
kms_key_id = ""
metered_bytes = "0"
state = "ACTIVE"
time_created = "2020-08-31 19:31:24.207 +0000 UTC"
},
]
~ id = "2020-08-31 19:56:34.95778 +0000 UTC" -> "2020-08-31 19:56:37.609995 +0000 UTC"
}

data.oci_file_storage_mount_targets.mount_targets will be read during apply
(config refers to values not yet known)
<= data "oci_file_storage_mount_targets" "mount_targets" {
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
~ id = "2020-08-31 19:56:35.435847 +0000 UTC" -> "2020-08-31 19:56:37.54332 +0000 UTC"
mount_targets = [
{
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
defined_tags = {
"example-tag-namespace-all.example-tag" = "value"
}
display_name = "my_mount_target_1"
export_set_id = "ocid1.exportset.oc1.phx."
freeform_tags = {
"Department" = "Finance"
}
hostname_label = ""
id = "ocid1.mounttarget.oc1.phx."
ip_address = ""
lifecycle_details = ""
nsg_ids = [
"ocid1.networksecuritygroup.oc1.phx.",
]
private_ip_ids = [
"ocid1.privateip.oc1.phx.",
]
state = "ACTIVE"
subnet_id = "ocid1.subnet.oc1.phx."
time_created = "2020-08-31 19:31:38.67 +0000 UTC"
},
{
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
defined_tags = {
"example-tag-namespace-all.example-tag" = "value"
}
display_name = "my_mount_target_2"
export_set_id = "ocid1.exportset.oc1.phx."
freeform_tags = {
"Department" = "Accounting"
}
hostname_label = ""
id = "ocid1.mounttarget.oc1.phx."
ip_address = ""
lifecycle_details = ""
nsg_ids = [
"ocid1.networksecuritygroup.oc1.phx.",
]
private_ip_ids = [
"ocid1.privateip.oc1.phx.",
]
state = "ACTIVE"
subnet_id = "ocid1.subnet.oc1.phx."
time_created = "2020-08-31 19:31:27.404 +0000 UTC"
},
{
availability_domain = "NyKp:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1.."
defined_tags = {
"example-tag-namespace-all.example-tag" = "updatedValue"
}
display_name = "displayName2"
export_set_id = "ocid1.exportset.oc1.phx."
freeform_tags = {
"Department" = "Accounting"
}
hostname_label = ""
id = "ocid1.mounttarget.oc1.phx."
ip_address = ""
lifecycle_details = ""
nsg_ids = []
private_ip_ids = []
state = "FAILED"
subnet_id = "ocid1.subnet.oc1.phx."
time_created = "2020-06-16 02:44:09.658 +0000 UTC"
},
]
}

data.oci_file_storage_snapshots.snapshots will be read during apply
(config refers to values not yet known)
<= data "oci_file_storage_snapshots" "snapshots" {
file_system_id = "ocid1.filesystem.oc1.phx."
~ id = "2020-08-31 19:56:35.581674 +0000 UTC" -> "2020-08-31 19:56:37.495245 +0000 UTC"
snapshots = [
{
defined_tags = {
"example-tag-namespace-all.example-tag" = "value"
}
file_system_id = "ocid1.filesystem.oc1.phx."
freeform_tags = {
"Department" = "Finance"
}
id = "ocid1.snapshot.oc1.phx."
name = "20180320_daily"
state = "ACTIVE"
time_created = "2020-08-31 19:31:27.419 +0000 UTC"
},
]
}

Plan: 0 to add, 0 to change, 0 to destroy.

`

` $ tf13 -v
2020/08/31 12:56:49 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
Use TF_LOG=TRACE to see Terraform's internal logs.

2020/08/31 12:56:49 [INFO] Terraform version: 0.13.1
2020/08/31 12:56:49 [INFO] Go runtime version: go1.14.7
2020/08/31 12:56:49 [INFO] CLI args: []string{"/Users/srismish/TerraformVersion/Terraform13/tf13", "-v"}
2020/08/31 12:56:49 [DEBUG] Attempting to open CLI config file: /Users/srismish/.terraformrc
2020/08/31 12:56:49 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/08/31 12:56:49 [DEBUG] checking for credentials in "/Users/srismish/.terraform.d/plugins"
2020/08/31 12:56:49 [DEBUG] checking for credentials in "/Users/srismish/.terraform.d/plugins/darwin_amd64"
2020/08/31 12:56:49 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2020/08/31 12:56:49 [DEBUG] will search for provider plugins in /Users/srismish/.terraform.d/plugins
2020/08/31 12:56:49 [DEBUG] ignoring non-existing provider search directory /Users/srismish/Library/Application Support/io.terraform/plugins
2020/08/31 12:56:49 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2020/08/31 12:56:49 [INFO] CLI command args: []string{"version", "-v"}
2020/08/31 12:56:50 [ERR] Checkpoint error: Get "https://checkpoint-api.hashicorp.com/v1/check/terraform?arch=amd64&os=darwin&signature=b719ef91-1e5c-0a4b-7381-4bb6f8cf5b26&version=0.13.1": x509: certificate signed by unknown authority
Terraform v0.13.1

  • provider registry.terraform.io/-/null v2.1.2
  • provider registry.terraform.io/-/oci v3.90.1
  • provider registry.terraform.io/hashicorp/null v2.1.2
  • provider registry.terraform.io/hashicorp/oci v3.90.1`

Terraform version13.1
oci provider version : 3.90.1

Is it possible to share the config you're using?

@tutorialbyexample
Copy link
Author

++++++++++++++++++++++++++++++++++++++++
terraform -v
Terraform v0.13.1

Initializing the backend...

Initializing provider plugins...

  • Finding hashicorp/oci versions matching ">= 3.0.0"...
  • Installing hashicorp/oci v3.90.1...
  • Installed hashicorp/oci v3.90.1 (signed by HashiCorp)

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

kumvinov-mac:tf_tee_storage-tf-0.13.0 kumvinov$ terraform apply -var-file="phx_l.tfvars"
module.ads.data.oci_identity_availability_domains.ads: Refreshing state...
module.compartments.data.oci_identity_compartments.compartments: Refreshing state...
module.compartments_network.data.oci_identity_compartments.compartments: Refreshing state...
module.compartments_environment.data.oci_identity_compartments.compartments: Refreshing state...
module.vcns.data.oci_core_vcns.vcns: Refreshing state...
module.nsgs.data.oci_core_network_security_groups.nsgs: Refreshing state...
module.subnets.data.oci_core_subnets.subnets: Refreshing state...

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:

  • create
    <= read (data resources)

Terraform will perform the following actions:

data.oci_file_storage_export_sets.export_sets will be read during apply

(config refers to values not yet known)

<= data "oci_file_storage_export_sets" "export_sets" {
+ availability_domain = "WrnJ:PHX-AD-1"
+ compartment_id = "ocid1.compartment.oc1..aaaaaaaarka"
+ export_sets = (known after apply)
}

data.oci_file_storage_file_systems.fss will be read during apply

(config refers to values not yet known)

<= data "oci_file_storage_file_systems" "fss" {
+ availability_domain = "WrnJ:PHX-AD-1"
+ compartment_id = "ocid1.compartment.oc1..aaaaaaamnbka"
+ file_systems = (known after apply)
}

data.oci_file_storage_mount_targets.mount_targets will be read during apply

(config refers to values not yet known)

<= data "oci_file_storage_mount_targets" "mount_targets" {
+ availability_domain = "WrnJ:PHX-AD-1"
+ compartment_id = "ocid1.compartment.oc1..aaaaaaaanbka"
+ mount_targets = (known after apply)
}

module.export["phxl1-dbbackend-001"].oci_file_storage_export.export[0] will be created

  • resource "oci_file_storage_export" "export" {
    • export_set_id = (known after apply)

    • file_system_id = (known after apply)

    • id = (known after apply)

    • path = "/phxl1-dbbackend-001"

    • state = (known after apply)

    • time_created = (known after apply)

    • export_options {

      • access = "READ_WRITE"
      • anonymous_gid = "65534"
      • anonymous_uid = "65534"
      • identity_squash = "NONE"
      • require_privileged_source_port = false
      • source = "10.152.104.0/24"
        }
        }

module.export_set["phxl1-dbbackend-001"].oci_file_storage_export_set.export_set[0] will be created

  • resource "oci_file_storage_export_set" "export_set" {
    • availability_domain = (known after apply)
    • compartment_id = (known after apply)
    • display_name = "phxl1-dbbackend-001"
    • id = (known after apply)
    • max_fs_stat_bytes = "23843202333"
    • max_fs_stat_files = "223442"
    • mount_target_id = (known after apply)
    • state = (known after apply)
    • time_created = (known after apply)
    • vcn_id = (known after apply)
      }

module.fss["phxl1-filesystem-dbbackend-001"].oci_file_storage_file_system.fss[0] will be created

  • resource "oci_file_storage_file_system" "fss" {
    • availability_domain = "WrnJ:PHX-AD-1"
    • compartment_id = "ocid1.compartment.oc1..aaaaaaa4qdbue2mnbka"
    • defined_tags = (known after apply)
    • display_name = "phxl1-filesystem-dbbackend-001"
    • freeform_tags = {
      • "Environment" = "Lab"
      • "Purpose" = "Terraform"
      • "Region_function" = "Primary"
        }
    • id = (known after apply)
    • metered_bytes = (known after apply)
    • state = (known after apply)
    • time_created = (known after apply)
      }

module.mount_target["phxl1-mount_target-control-001"].oci_file_storage_mount_target.mount_target[0] will be created

  • resource "oci_file_storage_mount_target" "mount_target" {
    • availability_domain = "WrnJ:PHX-AD-1"
    • compartment_id = "ocid1.compartment.oc1..aaaaaamnbka"
    • defined_tags = (known after apply)
    • display_name = "phxl1-mount_target-control-001"
    • export_set_id = (known after apply)
    • freeform_tags = {
      • "Environment" = "Lab"
      • "Purpose" = "Terraform"
      • "Region_function" = "Primary"
        }
    • id = (known after apply)
    • ip_address = "10.152.104.251"
    • lifecycle_details = (known after apply)
    • nsg_ids = [
      • "ocid1.networksecuritygroup.oc1.phxszvj3p6pxa",
        ]
    • private_ip_ids = (known after apply)
    • state = (known after apply)
    • subnet_id = "ocid1.subnet.oc1.phx.aaa4zqv5voz4jwithtrksta"
    • time_created = (known after apply)
      }

module.mount_target["phxl1-mount_target-data-001"].oci_file_storage_mount_target.mount_target[0] will be created

  • resource "oci_file_storage_mount_target" "mount_target" {
    • availability_domain = "WrnJ:PHX-AD-1"
    • compartment_id = "ocid1.compartment.oc1..aaaaaaamnbka"
    • defined_tags = (known after apply)
    • display_name = "phxl1-mount_target-data-001"
    • export_set_id = (known after apply)
    • freeform_tags = {
      • "Environment" = "Lab"
      • "Purpose" = "Terraform"
      • "Region_function" = "Primary"
        }
    • id = (known after apply)
    • ip_address = "10.xxx.32.251"
    • lifecycle_details = (known after apply)
    • nsg_ids = [
      • "ocid1.networksecuritygroup.oc1.phx.aaaaaaxa",
        ]
    • private_ip_ids = (known after apply)
    • state = (known after apply)
    • subnet_id = "ocid1.subnet.oc1.phx.aaaaagq"
    • time_created = (known after apply)
      }

Plan: 5 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

module.fss["phxl1-filesystem-dbbackend-001"].oci_file_storage_file_system.fss[0]: Creating...
module.mount_target["phxl1-mount_target-control-001"].oci_file_storage_mount_target.mount_target[0]: Creating...
module.mount_target["phxl1-mount_target-data-001"].oci_file_storage_mount_target.mount_target[0]: Creating...
module.fss["phxl1-filesystem-dbbackend-001"].oci_file_storage_file_system.fss[0]: Creation complete after 4s [id=ocid1.filesystem.oc1.phx.aaaaaaaaaaa]
data.oci_file_storage_file_systems.fss: Reading...
data.oci_file_storage_file_systems.fss: Read complete after 1s [id=2020-09-02 11:01:34.804899 +0000 UTC]
module.mount_target["phxl1-mount_target-data-001"].oci_file_storage_mount_target.mount_target[0]: Still creating... [10s elapsed]
module.mount_target["phxl1-mount_target-control-001"].oci_file_storage_mount_target.mount_target[0]: Still creating... [10s elapsed]
module.mount_target["phxl1-mount_target-control-001"].oci_file_storage_mount_target.mount_target[0]: Still creating... [20s elapsed]
module.mount_target["phxl1-mount_target-data-001"].oci_file_storage_mount_target.mount_target[0]: Still creating... [20s elapsed]
module.mount_target["phxl1-mount_target-data-001"].oci_file_storage_mount_target.mount_target[0]: Creation complete after 23s [id=ocid1.mounttarget.oc1.aa]
module.mount_target["phxl1-mount_target-control-001"].oci_file_storage_mount_target.mount_target[0]: Still creating... [30s elapsed]
module.mount_target["phxl1-mount_target-control-001"].oci_file_storage_mount_target.mount_target[0]: Creation complete after 40s [id=ocid1.mounttarget.oc1.phx.aaaaaaaa]
data.oci_file_storage_mount_targets.mount_targets: Reading...
data.oci_file_storage_mount_targets.mount_targets: Read complete after 0s [id=2020-09-02 11:02:10.191313 +0000 UTC]
module.export_set["phxl1-dbbackend-001"].oci_file_storage_export_set.export_set[0]: Creating...
module.export_set["phxl1-dbbackend-001"].oci_file_storage_export_set.export_set[0]: Creation complete after 1s [id=ocid1.exportset.oc1.phx.aaaaaaa]
data.oci_file_storage_export_sets.export_sets: Reading...
data.oci_file_storage_export_sets.export_sets: Read complete after 0s [id=2020-09-02 11:02:11.317584 +0000 UTC]
module.export["phxl1-dbbackend-001"].oci_file_storage_export.export[0]: Creating...
module.export["phxl1-dbbackend-001"].oci_file_storage_export.export[0]: Creation complete after 7s [id=ocid1.export.oc1.phx.aaazaaaaa]

Apply complete! Resources: 5 added, 0 changed, 0 destroyed.

Outputs:

fss_id = {
"phxl1-filesystem-dbbackend-001" = "ocid1.filesystem.oc1.phx.aaaaaaaa"
}
mount_targets_id = {
"phxl1-mount_target-control-001" = "ocid1.mounttarget.oc1.phx.aaaaabaa"
"phxl1-mount_target-data-001" = "ocid1.mounttarget.oc1.phx.aaaaaaaaaa"
}


Resource created successfully, once again we perform apply it will prompt to create again.


kumvinov-mac:tf_tee_storage-tf-0.13.0 kumvinov$ terraform apply -var-file="phx_l.tfvars"
module.ads.data.oci_identity_availability_domains.ads: Refreshing state... [id=2020-09-02 11:01:22.358135 +0000 UTC]
module.compartments.data.oci_identity_compartments.compartments: Refreshing state... [id=2020-09-02 11:01:22.389357 +0000 UTC]
module.compartments_environment.data.oci_identity_compartments.compartments: Refreshing state... [id=2020-09-02 11:01:23.023335 +0000 UTC]
module.compartments_network.data.oci_identity_compartments.compartments: Refreshing state... [id=2020-09-02 11:01:22.980959 +0000 UTC]
module.vcns.data.oci_core_vcns.vcns: Refreshing state... [id=2020-09-02 11:01:24.735017 +0000 UTC]
module.fss["phxl1-filesystem-dbbackend-001"].oci_file_storage_file_system.fss[0]: Refreshing state... [id=ocid1.filesystem.oc1.phx.aaaaaaaa]
data.oci_file_storage_file_systems.fss: Refreshing state... [id=2020-09-02 11:01:34.804899 +0000 UTC]
module.subnets.data.oci_core_subnets.subnets: Refreshing state... [id=2020-09-02 11:01:25.605172 +0000 UTC]
module.nsgs.data.oci_core_network_security_groups.nsgs: Refreshing state... [id=2020-09-02 11:01:26.006074 +0000 UTC]
module.mount_target["phxl1-mount_target-data-001"].oci_file_storage_mount_target.mount_target[0]: Refreshing state... [id=ocid1.mounttarget.oc1.phx.aaaaaaa]
module.mount_target["phxl1-mount_target-control-001"].oci_file_storage_mount_target.mount_target[0]: Refreshing state... [id=ocid1.mounttarget.oc1.phx.aaaaaaa]
data.oci_file_storage_mount_targets.mount_targets: Refreshing state... [id=2020-09-02 11:02:10.191313 +0000 UTC]
module.export_set["phxl1-dbbackend-001"].oci_file_storage_export_set.export_set[0]: Refreshing state... [id=ocid1.exportset.oc1.phx.aaaaaaaa]
data.oci_file_storage_export_sets.export_sets: Refreshing state... [id=2020-09-02 11:02:11.317584 +0000 UTC]
module.export["phxl1-dbbackend-001"].oci_file_storage_export.export[0]: Refreshing state... [id=ocid1.export.oc1.phx.aaaaaby2aa]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
<= read (data resources)

Terraform will perform the following actions:

data.oci_file_storage_export_sets.export_sets will be read during apply

(config refers to values not yet known)

<= data "oci_file_storage_export_sets" "export_sets" {
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaanbka"
~ export_sets = [
- {
- availability_domain = "WrnJ:PHX-AD-1"
- compartment_id = "ocid1.compartment.oc1..aaaaaaaarmnbka"
- display_name = "phxl1-dbbackend-001"
- id = "ocid1.exportset.oc1.phx.aaaaaa"
- max_fs_stat_bytes = ""
- max_fs_stat_files = ""
- mount_target_id = ""
- state = "ACTIVE"
- time_created = "2020-09-02 11:01:58.275 +0000 UTC"
- vcn_id = "ocid1.vcn.oc1.phx.ama47q"
},
- {
- availability_domain = "WrnJ:PHX-AD-1"
- compartment_id = "ocid1.compartment.oc1..aaaaanbka"
- display_name = "phxl1-mount_target-data-001 - export set"
- id = "ocid1.exportset.oc1.phx.aaaaaa"
- max_fs_stat_bytes = ""
- max_fs_stat_files = ""
- mount_target_id = ""
- state = "ACTIVE"
- time_created = "2020-09-02 11:01:32.761 +0000 UTC"
- vcn_id = "ocid1.vcn.oc1.phx.amaaaaxjl47q"
},
] -> (known after apply)
- id = "2020-09-02 11:02:29.274029 +0000 UTC" -> null
}

data.oci_file_storage_file_systems.fss will be read during apply

(config refers to values not yet known)

<= data "oci_file_storage_file_systems" "fss" {
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaarbka"
file_systems = [
{
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaanbka"
defined_tags = {
"Oracle-Tags.CreatedBy" = "xxxxx@oracle.com"
"Oracle-Tags.CreatedOn" = "2020-09-02T11:01:32.467Z"
}
display_name = "phxl1-filesystem-dbbackend-001"
freeform_tags = {
"Environment" = "Lab"
"Purpose" = "Terraform"
"Region_function" = "Primary"
}
id = "ocid1.filesystem.oc1.phx.aaaaaaaa"
kms_key_id = ""
metered_bytes = "0"
state = "ACTIVE"
time_created = "2020-09-02 11:01:32.471 +0000 UTC"
},
]
~ id = "2020-09-02 11:02:26.211523 +0000 UTC" -> "2020-09-02 11:02:31.884768 +0000 UTC"
}

data.oci_file_storage_mount_targets.mount_targets will be read during apply

(config refers to values not yet known)

<= data "oci_file_storage_mount_targets" "mount_targets" {
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaka"
~ id = "2020-09-02 11:02:28.59168 +0000 UTC" -> "2020-09-02 11:02:31.952888 +0000 UTC"
mount_targets = [
{
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaarla"
defined_tags = {
"Oracle-Tags.CreatedBy" = "xxxxxxar@oracle.com"
"Oracle-Tags.CreatedOn" = "2020-09-02T11:01:58.149Z"
}
display_name = "phxl1-mount_target-control-001"
export_set_id = "ocid1.exportset.oc1.phx.aaaaa"
freeform_tags = {
"Environment" = "Lab"
"Purpose" = "Terraform"
"Region_function" = "Primary"
}
hostname_label = ""
id = "ocid1.mounttarget.oc1.phx.aaaaaaa"
ip_address = ""
lifecycle_details = ""
nsg_ids = [
"ocid1.networksecuritygroup.oc1.phx.aaaaa",
]
private_ip_ids = [
"ocid1.privateip.oc1.phx.aaaaaca",
]
state = "ACTIVE"
subnet_id = "ocid1.subnet.oc1.phx.aaathtrksta"
time_created = "2020-09-02 11:01:58.275 +0000 UTC"
},
{
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaarlka"
defined_tags = {
"Oracle-Tags.CreatedBy" = "xxxxx@oracle.com"
"Oracle-Tags.CreatedOn" = "2020-09-02T11:01:32.705Z"
}
display_name = "phxl1-mount_target-data-001"
export_set_id = "ocid1.exportset.oc1.phx.aaa"
freeform_tags = {
"Environment" = "Lab"
"Purpose" = "Terraform"
"Region_function" = "Primary"
}
hostname_label = ""
id = "ocid1.mounttarget.oc1.phx.aaaaaa"
ip_address = ""
lifecycle_details = ""
nsg_ids = [
"ocid1.networksecuritygroup.oc1.phx.aaaxa",
]
private_ip_ids = [
"ocid1.privateip.oc1.phx.aaaaaacq",
]
state = "ACTIVE"
subnet_id = "ocid1.subnet.oc1.phx.aaaaa2gq"
time_created = "2020-09-02 11:01:32.761 +0000 UTC"
},
]
}

module.export["phxl1-dbbackend-001"].oci_file_storage_export.export[0] must be replaced

-/+ resource "oci_file_storage_export" "export" {
~ export_set_id = "ocid1.exportset.oc1.phx.aaaaabaaaaa" -> (known after apply) # forces replacement
file_system_id = "ocid1.filesystem.oc1.phx.aaaaaaaaaaaaa"
~ id = "ocid1.export.oc1.phx.aaaaabaaaaa" -> (known after apply)
path = "/phxl1-dbbackend-001"
~ state = "ACTIVE" -> (known after apply)
~ time_created = "2020-09-02 11:02:12.801 +0000 UTC" -> (known after apply)

    export_options {
        access                         = "READ_WRITE"
        anonymous_gid                  = "65534"
        anonymous_uid                  = "65534"
        identity_squash                = "NONE"
        require_privileged_source_port = false
        source                         = "10.152.104.0/24"
    }
}

Plan: 1 to add, 0 to change, 1 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value:

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Point for this issue is still id getting new value after apply.

<= data "oci_file_storage_mount_targets" "mount_targets" {
availability_domain = "WrnJ:PHX-AD-1"
compartment_id = "ocid1.compartment.oc1..aaaaaaaka"
~ id = "2020-09-02 11:02:28.59168 +0000 UTC" -> "2020-09-02 11:02:31.952888 +0000 UTC"

Thanks

@tutorialbyexample
Copy link
Author

data "oci_file_storage_mount_targets" "mount_targets" {
#Required
availability_domain = "${lookup(module.ads.ads.availability_domains["0"],"name")}"
compartment_id = local.remote_compartments_environment_child_id[var.compartments_environment_child]

depends_on = [ module.mount_target.mount_target ]

}

locals {
remote_mount_targets_id = { for i in data.oci_file_storage_mount_targets.mount_targets.mount_targets : i.display_name => i.id }
}

output mount_targets_id {
value = local.remote_mount_targets_id
}

@varmax2511
Copy link
Member

A new terraform provider version has been released with deterministic data source ids https://github.com/terraform-providers/terraform-provider-oci/releases/tag/v4.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants