Clayton
11/09/2021, 2:18 PMerror: AccessDeniedException: User: arn:aws:sts::635813714697:assumed-role/dev-si-install-event-tes-PublishEndpointLambdaPOS-1DZZ050R2GA5Z/dev-si-install-event-test-PublishEndpointLambdaPOS-fgyGrM4H3RQT is not authorized to perform: events:PutEvents on resource: arn:aws:events:us-east-1:635813714697:event-bus/default because no identity-based policy allows the events:PutEvents action
Ideally I’d like to add least permissions to the function (grantPutEventsTo).
Any ideas where I’m getting this wrong? Thanksthdxr
11/09/2021, 2:19 PMthdxr
11/09/2021, 2:20 PMconst bus = new sst.EventBus(this, "Bus", {
eventBridgeEventBus: events.EventBus.fromEventBusName(
this,
"BusInner",
ssm.BUS_NAME
),
})
app.addDefaultFunctionPermissions([
bus,
])
Clayton
11/09/2021, 2:22 PMthdxr
11/09/2021, 2:24 PMpublish.attachPermissions([
eventHubBus
]);
Clayton
11/09/2021, 2:25 PMthdxr
11/09/2021, 2:26 PMevent-bus/default
- isn't that the precreated one?Clayton
11/09/2021, 2:27 PMClayton
11/09/2021, 2:27 PMClayton
11/09/2021, 2:27 PMClayton
11/09/2021, 2:28 PMthdxr
11/09/2021, 2:28 PMthdxr
11/09/2021, 2:29 PMthdxr
11/09/2021, 2:29 PMClayton
11/09/2021, 2:30 PMprocess.env.BUS_ARN
is coming up as undefined. Hmmm…thdxr
11/09/2021, 2:30 PMClayton
11/09/2021, 2:30 PMconst publish = new sst.Function(this, 'Publish', {
handler: 'src/handler.publish',
environment: {
BUS_ARN: subsystemEventHubBusArn,
},
});
Clayton
11/09/2021, 2:30 PMthdxr
11/09/2021, 2:31 PMthdxr
11/09/2021, 2:31 PMBUS_NAME: eventHubBus.eventBusName
Clayton
11/09/2021, 2:33 PMClayton
11/09/2021, 2:34 PMClayton
11/09/2021, 2:36 PMthdxr
11/09/2021, 2:37 PMClayton
11/09/2021, 2:38 PMthdxr
11/09/2021, 2:42 PMthdxr
11/09/2021, 2:42 PMthdxr
11/09/2021, 2:42 PMClayton
11/09/2021, 2:43 PMClayton
11/09/2021, 2:44 PMthdxr
11/09/2021, 2:44 PMClayton
11/09/2021, 2:45 PMnpm run start
thdxr
11/09/2021, 2:51 PMprocess.env
and see what you getClayton
11/09/2021, 2:52 PMClayton
11/09/2021, 3:04 PMthdxr
11/09/2021, 3:05 PMthdxr
11/09/2021, 3:05 PMthdxr
11/09/2021, 3:05 PMClayton
11/09/2021, 3:06 PMClayton
11/10/2021, 2:15 PMconst api = new sst.Api(this, 'Publish Endpoint', {
routes: {
'POST /': {
function: {
srcPath: "src/",
handler: "handler.publish",
environment: { BUS_ARN: subsystemEventHubBusArn },
permissions: [ eventHubBus ],
},
},
},
});