-
Notifications
You must be signed in to change notification settings - Fork 1
/
lambda_publish_version.go
50 lines (42 loc) · 1.31 KB
/
lambda_publish_version.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
package kanarya
import (
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/lambda"
)
// LambdaNewVersionResponse is used to represent the response returned from
// PublishNewVersion. The main use case of this struct is to check version
// number of the latest published version.
type LambdaNewVersionResponse struct {
FunctionArn string
LastModified string
LastUpdateStatus string
State string
Version string
}
// PublishNewVersion publishes a new lambda version and returns a
// LambdaNewVersionResponse. One of the most important fields in the response is
// Version, that is the new published version and is used in later gradual
// deployment steps.
func PublishNewVersion(
client *lambda.Lambda,
lambdaPackage LambdaPackage,
) (LambdaNewVersionResponse, error) {
resp := LambdaNewVersionResponse{}
result, err := client.PublishVersion(
&lambda.PublishVersionInput{
FunctionName: aws.String(lambdaPackage.Function.Name),
},
)
if err != nil {
return resp, err
}
log.Println("Lambda version published...")
return LambdaNewVersionResponse{
FunctionArn: *result.FunctionArn,
LastModified: *result.LastModified,
LastUpdateStatus: *result.LastUpdateStatus,
State: *result.State,
Version: *result.Version,
}, nil
}