Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Fix external name configuration for ECS Service
Browse files Browse the repository at this point in the history
Fixes #170

Signed-off-by: Hasan Turken <[email protected]>
(cherry picked from commit 39932472c6cd6bba3db75bdb4b8ae674fcabf995)
  • Loading branch information
turkenh committed Mar 17, 2022
1 parent 4264c58 commit 7079281
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions config/ecs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ func Configure(p *config.Provider) {
r.Version = common.VersionV1Alpha2
r.ExternalName = config.NameAsIdentifier
r.ExternalName.GetExternalNameFn = func(tfstate map[string]interface{}) (string, error) {
// cluster-name/service-name
// expected id format: arn:aws:ecs:us-east-2:123456789123:service/hasan-test/sample-service-by-hasan
w := strings.Split(tfstate["id"].(string), "/")
if len(w) != 2 {
return "", errors.New("external name should have the following format: cluster-name/service-name")
if len(w) != 3 {
return "", errors.New("terraform ID should be the ARN of the cluster")
}
return w[len(w)-1], nil
}
Expand Down
10 changes: 10 additions & 0 deletions examples/ecs/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: ecs.aws.jet.crossplane.io/v1alpha2
kind: Service
metadata:
name: sample-service
spec:
forProvider:
taskDefinition: sample-task:1
cluster: sample-cluster
region: us-east-2
propagateTags: TASK_DEFINITION

0 comments on commit 7079281

Please sign in to comment.