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

getting failure message "The following resource attribute(s) had multiple entries: accountId" #5471

Open
gvolpe1968 opened this issue Jun 25, 2024 · 5 comments
Labels
service/IAM Issues related to IAM

Comments

@gvolpe1968
Copy link

gvolpe1968 commented Jun 25, 2024

terraform --version
Terraform v1.8.4
on darwin_arm64
+ provider registry.terraform.io/ibm-cloud/ibm v1.67.0-beta0

Your version of Terraform is out of date! The latest version
is 1.8.5. You can update by downloading from https://www.terraform.io/downloads.html
  • ibm_iam_access_group_policy
  • ibm_iam_trusted_profile_policy
  • ibm_iam_service_policy

I have an error on the TF provider while working with IAM policies

I'm getting

     "Result": {
        "errors": [
             {
                 "code": "invalid_body",
                 "message": "The following resource attribute(s) had multiple entries: accountId"
            }
         ],
         "status_code": 400,
         "trace": "a51ade43426f4c72a4dfbd9cecbdebc4"
    },

for all policies but there are no multiple instances of the given accountId entry really

@github-actions github-actions bot added the service/IAM Issues related to IAM label Jun 25, 2024
@hkantare
Copy link
Collaborator

@Rajesh-Pirati Can you look into this

@Rajesh-Pirati
Copy link
Contributor

we could see multiple accountId's in the input payload based on your transaction-id and please find below snippet.

            "transaction-id": "a51ade43426f4c72a4dfbd9cecbdebc4"
        },
        "header_bytes_estimate": 2743,
        "remote_address": "undefined",
        "body": {
            "description": "(Migrated) Auto-generated for key 85059df6-ca1d-456f-985a-d0d49c233441",
            "resources": [
                {
                    "attributes": [
                        {
                            "name": "accountId",
                            "value": "xxxxxx",
                            "operator": "stringEquals"
                        },
                        {
                            "name": "serviceName",
                            "value": "logs",
                            "operator": "stringEquals"
                        },
                        {
                            "name": "accountId",
                            "value": "xxxxx",
                            "operator": "stringEquals"
                        }
                    ]
                }
            ],

Have you included accountId details in the terraform configurations?

@gvolpe1968
Copy link
Author

what do you mean by configration ?
this is the working folder

$ ls -la
total 48
drwxr-xr-x  9 gianluca  staff   288 Jun 25 18:39 .
drwxr-xr-x  6 gianluca  staff   192 Jun 25 18:39 ..
-rw-r--r--@ 1 gianluca  staff  1590 Jun 25 18:39 iam_groups.tf
-rw-r--r--@ 1 gianluca  staff   942 Jun 25 18:39 iam_profiles.tf
-rw-r--r--@ 1 gianluca  staff  1765 Jun 25 18:39 iam_service_ids.tf
-rw-r--r--  1 gianluca  staff     0 Jun 25 18:39 iam_users.tf
-rwxr-xr-x  1 gianluca  staff    25 Jun 25 18:39 provider.tf
-rwxr-xr-x  1 gianluca  staff   590 Jun 25 18:39 variable.tf
-rwxr-xr-x  1 gianluca  staff   154 Jun 25 18:39 version.tf

$ grep -i accountid *
iam_groups.tf:	 	name  = "accountId"
iam_groups.tf:	 	name  = "accountId"
iam_groups.tf:	 	name  = "accountId"
iam_profiles.tf:	 	name  = "accountId"
iam_profiles.tf:	 	name  = "accountId"
iam_service_ids.tf:	 	name  = "accountId"
iam_service_ids.tf:	 	name  = "accountId"
iam_service_ids.tf:	 	name  = "accountId"

@gvolpe1968
Copy link
Author

the following is one of the files that are returning the duplication error
as you can see there is only one accountId per resource

$ cat iam_service_ids.tf 
 resource "ibm_iam_service_policy" "policy-1719333557384794" {
	 iam_service_id = "ServiceId-5e6e3c48-33b4-49a9-8bc3-c722bea0d2d9"
	 roles = ["Reader"]
	 #source_policy_id:4cbe5998-728e-4eef-b56c-d26698303a36
	 description = "(Migrated) "
 
    resource_attributes {
	    name  = "serviceName"
	    value = "logs"
    }
    resource_attributes {
	 	name  = "accountId"
	 	value = "81de6380e6232019c6567c9c8de6dece"
	 	operator = "stringEquals"
    }



}
 resource "ibm_iam_service_policy" "policy-1719333561642596" {
	 iam_service_id = "ServiceId-d4a009dc-98ab-4ac8-991c-ae377e73e67c"
	 roles = ["Administrator"]
	 #source_policy_id:23b021b6-0aec-4dbf-b6f1-69d2f79a799f
	 description = "(Migrated) Auto-generated for key crn:v1:bluemix:public:logdnaat:eu-es:a/81de6380e6232019c6567c9c8de6dece:bd9ca767-c8ce-45a6-8148-45c563208161:resource-key:14c255cd-f17c-4820-bb67-974da5639c42"
 
    resource_attributes {
	    name  = "serviceName"
	    value = "logs"
    }
    resource_attributes {
	 	name  = "resource_instance_id"
	 	value = "409a4c23-073d-4273-9c6d-3111307be016"
	 	operator = "stringEqual"
    }
    resource_attributes {
	 	name  = "accountId"
	 	value = "81de6380e6232019c6567c9c8de6dece"
	 	operator = "stringEquals"
    }



}
 resource "ibm_iam_service_policy" "policy-1719333583331487" {
	 iam_service_id = "ServiceId-d199f18e-fd6d-402a-b873-ea615751cf8d"
	 roles = ["Viewer","Writer"]
	 #source_policy_id:2f40191e-1340-4c6d-8ed3-47860ac0d723
	 description = "(Migrated) Auto-generated for key 85059df6-ca1d-456f-985a-d0d49c233441"
 
    resource_attributes {
	    name  = "serviceName"
	    value = "logs"
    }
    resource_attributes {
	 	name  = "accountId"
	 	value = "81de6380e6232019c6567c9c8de6dece"
	 	operator = "stringEquals"
    }



}

@Rajesh-Pirati
Copy link
Contributor

name = "accountId" attribute is not required. Please remove and try.
more info : https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_service_policy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service/IAM Issues related to IAM
Projects
None yet
Development

No branches or pull requests

3 participants