Skip to content

Commit 0f62729

Browse files
Add environment variable to allow specifying lattice service endpoint (#84)
1 parent 5ed899d commit 0f62729

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ make run
2424

2525
# or run it in debug mode
2626
GATEWAY_API_CONTROLLER_LOGLEVEL=debug make run
27+
28+
# to run it against specific lattice service endpoint
29+
LATTICE_ENDPOINT=https://mercury-gamma.us-west-2.amazonaws.com/ make run
2730
```
2831

2932
## End-to-End Testing

pkg/aws/services/vpclattice.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package services
22

33
import (
44
"context"
5+
"github.com/golang/glog"
6+
"os"
57

68
"github.com/aws/aws-sdk-go/aws"
79
"github.com/aws/aws-sdk-go/aws/session"
@@ -30,11 +32,16 @@ const (
3032

3133
func NewDefaultLattice(sess *session.Session, region string) *defaultLattice {
3234
var latticeSess vpclatticeiface.VpcLatticeAPI
33-
if region == "us-east-1" {
34-
latticeSess = vpclattice.New(sess, aws.NewConfig().WithRegion("us-east-1").WithEndpoint("https://mercury-beta.us-east-1.amazonaws.com/"))
35-
} else {
36-
latticeSess = vpclattice.New(sess, aws.NewConfig().WithRegion("us-west-2").WithEndpoint(BetaProdEndpoint))
35+
endpoint := os.Getenv("LATTICE_ENDPOINT")
36+
37+
if endpoint == "" {
38+
endpoint = BetaProdEndpoint
3739
}
40+
41+
latticeSess = vpclattice.New(sess, aws.NewConfig().WithRegion("us-west-2").WithEndpoint(endpoint))
42+
43+
glog.V(2).Infoln("Lattice Service EndPoint:", endpoint)
44+
3845
return &defaultLattice{VpcLatticeAPI: latticeSess}
3946
}
4047

0 commit comments

Comments
 (0)