OBS Event Source¶
For the use of OBS triggers, please refer to Using an OBS Trigger.
Note
For each OBS bucket, only one FunctionGraph can be triggered (no multiple FunctionGraphs listening on same bucket).
OBS example event¶
{
"Records": [
{
"eventVersion": "2.0",
"eventTime": "2018-01-09T07:50:50.028Z",
"requestParameters": {
"sourceIPAddress": "103.218.216.125"
},
"s3": {
"configurationId": "UK1DGFPYUKUZFHNQ00000160CC0B471D101ED30CE24DF4DB",
"object": {
"eTag": "9d377b10ce778c4938b3c7e2c63a229a",
"sequencer": "00000000160D9E681484D6B4C0000000",
"key": "job.png",
"size": 777835
},
"bucket": {
"arn": "arn:fss:s3:::syj-input2",
"name": "functionstorage-template",
"ownerIdentity": {
"PrincipalId": "0ed1b73473f24134a478962e631651eb"
}
}
},
"awsRegion": "region",
"eventName": "ObjectCreated:Post",
"userIdentity": {
"principalId": "9bf43789b1ff4b679040f35cc4f0dc05"
}
}
]
}
Parameter description¶
Parameter |
Type |
Description |
|---|---|---|
eventVersion |
String |
Event version |
eventSource |
String |
Event source |
awsRegion |
String |
AWS region |
eventTime |
String |
Time when an event occurs |
eventName |
String |
See below |
userIdentity |
String |
User identity information |
requestParameters |
String |
Request parameters |
responseElements |
String |
Response elements |
s3 |
Object |
See below |
Possible values for eventName¶
EventName |
Description |
|---|---|
ObjectCreated:Put
ObjectCreated:Post
ObjectCreated:Copy
|
Operations such as PUT, POST, and COPY can create an object. With these event types, you can enable notifications when an object is created using a specific API operation. |
ObjectCreated:CompleteMultipartUpload |
ObjectCreated:CompleteMultipartUpload includes objects that are created using UploadPartCopy for Copy operations. |
ObjectRemoved:Delete
ObjectRemoved:DeleteMarkerCreated
|
By using the ObjectRemoved event types, you can enable notification when an object or a batch of objects is removed from a bucket. You can request notification when an object is deleted or a versioned object is permanently deleted by using the ObjectRemoved:Delete event type. Alternatively, you can request notification when a delete marker is created for a versioned object using ObjectRemoved:DeleteMarkerCreated. These event notifications don’t alert you for automatic deletes from lifecycle configurations or from failed operations. |
Parameter s3¶
Parameter |
Type |
Description |
|---|---|---|
s3SchemaVersion |
String |
S3 schema version |
configurationId |
String |
Configuration ID |
bucket |
Object |
See below |
Parameter bucket¶
Parameter |
Type |
Description |
|---|---|---|
name |
String |
Name of the bucket |
ownerIdentity |
String |
Owner identity information |
arn |
String |
Amazon Resource Name |
Parameter object¶
Parameter |
Type |
Description |
|---|---|---|
key |
String |
The name that has been assigned to an object. |
eTag |
String |
The entity tag is a hash of the object. |
size |
Long |
Size in bytes of the object |
versionId |
String |
Version ID |
sequencer |
String |
Sequencer |
Example¶
const { OBSS3Event } = require("@opentelekomcloud-community/fg-obss3-event");
exports.initializer = function (context, callback) {
const logger = context.getLogger();
logger.info("Function initialized");
callback(null, "");
};
exports.handler = async function (event, context) {
const logger = context.getLogger();
logger.info("Function Name:", context.getFunctionName());
const obss3Event = new OBSS3Event(event);
logger.info("OBS Event- Name:", obss3Event.getRecords()[0].getEventName());
logger.info("OBS Event- Bucket:", obss3Event.getRecords()[0].getS3().getBucket().getName());
const output = {
event_name: obss3Event.getRecords()[0].getEventName(),
bucket_name: obss3Event.getRecords()[0].getS3().getBucket().getName()
};
return output;
};
Further reading¶
For working with OBS Buckets, please refer to: Object Storage Service 3rd Party - Node.js SDK.
FunctionGraph Node.js Runtime contains a bundled version of OBS SDK, which is available in the runtime environment.
See Bundled Libraries for the specific Node.js version documentation for more details.
For samples, see: