I have a lambda that is trying to write to my fire...
# help
d
I have a lambda that is trying to write to my firehose DeliveryStream instance. This permission works:
Copy code
'POST    /collect': {
  function: {
    handler: 'src/analytics/create.main',
    environment: {
      ANALYTICS_DELIVERY_STREAM_NAME: analyticsDeliveryStream.deliveryStreamName,
    },
    permissions: [analyticsDeliveryStream],
  },
},
When I add it, it says
Error: The specified permissions are not supported.
Is there a way to go around it?
Note that ‘firehose:PutRecord’ seems to work, put I would like to have that for only this data stream.
f
Hi @Daniel Gato, can I see how you are creating the
analyticsDeliveryStream
?
d
Copy code
export default class AnalyticsStack extends sst.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    this.analyticsBucket = new sst.Bucket(this, 'Analytics');

    this.deliveryStream = new firehose.DeliveryStream(this, 'Delivery Stream', {
      destinations: [new destinations.S3Bucket(this.analyticsBucket.s3Bucket)],
    });
  }
}
I think this is working now:
Copy code
POST /collect': {
          function: {
            handler: 'src/analytics/create.main',
            environment: {
              ANALYTICS_DELIVERY_STREAM_NAME: analyticsDeliveryStream.deliveryStreamName,
            },
            permissions: [
              new iam.PolicyStatement({
                actions: ['firehose:PutRecord'],
                effect: iam.Effect.ALLOW,
                resources: [analyticsDeliveryStream.deliveryStreamArn],
              }),
              // 'firehose:PutRecord',
            ],
          },
f
DeliverStream
wasn’t supported by the shorthand permission syntax - https://docs.serverless-stack.com/util/Permissions#supported-constructs
However, I just submitted a PR to add support for it - https://github.com/serverless-stack/serverless-stack/pull/1266
Will merge once the test pass. And what u had originally would work:
permissions: [analyticsDeliveryStream],
d
awesome, will test when it’s released