-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (33 loc) · 927 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const core = require('@actions/core');
const AWS = require('aws-sdk');
let ec2 = new AWS.EC2();
let params = {
GroupId: core.getInput('security_group_id'),
IpPermissions: [
{
FromPort: core.getInput('from_port'),
IpProtocol: core.getInput('ip_protocol'),
IpRanges: [
{
CidrIp: core.getInput('cidr'),
Description: core.getInput('desc')
}
],
ToPort: core.getInput('to_port')
}
]
};
switch (core.getInput('action_type')) {
case 'authorize':
ec2.authorizeSecurityGroupIngress(params, function (err, data) {
if (err) core.setFailed('Fetch Failed! Error: ' + err);
});
break;
case 'revoke':
ec2.revokeSecurityGroupIngress(params, function (err, data) {
if (err) core.setFailed('Fetch Failed! Error: ' + err);
});
break;
default:
core.setFailed('Unknown `action_type`: ' + core.getInput('action_type'));
}