forked from theaaf/cloudformation-media-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mediaconnect_flow.go
45 lines (38 loc) · 1.09 KB
/
mediaconnect_flow.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
package main
import (
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/mediaconnect"
)
func init() {
RegisterType("Custom::MediaConnectFlow", MediaConnectFlow)
}
func createMediaConnectFlow(props map[string]interface{}, client *mediaconnect.MediaConnect) (*Success, error) {
var input mediaconnect.CreateFlowInput
if err := ReshapeProps(props, &input); err != nil {
return nil, err
}
resp, err := client.CreateFlowRequest(&input).Send()
if err != nil {
return nil, err
}
return &Success{
PhysicalResourceId: *resp.Flow.FlowArn,
Data: map[string]interface{}{
"Arn": *resp.Flow.FlowArn,
},
}, nil
}
func MediaConnectFlow(request *CustomResourceRequest, cfg aws.Config) (*Success, error) {
client := mediaconnect.New(cfg)
switch request.RequestType {
case "Create", "Update":
return createMediaConnectFlow(request.ResourceProperties, client)
case "Delete":
_, err := client.DeleteFlowRequest(&mediaconnect.DeleteFlowInput{
FlowArn: &request.PhysicalResourceId,
}).Send()
return nil, err
}
return nil, fmt.Errorf("unexpected request type")
}