terraform-provider-oci
terraform-provider-oci copied to clipboard
oci_objectstorage_object fails to create file when running on TF cloud remote
Community Note
- 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 v1.5.7 on windows_amd64
- provider registry.terraform.io/oracle/oci v5.14.0
Affected Resource(s)
oci_objectstorage_object
Terraform Configuration Files
resource "oci_objectstorage_object" "file" {
bucket = oci_objectstorage_bucket.main.name
source = abspath("files/aaa.txt")
namespace = oci_objectstorage_bucket.main.namespace
object = "aaa.txt"
}
Debug Output
2023-09-29T19:54:37.489+0200 [INFO] Terraform version: 1.5.7
2023-09-29T19:54:37.490+0200 [DEBUG] using github.com/hashicorp/go-tfe v1.26.0
2023-09-29T19:54:37.491+0200 [DEBUG] using github.com/hashicorp/hcl/v2 v2.16.2
2023-09-29T19:54:37.492+0200 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.0
2023-09-29T19:54:37.493+0200 [DEBUG] using github.com/zclconf/go-cty v1.12.2
2023-09-29T19:54:37.493+0200 [INFO] Go runtime version: go1.20.7
2023-09-29T19:54:37.493+0200 [INFO] CLI args: []string{"C:\\Users\\redacted\\AppData\\Local\\Microsoft\\WinGet\\Packages\\Hashicorp.Terraform_Microsoft.Winget.Source_8wekyb3d8bbwe\\.\\terraform.exe", "apply"}
2023-09-29T19:54:37.501+0200 [DEBUG] Attempting to open CLI config file: C:\Users\redacted\AppData\Roaming\terraform.rc
2023-09-29T19:54:37.501+0200 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2023-09-29T19:54:37.502+0200 [INFO] Loading CLI configuration from C:\Users\redacted\AppData\Roaming\terraform.d\credentials.tfrc.json
2023-09-29T19:54:37.504+0200 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2023-09-29T19:54:37.504+0200 [DEBUG] ignoring non-existing provider search directory C:\Users\redacted\AppData\Roaming\terraform.d\plugins
2023-09-29T19:54:37.506+0200 [DEBUG] ignoring non-existing provider search directory C:\Users\redacted\AppData\Roaming\HashiCorp\Terraform\plugins
2023-09-29T19:54:37.507+0200 [INFO] CLI command args: []string{"apply"}
2023-09-29T19:54:37.510+0200 [DEBUG] Service discovery for app.terraform.io at https://app.terraform.io/.well-known/terraform.json
2023-09-29T19:54:38.550+0200 [DEBUG] Service discovery for app.terraform.io aliased as localterraform.com
2023-09-29T19:54:39.066+0200 [DEBUG] checking for provisioner in "."
2023-09-29T19:54:39.066+0200 [DEBUG] checking for provisioner in "C:\\Users\\redacted\\AppData\\Local\\Microsoft\\WinGet\\Packages\\Hashicorp.Terraform_Microsoft.Winget.Source_8wekyb3d8bbwe"
2023-09-29T19:54:39.274+0200 [INFO] cloud: starting Apply operation
Running apply in Terraform Cloud. Output will stream here. Pressing Ctrl-C
will cancel the remote apply if it's still pending. If the apply started it
will stop streaming the logs, but will not stop the apply running remotely.
Preparing the remote apply...
To view this run in a browser, visit:
https://app.terraform.io/app/redacted/redacted/runs/run-tENaR8SecZuwDdqk
Waiting for the plan to start...
Terraform v1.5.7
on linux_amd64
Initializing plugins and modules...
data.oci_objectstorage_namespace.main: Refreshing...
oci_identity_compartment.main: Refreshing state... [id=ocid1.compartment.oc1..redacted]
data.oci_objectstorage_namespace.main: Refresh complete after 1s [id=ObjectStorageNamespaceDataSource-redacted]
oci_objectstorage_bucket.main: Refreshing state... [id=n/redacted/b/redacted]
2023-09-29T19:55:04.588+0200 [DEBUG] performing request: method=GET url=https://app.terraform.io/api/v2/plans/plan-redacted/json-output-redacted
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# oci_objectstorage_object.cert will be created
+ resource "oci_objectstorage_object" "cert" {
+ bucket = "redacted"
+ content_length = (known after apply)
+ content_md5 = (known after apply)
+ content_type = (known after apply)
+ delete_all_object_versions = false
+ id = (known after apply)
+ namespace = "redacted"
+ object = "aaa.txt"
+ opc_sse_kms_key_id = (known after apply)
+ source = "/home/tfc-agent/.tfc-agent/component/terraform/runs/run-redacted/config/files/aaa.txt 2023-09-29 17:54:45.860975203 +0000 UTC"
+ state = (known after apply)
+ storage_tier = (known after apply)
+ version_id = (known after apply)
+ work_request_id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
------------------------------------------------------------------------
Cost Estimation:
Resources: 0 of 3 estimated
$0.0/mo +$0.0
------------------------------------------------------------------------
2023-09-29T19:55:07.616+0200 [DEBUG] command: asking for input: "\nDo you want to perform these actions in workspace \"redacted\"?"
Do you want to perform these actions in workspace "redacted"?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
╷
│ Error: Provider produced inconsistent final plan
│
│ When expanding the plan for oci_objectstorage_object.cert to include new
│ values learned so far during apply, provider
│ "registry.terraform.io/oracle/oci" produced an invalid new value for
│ .source: was
│ cty.StringVal("/home/tfc-agent/.tfc-agent/component/terraform/runs/run-redacted/config/files/aaa.txt
│ 2023-09-29 17:54:45.860975203 +0000 UTC"), but now
│ cty.StringVal("/home/tfc-agent/.tfc-agent/component/terraform/runs/run-redacted/config/files/aaa.txt
│ 2023-09-29 17:55:25.558842516 +0000 UTC").
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵
Operation failed: failed running terraform apply (exit 1)
Panic Output
Expected Behavior
The file should have been created
Actual Behavior
It failed
Steps to Reproduce
-
terraform apply
Important Factoids
This only happens when running on Terraform Cloud remote. When running locally, it doesn't fail.
References
Thank you for reporting the issue. We have raised an internal ticket to track this. Our service engineers will get back to you.
Any update on this? This kind of issue also happens intermittently when running outside TF cloud. Maybe you can add an option to let the user choose how files are compared? Or allow to set content directly, instead of thorough a path file?
Attribute "content" already exists. Along with this attribute we also provide attributes to support content upload. eg. content_type content_md5 content_length content_language content_encoding content_disposition NOTE: "content" attribute cannot be defined if source or source_uri_details is defined. public documentation regarding these attributes can be found here :https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/objectstorage_object#source_object_if_match_etag
you can also use source attribute with lifecycle block for this purpose you can set the "ignore_changes" attribute of the lifecycle block to source along with "replace_triggered_by" according to your needs
you can get more info on the lifecycle block from the following document: https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle
since the info required has been shared. closing the issue If you are still experiencing any problems, please create a new issue.
since the info required has been shared. closing the issue If you are still experiencing any problems, please create a new issue.