Open pauljegouic opened 4 months ago
For the same template, I got 2 configs that are in success with following logs:
2024/07/04 06:39:11 Terraform plan | Note: Objects have changed outside of Terraform
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | Terraform detected the following changes made outside of Terraform since the
2024/07/04 06:39:11 Terraform plan | last "terraform apply" which may have affected this plan:
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | # module.iz_environment.module.cos.ibm_cos_bucket.cos_bucket[0] has changed
2024/07/04 06:39:11 Terraform plan | ~ resource "ibm_cos_bucket" "cos_bucket" {
2024/07/04 06:39:11 Terraform plan | id = "crn:v1:bluemix:public:cloud-object-storage:global:a/3f2cae45b0644f6d87aefcf404f5987f:85d451f7-57fa-48ae-8f0c-9b166420f246:bucket:env-guardium-cos-bucket:meta:rl:eu-fr2:direct"
2024/07/04 06:39:11 Terraform plan | ~ s3_endpoint_public = "s3.direct.eu-fr2.cloud-object-storage.appdomain.cloud" -> "s3.eu-fr2.cloud-object-storage.appdomain.cloud"
2024/07/04 06:39:11 Terraform plan | # (12 unchanged attributes hidden)
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | # (2 unchanged blocks hidden)
2024/07/04 06:39:11 Terraform plan | }
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | Unless you have made equivalent changes to your configuration, or ignored the
2024/07/04 06:39:11 Terraform plan | relevant attributes using ignore_changes, the following plan may include
2024/07/04 06:39:11 Terraform plan | actions to undo or respond to these changes.
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | ─────────────────────────────────────────────────────────────────────────────
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | Terraform used the selected providers to generate the following execution
2024/07/04 06:39:11 Terraform plan | plan. Resource actions are indicated with the following symbols:
2024/07/04 06:39:11 Terraform plan | ~ update in-place
2024/07/04 06:39:11 Terraform plan | -/+ destroy and then create replacement
2024/07/04 06:39:11 Terraform plan | <= read (data resources)
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | Terraform will perform the following actions:
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | # module.iz_environment.module.access_groups["project"].ibm_iam_trusted_profile_policy.this["account"] will be updated in-place
2024/07/04 06:39:11 Terraform plan | ~ resource "ibm_iam_trusted_profile_policy" "this" {
2024/07/04 06:39:11 Terraform plan | ~ account_management = true -> false
2024/07/04 06:39:11 Terraform plan | id = "Profile-94eaf97d-1f18-4f56-9cff-f18dcf06af3b/47460373-04f4-4c60-af08-0e7694bc0748"
2024/07/04 06:39:11 Terraform plan | # (4 unchanged attributes hidden)
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | # (1 unchanged block hidden)
2024/07/04 06:39:11 Terraform plan | }
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | # module.iz_environment.module.iz_project.data.external.env will be read during apply
2024/07/04 06:39:11 Terraform plan | # (depends on a resource or a module with changes pending)
2024/07/04 06:39:11 Terraform plan | <= data "external" "env" {
2024/07/04 06:39:11 Terraform plan | + id = (known after apply)
2024/07/04 06:39:11 Terraform plan | + program = [
2024/07/04 06:39:11 Terraform plan | + ".terraform/modules/iz_environment.iz_project/scripts/extract_env_vars.sh",
2024/07/04 06:39:11 Terraform plan | ]
2024/07/04 06:39:11 Terraform plan | + result = (known after apply)
2024/07/04 06:39:11 Terraform plan | }
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | # module.iz_environment.module.iz_project.data.ibm_iam_trusted_profile.trusted_profile[0] will be read during apply
2024/07/04 06:39:11 Terraform plan | # (depends on a resource or a module with changes pending)
2024/07/04 06:39:11 Terraform plan | <= data "ibm_iam_trusted_profile" "trusted_profile" {
2024/07/04 06:39:11 Terraform plan | + account_id = (known after apply)
2024/07/04 06:39:11 Terraform plan | + assignment_id = (known after apply)
2024/07/04 06:39:11 Terraform plan | + created_at = (known after apply)
2024/07/04 06:39:11 Terraform plan | + crn = (known after apply)
2024/07/04 06:39:11 Terraform plan | + description = (known after apply)
2024/07/04 06:39:11 Terraform plan | + entity_tag = (known after apply)
2024/07/04 06:39:11 Terraform plan | + history = (known after apply)
2024/07/04 06:39:11 Terraform plan | + iam_id = (known after apply)
2024/07/04 06:39:11 Terraform plan | + id = (known after apply)
2024/07/04 06:39:11 Terraform plan | + ims_account_id = (known after apply)
2024/07/04 06:39:11 Terraform plan | + ims_user_id = (known after apply)
2024/07/04 06:39:11 Terraform plan | + modified_at = (known after apply)
2024/07/04 06:39:11 Terraform plan | + name = (known after apply)
2024/07/04 06:39:11 Terraform plan | + profile_id = "Profile-94eaf97d-1f18-4f56-9cff-f18dcf06af3b"
2024/07/04 06:39:11 Terraform plan | + template_id = (known after apply)
2024/07/04 06:39:11 Terraform plan | }
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | # module.iz_environment.module.iz_project.ibm_project_environment.this[0] will be updated in-place
2024/07/04 06:39:11 Terraform plan | ~ resource "ibm_project_environment" "this" {
2024/07/04 06:39:11 Terraform plan | id = "cd5ad037-9d86-4c9f-be7a-55a07060258f/bf4c303e-927a-402b-b910-3ed0fbfb7415"
2024/07/04 06:39:11 Terraform plan | # (7 unchanged attributes hidden)
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | ~ definition {
2024/07/04 06:39:11 Terraform plan | name = "env-guardium-project-environment"
2024/07/04 06:39:11 Terraform plan | # (2 unchanged attributes hidden)
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | ~ authorizations {
2024/07/04 06:39:11 Terraform plan | ~ trusted_profile_id = "Profile-94eaf97d-1f18-4f56-9cff-f18dcf06af3b" -> (known after apply)
2024/07/04 06:39:11 Terraform plan | # (1 unchanged attribute hidden)
2024/07/04 06:39:11 Terraform plan | }
2024/07/04 06:39:11 Terraform plan | }
2024/07/04 06:39:11 Terraform plan | }
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | # module.iz_environment.module.iz_project.null_resource.attach_project_crn[0] must be replaced
2024/07/04 06:39:11 Terraform plan | -/+ resource "null_resource" "attach_project_crn" {
2024/07/04 06:39:11 Terraform plan | ~ id = "3636325891913538248" -> (known after apply)
2024/07/04 06:39:11 Terraform plan | ~ triggers = { # forces replacement
2024/07/04 06:39:11 Terraform plan | ~ "always_run" = "2024-06-27T14:45:35Z" -> (known after apply)
2024/07/04 06:39:11 Terraform plan | }
2024/07/04 06:39:11 Terraform plan | }
2024/07/04 06:39:11 Terraform plan |
2024/07/04 06:39:11 Terraform plan | Plan: 1 to add, 2 to change, 1 to destroy.
2024/07/04 06:39:11 Command finished successfully.
hi Paul, the problem is at project level (not config level), can you send a sample of source TF file with the offending project resource definition? (resource "ibm_project" "project_instance")
I won't be able to do it here for internal reasons. @hkantare any chance @riccardo-angelilli can jump into the Slack channel ?
@riccardo-angelilli I transfered the archive to Harini.
I'm not able to reproduce the issue, but I think this can be the fix https://github.com/IBM-Cloud/terraform-provider-ibm/pull/5486 (the auto_deploy option was introduced in the last release)
Here is the extract of the Project part :
##################################################### Trusted Profile #####################################################
data "ibm_iam_trusted_profile" "trusted_profile" {
count = var.attach_to_existing_tp ? 1 : 0
profile_id = var.trusted_profile_id
}
data "external" "env" {
program = ["${path.module}/scripts/extract_env_vars.sh"]
}
##################################################### Project #####################################################
resource "ibm_project" "project_instance" {
definition {
description = var.description
name = var.project_name
destroy_on_delete = true
}
location = var.region
resource_group = var.resource_group
}
resource "ibm_project_environment" "this" {
count = var.attach_to_existing_tp ? 1 : 0
depends_on = [ibm_project.project_instance, data.ibm_iam_trusted_profile.trusted_profile[0], null_resource.attach_project_crn]
definition {
name = "${var.project_name}-environment"
description = "${var.description} environment"
authorizations {
method = "trusted_profile"
trusted_profile_id = data.ibm_iam_trusted_profile.trusted_profile[0].id
}
}
project_id = ibm_project.project_instance.id
}
## Attach Project CRN to trusted profile
resource "null_resource" "attach_project_crn" {
count = var.attach_to_existing_tp ? 1 : 0
triggers = {
always_run = "${timestamp()}"
}
provisioner "local-exec" {
command = <<EOT
if [ ! -z ${data.external.env.result.token} ]
then
res=$(curl -X POST 'https://iam.cloud.ibm.com/v1/profiles/${data.ibm_iam_trusted_profile.trusted_profile[0].id}/identities/crn' -H "Authorization: Bearer ${data.external.env.result.token}" -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{ "identifier": "${ibm_project.project_instance.crn}", "type": "crn", "description": "${var.project_name} attached to ${data.ibm_iam_trusted_profile.trusted_profile[0].name}" }')
echo $res
else
TOKEN=$(curl -X POST "https://iam.cloud.ibm.com/identity/token" --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --data-urlencode 'grant_type=urn:ibm:params:oauth:grant-type:apikey' --data-urlencode "apikey=${data.external.env.result.api_key}" | jq -r .access_token)
res=$(curl -X POST 'https://iam.cloud.ibm.com/v1/profiles/${data.ibm_iam_trusted_profile.trusted_profile[0].id}/identities/crn' -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{ "identifier": "${ibm_project.project_instance.crn}", "type": "crn", "description": "${var.project_name} attached to ${data.ibm_iam_trusted_profile.trusted_profile[0].name}" }')
echo $res
fi
EOT
}
}
just for test, can you please try adding
auto_deploy = false
in the definition
section of the project resource and run again?
Actually we are working with modules, deployable architecture in the catalog, and project to instiante those DA.
What you are asking take me a lot of time, thus I would need some more "confidence" on the origin of the error.
But I will do.
Just got the exact same error.
2024/07/04 10:40:01 Terraform plan | Stack trace from the terraform-provider-ibm_v1.67.0 plugin:
2024/07/04 10:40:01 Terraform plan |
2024/07/04 10:40:01 Terraform plan | panic: runtime error: invalid memory address or nil pointer dereference
2024/07/04 10:40:01 Terraform plan | [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x379a214]
2024/07/04 10:40:01 Terraform plan |
2024/07/04 10:40:01 Terraform plan | goroutine 1525 [running]:
2024/07/04 10:40:01 Terraform plan | github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/project.ResourceIbmProjectProjectDefinitionPropertiesToMap(...)
2024/07/04 10:40:01 Terraform plan | github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/project/resource_ibm_project.go:945
2024/07/04 10:40:01 Terraform plan | github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/project.resourceIbmProjectRead({0x56c49d0, 0xc0003d60e0}, 0xc001e24680, {0x4c2ab20?, 0xc000716008?})
2024/07/04 10:40:01 Terraform plan | github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/project/resource_ibm_project.go:550 +0x714
2024/07/04 10:40:01 Terraform plan | github.com/IBM-Cloud/terraform-provider-ibm/ibm/provider.wrapResource.wrapFunction.func3({0x56c49d0?, 0xc0003d60e0?}, 0x1176592e000?, {0x4c2ab20?, 0xc000716008?})
2024/07/04 10:40:01 Terraform plan | github.com/IBM-Cloud/terraform-provider-ibm/ibm/provider/provider.go:1609 +0x2c
2024/07/04 10:40:01 Terraform plan | github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc001706e00, {0x56c4928, 0xc001781350}, 0xc001e24680, {0x4c2ab20, 0xc000716008})
2024/07/04 10:40:01 Terraform plan | github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:795 +0x119
2024/07/04 10:40:01 Terraform plan | github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc001706e00, {0x56c4928, 0xc001781350}, 0xc00258c9c0, {0x4c2ab20, 0xc000716008})
2024/07/04 10:40:01 Terraform plan | github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:1089 +0x529
2024/07/04 10:40:01 Terraform plan | github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0009ab5a8, {0x56c4928?, 0xc001781290?}, 0xc002924d80)
2024/07/04 10:40:01 Terraform plan | github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:649 +0x4aa
2024/07/04 10:40:01 Terraform plan | github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0006fa000, {0x56c4928?, 0xc001780b10?}, 0xc002c60240)
2024/07/04 10:40:01 Terraform plan | github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/tf5server/server.go:789 +0x488
2024/07/04 10:40:01 Terraform plan | github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x4a9b6c0, 0xc0006fa000}, {0x56c4928, 0xc001780b10}, 0xc000395880, 0x0)
2024/07/04 10:40:01 Terraform plan | github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:431 +0x1a6
2024/07/04 10:40:01 Terraform plan | google.golang.org/grpc.(*Server).processUnaryRPC(0xc00012c780, {0x56d09c0, 0xc001832000}, 0xc002236a20, 0xc0016c1a40, 0x799c888, 0x0)
2024/07/04 10:40:01 Terraform plan | google.golang.org/grpc@v1.57.1/server.go:1358 +0xde3
2024/07/04 10:40:01 Terraform plan | google.golang.org/grpc.(*Server).handleStream(0xc00012c780, {0x56d09c0, 0xc001832000}, 0xc002236a20, 0x0)
2024/07/04 10:40:01 Terraform plan | google.golang.org/grpc@v1.57.1/server.go:1735 +0x9da
2024/07/04 10:40:01 Terraform plan | google.golang.org/grpc.(*Server).serveStreams.func1.1()
2024/07/04 10:40:01 Terraform plan | google.golang.org/grpc@v1.57.1/server.go:970 +0xbb
2024/07/04 10:40:01 Terraform plan | created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 36
2024/07/04 10:40:01 Terraform plan | google.golang.org/grpc@v1.57.1/server.go:981 +0x136
2024/07/04 10:40:01 Terraform plan |
2024/07/04 10:40:01 Terraform plan | Error: The terraform-provider-ibm_v1.67.0 plugin crashed!
With this update:
resource "ibm_project" "project_instance" {
definition {
description = var.description
name = var.project_name
auto_deploy = false
destroy_on_delete = true
}
location = var.region
resource_group = var.resource_group
}
ok, it was just an attempt to workaround the problem because I'm not able to reproduce, but evidently we need a fix
the PR https://github.com/IBM-Cloud/terraform-provider-ibm/pull/5486 has been merged by @hkantare, I would wait for the upcoming release 1.67.1 that will include the fix (wonder if the previous release 1.66.0 was working fine)
Yes I've created a new DA version that fix the provider to 1.66.0 and I got no error, the process can go on.
to reproduce, just create a Project with 1.66 and then try to re-apply with 1.67. I think you should be able to reproduce.
I have created a project with 1.66.0 and then re-applied with 1.67.0, it worked, I had no crash. Let's see if the fix works for you when we release 1.67.1
Hey Paul, I was able to reproduce your issue with an existing old project (created months ago with an old TF version, where the field auto_deploy
was not present in the data model) and the crash happens even with 1.67, so probably your project is very old (most likely created even before 1.66 was released).
When I used the new TF build I got the apply pass, so the fix we will release with 1.67.1 should work:
Yes it was an old Project. Glad to read this.
Thanks @riccardo-angelilli
Fixed with version 1.67.1
Hello there,
When using the latest provider version, I got this error.
@hkantare