Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ See the demo from AWS Container Day x KubeCon!

First, install the controller with latest release on at least 2 AWS EKS clusters. Nodes must have sufficient IAM permissions to perform CloudMap operations.

> **_NOTE:_** AWS region environment variable should be set like `export AWS_REGION=us-west-2`
> **_NOTE:_** AWS region environment variable can be _optionaly_ set like `export AWS_REGION=us-west-2` Otherwise controller will infer region in the order `AWS_REGION` environment variable, ~/.aws/config file, then EC2 metadata (for EKS environment)

```sh
kubectl apply -k "github.com/aws/aws-cloud-map-mcs-controller-for-k8s/config/controller_install_release"
Expand Down Expand Up @@ -74,7 +74,7 @@ kubectl get ServiceImport -A

AWS Cloud Map MCS Controller for K8s adheres to the [SemVer](https://semver.org/) specification. Each release updates the major version tag (eg. `vX`), a major/minor version tag (eg. `vX.Y`) and a major/minor/patch version tag (eg. `vX.Y.Z`). To see a full list of all releases, refer to our [Github releases page](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/releases).

> **_NOTE:_** AWS region environment variable should be set like `export AWS_REGION=us-west-2`
> **_NOTE:_** AWS region environment variable can be _optionally_ set like `export AWS_REGION=us-west-2` Otherwise controller will infer region in the order `AWS_REGION` environment variable, ~/.aws/config file, then EC2 metadata (for EKS environment)

To install from a release run
```sh
Expand Down
18 changes: 9 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ package main
import (
"context"
"flag"
"os"

"github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/cloudmap"
"github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pkg/version"
"github.com/aws/aws-sdk-go-v2/config"
"os"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
Expand Down Expand Up @@ -84,18 +85,17 @@ func main() {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
}
setupLog.Info("configuring AWS session")
// GO sdk will look for region in order 1) AWS_REGION env var, 2) ~/.aws/config file, 3) EC2 IMDS
awsCfg, err := config.LoadDefaultConfig(context.TODO(), config.WithEC2IMDSRegion())

// TODO: configure session
awsRegion := os.Getenv("AWS_REGION")
setupLog.Info("configuring AWS session", "AWS_REGION", awsRegion)
awsCfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithRegion(awsRegion),
)
if err != nil {
setupLog.Error(err, "unable to configure AWS session", "AWS_REGION", awsRegion)
if err != nil || awsCfg.Region == "" {
setupLog.Error(err, "unable to configure AWS session", "AWS_REGION", awsCfg.Region)
os.Exit(1)
}

setupLog.Info("Running with AWS region", "AWS_REGION", awsCfg.Region)

serviceDiscoveryClient := cloudmap.NewDefaultServiceDiscoveryClient(&awsCfg)
if err = (&controllers.ServiceExportReconciler{
Client: mgr.GetClient(),
Expand Down