forked from theaaf/cloudformation-media-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
medialive_input_security_group.go
59 lines (53 loc) · 1.57 KB
/
medialive_input_security_group.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/medialive"
)
func init() {
RegisterType("Custom::MediaLiveInputSecurityGroup", MediaLiveInputSecurityGroup)
}
func MediaLiveInputSecurityGroup(request *CustomResourceRequest, cfg aws.Config) (*Success, error) {
client := medialive.New(cfg)
switch request.RequestType {
case "Create":
var input medialive.CreateInputSecurityGroupInput
if err := ReshapeProps(request.ResourceProperties, &input); err != nil {
return nil, err
}
resp, err := client.CreateInputSecurityGroupRequest(&input).Send()
if err != nil {
return nil, err
}
return &Success{
PhysicalResourceId: *resp.SecurityGroup.Id,
Data: map[string]interface{}{
"Arn": *resp.SecurityGroup.Arn,
"Id": *resp.SecurityGroup.Id,
},
}, nil
case "Update":
var input medialive.UpdateInputSecurityGroupInput
if err := ReshapeProps(request.ResourceProperties, &input); err != nil {
return nil, err
}
input.InputSecurityGroupId = &request.PhysicalResourceId
resp, err := client.UpdateInputSecurityGroupRequest(&input).Send()
if err != nil {
return nil, err
}
return &Success{
PhysicalResourceId: *resp.SecurityGroup.Id,
Data: map[string]interface{}{
"Arn": *resp.SecurityGroup.Arn,
"Id": *resp.SecurityGroup.Id,
},
}, nil
case "Delete":
_, err := client.DeleteInputSecurityGroupRequest(&medialive.DeleteInputSecurityGroupInput{
InputSecurityGroupId: &request.PhysicalResourceId,
}).Send()
return nil, err
}
return nil, fmt.Errorf("unexpected request type")
}