eventcatalog icon indicating copy to clipboard operation
eventcatalog copied to clipboard

Error: The `resource` component (6th component) of an ARN is required: arn:aws:applicationinsights:eu-central-1:::

Open floriankraemer opened this issue 2 months ago • 0 comments

Have you read the Contributing Guidelines on issues?

Description

I can't use the generator because it throws an exception each time I run it.

Steps to reproduce

Just run npm run generate

The env vars are set and when I echo them I gt my correct key and secret.

Configuration:

  generators: [
    [
      '@eventcatalog/plugin-doc-generator-amazon-eventbridge',
      {
        eventBusName: 'default',
        region: 'eu-central-1',
        registryName: 'Event-Catalog-Test', // your registry normally "discovered-schemas"
        schemaNamePrefix: 'CMH', // Schema name prefix filter, optional
        credentials: {
          accessKeyId: process.env.AWS_ACCESS_KEY,
          secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
          // sessionToken: process.env.AWS_SESSION_TOKEN // optional
        },
      },
    ],
  ],

package.json

{
  "name": "cmh",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "eventcatalog start",
    "dev": "eventcatalog dev",
    "build": "eventcatalog build",
    "generate": "eventcatalog generate",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "@eventcatalog/types": "0.4.2",
    "@types/node": "20.12.12",
    "@types/react": "18.3.3",
    "autoprefixer": "10.4.5",
    "cross-env": "^7.0.3",
    "postcss": "^8.3.11",
    "tailwindcss": "^3.3.3",
    "typescript": "^5.1.6"
  },
  "dependencies": {
    "@eventcatalog/core": "1.2.7",
    "@eventcatalog/plugin-doc-generator-amazon-eventbridge": "^0.0.13",
    "@eventcatalog/plugin-doc-generator-asyncapi": "^0.4.0"
  }
}

Expected behavior

That the schema documentation is generated.

Actual behavior

I get an exception when running the generator.

Generating EventCatalog docs using: @eventcatalog/plugin-doc-generator-amazon-eventbridge
/home/florian/projects/cmh-event-catalog/node_modules/aws-cdk-lib/core/lib/arn.js:1
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Arn=exports.ArnFormat=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var cfn_fn_1=()=>{var tmp=require("./cfn-fn");return cfn_fn_1=()=>tmp,tmp},token_1=()=>{var tmp=require("./token");return token_1=()=>tmp,tmp},util_1=()=>{var tmp=require("./util");return util_1=()=>tmp,tmp},ArnFormat;(function(ArnFormat2){ArnFormat2.NO_RESOURCE_NAME="arn:aws:service:region:account:resource",ArnFormat2.COLON_RESOURCE_NAME="arn:aws:service:region:account:resource:resourceName",ArnFormat2.SLASH_RESOURCE_NAME="arn:aws:service:region:account:resource/resourceName",ArnFormat2.SLASH_RESOURCE_SLASH_RESOURCE_NAME="arn:aws:service:region:account:/resource/resourceName"})(ArnFormat||(exports.ArnFormat=ArnFormat={}));class Arn{static format(components,stack){try{jsiiDeprecationWarnings().aws_cdk_lib_ArnComponents(components),jsiiDeprecationWarnings().aws_cdk_lib_Stack(stack)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.format),error}const partition=components.partition??stack?.partition,region=components.region??stack?.region,account=components.account??stack?.account;if(partition==null||region==null||account==null)throw new Error(`Arn.format: partition (${partition}), region (${region}), and account (${account}) must all be passed if stack is not passed.`);const sep=components.sep??(components.arnFormat===ArnFormat.COLON_RESOURCE_NAME?":":"/"),values=["arn",":",partition,":",components.service,":",region,":",account,":",...components.arnFormat===ArnFormat.SLASH_RESOURCE_SLASH_RESOURCE_NAME?["/"]:[],components.resource];if(sep!=="/"&&sep!==":"&&sep!=="")throw new Error('resourcePathSep may only be ":", "/" or an empty string');return components.resourceName!=null&&(values.push(sep),values.push(components.resourceName)),values.join("")}static parse(arn,sepIfToken="/",hasName=!0){let arnFormat;return hasName?arnFormat=sepIfToken==="/"?ArnFormat.SLASH_RESOURCE_NAME:ArnFormat.COLON_RESOURCE_NAME:arnFormat=ArnFormat.NO_RESOURCE_NAME,this.split(arn,arnFormat)}static split(arn,arnFormat){try{jsiiDeprecationWarnings().aws_cdk_lib_ArnFormat(arnFormat)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.split),error}const components=parseArnShape(arn);if(components==="token")return parseTokenArn(arn,arnFormat);const[,partition,service,region,account,resourceTypeOrName,...rest]=components;let resource,resourceName,sep,resourcePartStartIndex=0,detectedArnFormat,slashIndex=resourceTypeOrName.indexOf("/");return slashIndex===0&&(slashIndex=resourceTypeOrName.indexOf("/",1),resourcePartStartIndex=1,detectedArnFormat=ArnFormat.SLASH_RESOURCE_SLASH_RESOURCE_NAME),slashIndex!==-1?arnFormat===ArnFormat.NO_RESOURCE_NAME?(sep=void 0,slashIndex=-1,detectedArnFormat=ArnFormat.NO_RESOURCE_NAME):(sep="/",detectedArnFormat=resourcePartStartIndex===0?ArnFormat.SLASH_RESOURCE_NAME:ArnFormat.SLASH_RESOURCE_SLASH_RESOURCE_NAME):rest.length>0?(sep=":",slashIndex=-1,detectedArnFormat=ArnFormat.COLON_RESOURCE_NAME):(sep=void 0,detectedArnFormat=ArnFormat.NO_RESOURCE_NAME),slashIndex!==-1?(resource=resourceTypeOrName.substring(resourcePartStartIndex,slashIndex),resourceName=resourceTypeOrName.substring(slashIndex+1)):resource=resourceTypeOrName,rest.length>0&&(resourceName?resourceName+=":":resourceName="",resourceName+=rest.join(":")),(0,util_1().filterUndefined)({service:service||void 0,resource:resource||void 0,partition:partition||void 0,region,account,resourceName,sep,arnFormat:detectedArnFormat})}static extractResourceName(arn,resourceType){if(parseArnShape(arn)==="token")return cfn_fn_1().Fn.select(1,cfn_fn_1().Fn.split(`:${resourceType}/`,arn));const parsed=Arn.split(arn,ArnFormat.SLASH_RESOURCE_NAME);if(!token_1().Token.isUnresolved(parsed.resource)&&parsed.resource!==resourceType)throw new Error(`Expected resource type '${resourceType}' in ARN, got '${parsed.resource}' in '${arn}'`);if(!parsed.resourceName)throw new Error(`Expected resource name in ARN, didn't find one: '${arn}'`);return parsed.resourceName}constructor(){}}exports.Arn=Arn,_a=JSII_RTTI_SYMBOL_1,Arn[_a]={fqn:"aws-cdk-lib.Arn",version:"2.143.0"};function parseTokenArn(arnToken,arnFormat){const components=cfn_fn_1().Fn.split(":",arnToken),partition=cfn_fn_1().Fn.select(1,components).toString(),service=cfn_fn_1().Fn.select(2,components).toString(),region=cfn_fn_1().Fn.select(3,components).toString(),account=cfn_fn_1().Fn.select(4,components).toString();let resource,resourceName,sep;if(arnFormat===ArnFormat.NO_RESOURCE_NAME||arnFormat===ArnFormat.COLON_RESOURCE_NAME)resource=cfn_fn_1().Fn.select(5,components),arnFormat===ArnFormat.COLON_RESOURCE_NAME?(resourceName=cfn_fn_1().Fn.select(6,components),sep=":"):(resourceName=void 0,sep=void 0);else{const lastComponents=cfn_fn_1().Fn.split("/",cfn_fn_1().Fn.select(5,components));arnFormat===ArnFormat.SLASH_RESOURCE_NAME?(resource=cfn_fn_1().Fn.select(0,lastComponents),resourceName=cfn_fn_1().Fn.select(1,lastComponents)):(resource=cfn_fn_1().Fn.select(1,lastComponents),resourceName=cfn_fn_1().Fn.select(2,lastComponents)),sep="/"}return{partition,service,region,account,resource,resourceName,sep,arnFormat}}function parseArnShape(arn){if(!arn.startsWith("arn:")){if(token_1().Token.isUnresolved(arn))return"token";throw new Error(`ARNs must start with "arn:" and have at least 6 components: ${arn}`)}const components=arn.split(":");if(!(components.length>1?components[1]:void 0))throw new Error("The `partition` component (2nd component) of an ARN is required: "+arn);if(!(components.length>2?components[2]:void 0))throw new Error("The `service` component (3rd component) of an ARN is required: "+arn);if(!(components.length>5?components[5]:void 0))throw new Error("The `resource` component (6th component) of an ARN is required: "+arn);return components}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

Error: The `resource` component (6th component) of an ARN is required: arn:aws:applicationinsights:eu-central-1:::
    at parseArnShape (/home/florian/projects/cmh-event-catalog/node_modules/aws-cdk-lib/core/lib/arn.js:1:5952)
    at Arn.split (/home/florian/projects/cmh-event-catalog/node_modules/aws-cdk-lib/core/lib/arn.js:1:2484)
    at /home/florian/projects/cmh-event-catalog/node_modules/@eventcatalog/plugin-doc-generator-amazon-eventbridge/lib/lib/aws.js:102:79
    at Array.map (<anonymous>)
    at /home/florian/projects/cmh-event-catalog/node_modules/@eventcatalog/plugin-doc-generator-amazon-eventbridge/lib/lib/aws.js:101:37
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async /home/florian/projects/cmh-event-catalog/node_modules/@eventcatalog/plugin-doc-generator-amazon-eventbridge/lib/lib/aws.js:107:42

Node.js v18.19.1
Error: Command failed: cross-env PROJECT_DIR='/home/florian/projects/cmh-event-catalog' npm run generate
    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at Command.<anonymous> (/home/florian/projects/cmh-event-catalog/node_modules/@eventcatalog/core/bin/eventcatalog.js:121:5)
    at Command.listener [as _actionHandler] (/home/florian/projects/cmh-event-catalog/node_modules/commander/index.js:922:31)
    at Command._parseCommand (/home/florian/projects/cmh-event-catalog/node_modules/commander/index.js:1503:14)
    at Command._dispatchSubcommand (/home/florian/projects/cmh-event-catalog/node_modules/commander/index.js:1443:18)
    at Command._parseCommand (/home/florian/projects/cmh-event-catalog/node_modules/commander/index.js:1460:12)
    at Command.parse (/home/florian/projects/cmh-event-catalog/node_modules/commander/index.js:1292:10)
    at run (/home/florian/projects/cmh-event-catalog/node_modules/@eventcatalog/core/bin/eventcatalog.js:128:7) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 883072,
  stdout: null,
  stderr: null
}

Your environment

  • EventCatalog version used: @eventcatalog/core": "1.2.7"
  • Environment name and version: v18.19.1
  • Operating system and version Kubuntu 24.04

floriankraemer avatar May 29 '24 15:05 floriankraemer