Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit 5c02534

Browse files
authored
Merge pull request #121 from awslabs/fix-s3-urls-for-cfts
Fixed url construction to work with all regions
2 parents 75b62ca + b2fe798 commit 5c02534

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

pkg/customizations/cloudformationtemplate/cloudformationtemplate.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package cloudformationtemplate
22

33
import (
44
"bytes"
5+
"reflect"
6+
57
"github.com/aws/aws-sdk-go/aws"
68
"github.com/aws/aws-sdk-go/aws/session"
79
"github.com/aws/aws-sdk-go/service/s3"
810
awsV1alpha1 "github.com/awslabs/aws-service-operator/pkg/apis/service-operator.aws/v1alpha1"
911
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
1012
"github.com/awslabs/aws-service-operator/pkg/config"
1113
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12-
"reflect"
1314
)
1415

1516
// OnAdd will be fired when you add a new CFT
@@ -82,7 +83,7 @@ func updateOutput(config *config.Config, cft *awsV1alpha1.CloudFormationTemplate
8283
resourceCopy := resource.DeepCopy()
8384
resourceCopy.Status.ResourceStatus = status
8485
resourceCopy.Status.ResourceStatusReason = reason
85-
resourceCopy.Output.URL = "https://" + config.Bucket + ".s3-" + config.Region + ".amazonaws.com/" + cft.Data.Key
86+
resourceCopy.Output.URL = "https://s3." + config.Region + ".amazonaws.com/" + config.Bucket + "/" + cft.Data.Key
8687

8788
_, err = clientSet.CloudFormationTemplates(cft.Namespace).Update(resourceCopy)
8889
if err != nil {

pkg/helpers/helpers.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ package helpers
22

33
import (
44
"bytes"
5-
"github.com/aws/aws-sdk-go/service/cloudformation"
6-
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
7-
"github.com/awslabs/aws-service-operator/pkg/config"
8-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
95
"reflect"
106
"regexp"
117
"strconv"
128
"strings"
139
"text/template"
10+
11+
"github.com/aws/aws-sdk-go/service/cloudformation"
12+
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
13+
"github.com/awslabs/aws-service-operator/pkg/config"
14+
"github.com/sirupsen/logrus"
15+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1416
)
1517

1618
// KubernetesResourceName returns the resource name for other components
@@ -101,5 +103,11 @@ func GetCloudFormationTemplate(config *config.Config, rType string, name string,
101103
logger.WithError(err).Error("error getting cloudformation template returning fallback template")
102104
return "https://s3-us-west-2.amazonaws.com/cloudkit-templates/" + rType + ".yaml"
103105
}
106+
107+
logger.WithFields(logrus.Fields{
108+
"namespace": cNamespace,
109+
"name": cName,
110+
"url": resource.Output.URL,
111+
}).Info("found cloudformation template")
104112
return resource.Output.URL
105113
}

0 commit comments

Comments
 (0)