sst / sst

Build full-stack apps on your own infrastructure.
https://sst.dev
MIT License
24.07k stars 1.86k forks source link

sst.aws.KinesisStream missing `arn` property from Resource interface #5884

Closed beerlington closed 1 month ago

beerlington commented 1 month ago

I've configured an AWS Kinesis stream and am accessing it via a lambda function but I'm getting a typescript error on the resource saying the arn property does not exist on the type.

The relevant setup in sst.config.ts is:

const twilioMessageStream = new sst.aws.KinesisStream(
  'twilio-message-stream'
);

const twilioImportScheduler = new sst.aws.Function(
  'twilio-import-scheduler',
  {
    environment: {
      // omitted ...
    },
    handler: './infra/twilio/src/scheduler.handler',
    link: [twilioMessageStream],
  }
);

Then I'm accessing it in the lambda function like this:

import { Resource } from 'sst';

// failing the type check with "Property 'arn' does not exist"
const streamArn = Resource['twilio-message-stream'].arn;

My sst-env.d.ts file has this entry in the Resource interface:

"twilio-message-stream": {
  "name": string
  "type": "sst.aws.KinesisStream"
}

which I believe should have the arn property and look like this:

"twilio-message-stream": {
  "arn": string
  "name": string
  "type": "sst.aws.KinesisStream"
}

I'm not sure how the Resource is auto-generated, but I'm wondering if the getSSTLink function needs to include arn in it's properties:

  getSSTLink() {
    return {
      properties: {
        arn: this.stream.arn, // <------ will this fix it?
        name: this.stream.name,
      },
      include: [
        permission({
          actions: ["kinesis:*"],
          resources: [this.nodes.stream.arn],
        }),
      ],
    };
  }
}