CCM AWS connector update API throws invalid account id error

Before we start

To enable CCM for your AWS services (such as EC2, S3, RDS, Lambda, and so on), you simply need to connect Harness to your AWS accounts.

For that you will need a AWS connector which can be either be created/updated with API while doing so we have seen this common issues which customers generally faces while updating the connector.

Let’s have a look into this problem

Problem Statement

When trying to update a connector as per documentation https://apidocs.harness.io/tag/Connectors#operation/updateConnector,

getting this error:

{"status":"ERROR","code":"INVALID_REQUEST","message":"Invalid request: accountId in role arn does not match accountId in overview screen","correlationId":"e99f0dea-62d2-4230-b9b2-4b40032cc354","detailedMessage":null,"responseMessages":[{"code":"INVALID_REQUEST","level":"ERROR","message":"Invalid request: accountId in role arn does not match accountId in overview screen","exception":null,"failureTypes":[]}],"metadata":null}

Coming to the solution

To update the connector successfully you need to include awsAccountId with your API request which is under field connector {spec{awsAccountId}}

Here is an example payload for same.

curl -i -X PUT \
  'https://app.harness.io/gateway/ng/api/connectors?accountIdentifier&branch=string&repoIdentifier=string&rootFolder=string&filePath=string&commitMsg=string&lastObjectId=string&resolvedConflictCommitId=string&baseBranch=string&connectorRef=string' \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: ' \
  -d '{
    "connector": {
      "name": "Abhi-AWS-CCM",
      "identifier": "AbhiAWSCCM",
      "type": "CEAws",
      "spec": {
        "connectorType": "CEAwsConnector",
        "crossAccountAccess": {
          "crossAccountRoleArn": "arn:aws:iam::"
        },
        "curAttributes": {
          "reportName": "AbhiReport1",
          "s3BucketName": "abhitestbucket"
        },
        "featuresEnabled": [
          "VISIBILITY",
          "OPTIMIZATION",
          "BILLING"
        ],
        "awsAccountId": "91xxxxxxx"
      }
    }
  }'

That’s all for this article. Do try Harness CCM if not already, it’s free to try and saves lot of cloud cost, efforts and time.
Happy Savings with Harness CCM :moneybag:

2 Likes