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

Unmarshal error when using newrelic_api_access_key but not having right permissions to create key #2261

Closed
kidk opened this issue Feb 27, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@kidk
Copy link
Contributor

kidk commented Feb 27, 2023

HCL

resource "newrelic_api_access_key" "newrelic_aws_access_key" {
  account_id  = var.NEW_RELIC_ACCOUNT_ID
  key_type    = "INGEST"
  ingest_type = "LICENSE"
  name        = "Ingest License key for ${var.NEW_RELIC_ACCOUNT_NAME}"
  notes       = "AWS Cloud Integrations Firehost Key"
}

Output

newrelic_api_access_key.newrelic_aws_access_key: Creating...
╷
│ Error: json: cannot unmarshal object into Go struct field .data.apiAccessCreateKeys.errors of type apiaccess.APIAccessKeyErrorInterface
│
│   with newrelic_api_access_key.newrelic_aws_access_key,
│   on cloud-integrations-aws.tf line 100, in resource "newrelic_api_access_key" "newrelic_aws_access_key":
│  100: resource "newrelic_api_access_key" "newrelic_aws_access_key" {
│

Expected behaviour

Error message telling me I don't have the right permissions

API Traffic

Request

{
	"query": "mutation($keys: ApiAccessCreateInput!) {\n\t\t\tapiAccessCreateKeys(keys: $keys) {createdKeys {\n\t\tid\n\t\tkey\n\t\tname\n\t\tnotes\n\t\ttype\n\t\t... on ApiAccessIngestKey {\n\t\t\tid\n\t\t\tname\n\t\t\taccountId\n\t\t\tingestType\n\t\t\tkey\n\t\t\tnotes\n\t\t\ttype\n\t\t}\n\t\t... on ApiAccessUserKey {\n\t\t\tid\n\t\t\tname\n\t\t\taccountId\n\t\t\tkey\n\t\t\tnotes\n\t\t\ttype\n\t\t\tuserId\n\t\t}\n\t\t... on ApiAccessKey {\n\t\t\tid\n\t\t\tname\n\t\t\tkey\n\t\t\tnotes\n\t\t\ttype\n\t\t}}errors {\n\t\t  message\n\t\t  type\n\t\t... on ApiAccessIngestKeyError {\n\t\t\tid\n\t\t\tingestErrorType: errorType\n\t\t\taccountId\n\t\t\tingestType\n\t\t\tmessage\n\t\t\ttype\n\t\t  }\n\t\t... on ApiAccessKeyError {\n\t\t\tmessage\n\t\t\ttype\n\t\t  }\n\t\t... on ApiAccessUserKeyError {\n\t\t\tid\n\t\t\taccountId\n\t\t\tuserErrorType: errorType\n\t\t\tmessage\n\t\t\ttype\n\t\t\tuserId\n\t\t  }\n\t\t}\n\t\n\t\t}}",
	"variables": {
		"keys": {
			"ingest": [{
				"accountId": 1234567,
				"ingestType": "LICENSE",
				"name": "Ingest License key for Production",
				"notes": "AWS Cloud Integrations Firehost Key"
			}]
		}
	}
}

Response

{
	"data": {
		"apiAccessCreateKeys": {
			"createdKeys": null,
			"errors": [{
				"accountId": 1234567,
				"id": null,
				"ingestErrorType": "FORBIDDEN",
				"ingestType": "LICENSE",
				"message": "You do not have permission to create this key.",
				"type": "INGEST"
			}]
		}
	}
}
@kidk kidk added the bug Something isn't working label Feb 27, 2023
@kidk kidk changed the title Unmarshal when using newrelic_api_access_key but not having right permissions Unmarshal error when using newrelic_api_access_key but not having right permissions to create key Feb 27, 2023
@pranav-new-relic
Copy link
Member

pranav-new-relic commented Mar 29, 2023

Closing this issue, as it is similar to #1418 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants