cloud-red
Version:
Harnessing Serverless for your cloud integration needs
125 lines (108 loc) • 5.15 kB
HTML
<script type="text/x-red" data-template-name="s3-trigger">
<!-- Name -->
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input id="node-input-name" type="text">
</div>
<!-- Description -->
<div class="form-row" style="margin-bottom:0px">
<label> </label>
<input id="node-input-withDescription" type="checkbox" unchecked style="display:inline-block; width:auto; vertical-align:top;"">
<label for="node-input-withDescription" style="width:70%; line-height:0px"> Including description</label>
</div>
<div id="section-node-config-s3trigger-description" class="form-row">
<textarea id="node-input-description" rows="3" style="width:100%" />
</div>
<hr>
<!-- BucketName -->
<div class="form-row">
<label for="node-input-bucketName">Bucket</label>
<input id="node-input-bucketName" type="text">
</div>
<!-- Prefix -->
<div class="form-row">
<label for="node-input-prefix">Prefix</label>
<input id="node-input-prefix" type="text" placeholder="(optional) e.g. images/">
</div>
<!-- Suffix -->
<div class="form-row">
<label for="node-input-suffix">Suffix</label>
<input id="node-input-suffix" type="text" placeholder="(optional) e.g. .jpg">
</div>
<!-- Event -->
<div class="form-row">
<label for="node-input-event">Event type</label>
<!-- <input id="node-input-event" type="text" placeholder="default: s3:ObjectCreated:*"> -->
<select type="text" id="node-input-event" style="width:70%">
<option selected value="s3:ObjectCreated:*">s3:ObjectCreated:*</option>
<option value="s3:ObjectCreated:Put">s3:ObjectCreated:Put</option>
<option value="s3:ObjectCreated:Post">s3:ObjectCreated:Post</option>
<option value="s3:ObjectCreated:Copy">s3:ObjectCreated:Copy</option>
<option value="s3:ObjectCreated:CompleteMultipartUpload">s3:ObjectCreated:CompleteMultipartUpload</option>
<option disabled>────────────────────</option>
<option value="s3:ObjectRemoved:*">s3:ObjectRemoved:*</option>
<option value="s3:ObjectRemoved:Delete">s3:ObjectRemoved:Delete</option>
<option value="s3:ObjectRemoved:DeleteMarkerCreated">s3:ObjectRemoved:DeleteMarkerCreated</option>
<option disabled>────────────────────</option>
<option value="s3:ObjectRestore:Post">s3:ObjectRestore:Post</option>
<option value="s3:ObjectRestore:Completed">s3:ObjectRestore:Completed</option>
<option disabled>────────────────────</option>
<option value="s3:ReducedRedundancyLostObject">s3:ReducedRedundancyLostObject</option>
</select>
</div>
<!-- Note -->
<div class="form-tips" style="margin-top:20px"><b>Warning:</b> An S3 Event notification will be attached to this bucket at deployment time</div>
</script>
<script type="text/x-red" data-help-name="s3-trigger">
<p>Add a notification event to your Lambda when a file is added to a S3 bucket, and set up access permissions</p>
<h3>Options</h3>
<ul>
<li><b>Bucket</b> - S3 Bucket name which will push notifications to Lambda</li>
<li><b>Prefix</b> - (optional) Prefix filter for S3 keys that will cause the event. <i>Example: images/</i></li>
<li><b>Suffix</b> - (optional) Suffix filter for S3 keys that will cause the event. <i>Example: .png</i></li>
<li><b>Events</b> - Event type that trigger the function. <i>Default:</i> <code>s3:ObjectCreated:*</code></li>
</ul>
<h3>References</h3>
<ul>
<li><a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types">Configuring Amazon S3 Event Notification</a></li>
</ul>
</script>
<script type="text/javascript">
RED.nodes.registerType('s3-trigger', {
category: 'triggers',
icon: 'aws.png',
inputs: 0,
outputs: 1,
defaults: {
name: { required: true },
bucketName: { required: true },
prefix: { required: false },
suffix: { required: false },
event: { value: 's3:ObjectCreated:*', required: true },
withDescription: { value: false, required: true },
description: { value: '', required: false }
},
label: function() {
return this.name || 's3 trigger';
},
oneditprepare: function() {
if ($('#node-input-withDescription').checked) {
$('#section-node-config-s3trigger-description').show();
} else {
$('#section-node-config-s3trigger-description').hide();
}
$('#node-input-withDescription').change(function(data) {
if (this.checked) {
$('#section-node-config-s3trigger-description').show();
} else {
$('#section-node-config-s3trigger-description').hide();
$('#node-input-description').val('');
}
});
// make the selected option of event type drop visible
$('#node-input-event').on('change', function() {
this.event = $('#node-input-event').val();
});
}
});
</script>