Skip to content

Commit

Permalink
Merge branch 'gh-2-aws-lambda-wrapper-for-request-cert' into gh-2-aws…
Browse files Browse the repository at this point in the history
…-lambda-wrapper-for-retrieve-cert

# Conflicts:
#	venafi-snowflake-connector/go.mod
#	venafi-snowflake-connector/go.sum
#	venafi-snowflake-connector/lambda/get_cert/main.go
#	venafi-snowflake-connector/lambda/go.sum
#	venafi-snowflake-connector/lambda/request_cert/go.sum
#	venafi-snowflake-connector/lambda/request_cert/main.go
#	venafi-snowflake-connector/serverless.yml
  • Loading branch information
Fanni1993 committed Jun 17, 2021
2 parents 151bc3e + d0cb902 commit b6f5f3e
Show file tree
Hide file tree
Showing 8 changed files with 1,185 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
.serverless
.bin
1 change: 1 addition & 0 deletions venafi-snowflake-connector/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.16
require (
github.com/Venafi/vcert/v4 v4.14.3 // indirect
github.com/aws/aws-lambda-go v1.24.0 // indirect
github.com/aws/aws-sdk-go v1.38.63 // indirect
github.com/palette-software/go-log-targets v0.0.0-20200609204140-16fbfda0867a // indirect
github.com/urfave/cli v1.21.0 // indirect
github.com/zfjagann/golang-ring v0.0.0-20210116075443-7c86fdb43134 // indirect
Expand Down
20 changes: 20 additions & 0 deletions venafi-snowflake-connector/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Venafi/vcert/v4 v4.14.1 h1:7P4XCnFsbGokZeKMUwgOSQbU9dUXhtTFcZc2cfyMDGU=
github.com/Venafi/vcert/v4 v4.14.1/go.mod h1:IL+6LA8QRWZbmcMzIr/vRhf9Aa6XDM2cQO50caWevjA=
github.com/Venafi/vcert/v4 v4.14.3 h1:tlyhgQKTzMXn9B44hx8CDI4oiaisWEWSGH66KKUh088=
github.com/Venafi/vcert/v4 v4.14.3/go.mod h1:IL+6LA8QRWZbmcMzIr/vRhf9Aa6XDM2cQO50caWevjA=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aws/aws-lambda-go v1.23.0 h1:Vjwow5COkFJp7GePkk9kjAo/DyX36b7wVPKwseQZbRo=
github.com/aws/aws-lambda-go v1.23.0/go.mod h1:jJmlefzPfGnckuHdXX7/80O3BvUUi12XOkbv4w9SGLU=
github.com/aws/aws-lambda-go v1.24.0 h1:bOMerM175hLqHLdF1Nonfv1NA20nTIatuC0HK8eMoYg=
github.com/aws/aws-lambda-go v1.24.0/go.mod h1:jJmlefzPfGnckuHdXX7/80O3BvUUi12XOkbv4w9SGLU=
github.com/aws/aws-sdk-go v1.38.61 h1:wizuqQZe0K4iYJ+Slrs0aSQ4P94FAwqBUHwk46Iz5UA=
github.com/aws/aws-sdk-go v1.38.61/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.38.62 h1:w7r48cTciWCJK//YH+oN8HhNXzPDdlucV3XT6KGDMjE=
github.com/aws/aws-sdk-go v1.38.62/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.38.63 h1:BqPxe0sujTRTbir6OWj0f1VmeJcAIv7ZhTCAhaU1zmE=
github.com/aws/aws-sdk-go v1.38.63/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
Expand Down Expand Up @@ -94,6 +104,9 @@ github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0m
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
Expand Down Expand Up @@ -129,6 +142,7 @@ github.com/pavel-v-chernykh/keystore-go/v4 v4.1.0/go.mod h1:2ejgys4qY+iNVW1IittZ
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
Expand Down Expand Up @@ -163,6 +177,7 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/urfave/cli v1.21.0 h1:wYSSj06510qPIzGSua9ZqsncMmWE3Zr55KBERygyrxE=
github.com/urfave/cli v1.21.0/go.mod h1:lxDj6qX9Q6lWQxIrbrT0nwecwUtRnhVZAJjJZrVUZZQ=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
Expand All @@ -180,6 +195,7 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -212,6 +228,7 @@ golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand All @@ -233,10 +250,12 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down Expand Up @@ -289,6 +308,7 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
23 changes: 16 additions & 7 deletions venafi-snowflake-connector/lambda/get_cert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"regexp"
"os"
"strings"
"time"

Expand All @@ -19,6 +19,9 @@ import (
)

func GetCert(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {

log.AddTarget(os.Stdout, log.LevelDebug)

var dataForRequestCert utils.VenafiConnectorConfig
var snowflakeData utils.SnowFlakeType
err := json.Unmarshal([]byte(request.Body), &snowflakeData)
Expand All @@ -44,7 +47,7 @@ func GetCert(ctx context.Context, request events.APIGatewayProxyRequest) (events

c, err := vcert.NewClient(config)
if err != nil {
fmt.Printf("Failed to connect to endpoint: %s", err)
log.Errorf("Failed to connect to endpoint: %s", err)
return events.APIGatewayProxyResponse{
Body: fmt.Sprintf("{'data': [[0, '%v']]}", err.Error()),
StatusCode: 500,
Expand All @@ -58,19 +61,25 @@ func GetCert(ctx context.Context, request events.APIGatewayProxyRequest) (events

pcc, err := c.RetrieveCertificate(pickupReq)
if err != nil {
fmt.Printf("Could not get certificate: %s", err)
log.Errorf("Could not get certificate: %s", err)
return events.APIGatewayProxyResponse{
Body: fmt.Sprintf("{'data': [[0, '%v']]}", err.Error()),
StatusCode: 500,
}, nil
}

var regexp_to_remove_whitespace = regexp.MustCompile("\\s")
escaped_cert := regexp_to_remove_whitespace.ReplaceAllString(fmt.Sprintf("%v", pcc), "\\n")
bytes, err := json.Marshal(pcc)
if err != nil {
log.Errorf("Failed to serialize certificate: %v", err)
return events.APIGatewayProxyResponse{
Body: fmt.Sprintf("{'data': [[0, '%v']]}", err.Error()),
StatusCode: 500,
}, nil
}

fmt.Printf("Retrieving certificate was succesfull: %s", escaped_cert)
log.Infof("Retrieving certificate was succesful")
return events.APIGatewayProxyResponse{ // Success HTTP response
Body: fmt.Sprintf("{'data': [[0, '%v']]}", escaped_cert),
Body: fmt.Sprintf("{'data': [[0, '%v']]}", string(bytes)),
StatusCode: 200,
}, nil
}
Expand Down
57 changes: 31 additions & 26 deletions venafi-snowflake-connector/lambda/request_cert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/x509/pkix"
"encoding/json"
"fmt"
"os"
"strings"

"github.com/Venafi/vcert/v4"
Expand All @@ -18,6 +19,8 @@ import (

func RequestCert(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {

log.AddTarget(os.Stdout, log.LevelDebug)

var dataForRequestCert utils.VenafiConnectorConfig
var snowflakeData utils.SnowFlakeType
err := json.Unmarshal([]byte(request.Body), &snowflakeData)
Expand All @@ -29,21 +32,35 @@ func RequestCert(ctx context.Context, request events.APIGatewayProxyRequest) (ev
}, nil
}

// Parse parameters sent by Snowflake from Lambda Event
dataForRequestCert.TppURL = fmt.Sprintf("%v", snowflakeData.Data[0][1])
dataForRequestCert.AccessToken = fmt.Sprintf("%v", snowflakeData.Data[0][2])
dataForRequestCert.DNSName = fmt.Sprintf("%v", snowflakeData.Data[0][3]) // TODO: UPN, DNS should allow multiple values
dataForRequestCert.Zone = fmt.Sprintf("%v", snowflakeData.Data[0][4])
dataForRequestCert.UPN = fmt.Sprintf("%v", snowflakeData.Data[0][5])
dataForRequestCert.CommonName = fmt.Sprintf("%v", snowflakeData.Data[0][6])
dataForRequestCert.DNSName = fmt.Sprintf("%v", snowflakeData.Data[0][2]) // TODO: UPN, DNS should allow multiple values
dataForRequestCert.Zone = fmt.Sprintf("%v", snowflakeData.Data[0][3])
dataForRequestCert.UPN = fmt.Sprintf("%v", snowflakeData.Data[0][4])
dataForRequestCert.CommonName = fmt.Sprintf("%v", snowflakeData.Data[0][5])

log.Infof("Finished parse parameters from event object")

// Get access token from S3. If access token is expired, generate a new one.
accessToken, err := utils.GetAccessToken(dataForRequestCert.TppURL)
if err != nil {
log.Errorf("Failed to get accesss token: %s", err)
return events.APIGatewayProxyResponse{ // Error HTTP response
Body: err.Error(),
StatusCode: 500,
}, nil
}

log.Info("Got valid access token from S3")

config := &vcert.Config{
ConnectorType: endpoint.ConnectorTypeTPP,
BaseUrl: dataForRequestCert.TppURL,
Zone: dataForRequestCert.Zone,
Credentials: &endpoint.Authentication{
AccessToken: dataForRequestCert.AccessToken},
AccessToken: accessToken},
}

// Create a new Connector for Venafi API calls
c, err := vcert.NewClient(config)
if err != nil {
log.Errorf("Failed to connect to endpoint: %s", err)
Expand All @@ -57,24 +74,11 @@ func RequestCert(ctx context.Context, request events.APIGatewayProxyRequest) (ev

enrollReq = &certificate.Request{
Subject: pkix.Name{
CommonName: dataForRequestCert.CommonName,
Organization: []string{"Starschema"},
OrganizationalUnit: []string{"Team Software Dev"},
Locality: []string{"Salt Lake"},
Province: []string{"Salt Lake"},
Country: []string{"US"},
CommonName: dataForRequestCert.CommonName,
},
UPNs: []string{dataForRequestCert.UPN},
DNSNames: []string{dataForRequestCert.DNSName},
CsrOrigin: certificate.LocalGeneratedCSR,
KeyType: certificate.KeyTypeRSA,
KeyLength: 2048,
ChainOption: certificate.ChainOptionRootLast,
KeyPassword: "newPassw0rd!",
UPNs: []string{dataForRequestCert.UPN},
DNSNames: []string{dataForRequestCert.DNSName},
}
//
// 1.2. Generate private key and certificate request (CSR) based on request's options
//
err = c.GenerateRequest(nil, enrollReq)
if err != nil {
log.Errorf("Failed to generate request: %v ", err)
Expand All @@ -84,9 +88,8 @@ func RequestCert(ctx context.Context, request events.APIGatewayProxyRequest) (ev
}, nil
}

//
// 1.3. Submit certificate request, get request ID as a response
//
log.Info("Generate request was successful")
// Request a new certificate using Venafi API
requestID, err := c.RequestCertificate(enrollReq)
if err != nil {
log.Errorf("Failed to request certificate:: %v ", err)
Expand All @@ -96,7 +99,9 @@ func RequestCert(ctx context.Context, request events.APIGatewayProxyRequest) (ev
}, nil
}
log.Infof("Certificate request was successful. RequestID is: %s", requestID)

escaped_requestID := strings.Replace(fmt.Sprintf("%v", requestID), "\\", "\\\\", -1)
// Transform data to a form which is readable by Snowflake
return events.APIGatewayProxyResponse{ // Success HTTP response
Body: fmt.Sprintf("{'data': [[0, '%v']]}", escaped_requestID),
StatusCode: 200,
Expand Down
Loading

0 comments on commit b6f5f3e

Please sign in to comment.