You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/12/23 10:57:50 UTC

[shardingsphere-on-cloud] branch main updated: feat(terraform): support multi version config for shardingsphere proxy in aws (#156)

This is an automated email from the ASF dual-hosted git repository.

sunnianjun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shardingsphere-on-cloud.git


The following commit(s) were added to refs/heads/main by this push:
     new 0a050fd  feat(terraform): support multi version config for shardingsphere proxy in aws (#156)
0a050fd is described below

commit 0a050fd5fd7838872ed0ac788739981480299778
Author: pierce <xu...@gmail.com>
AuthorDate: Fri Dec 23 18:57:45 2022 +0800

    feat(terraform): support multi version config for shardingsphere proxy in aws (#156)
    
    Signed-off-by: xuanyuan300 <xu...@gmail.com>
    
    Signed-off-by: xuanyuan300 <xu...@gmail.com>
---
 terraform/amazon/shardingsphere/cloud-init.yml | 23 +++++++++++++++++++++--
 terraform/amazon/shardingsphere/main.tf        |  1 +
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/terraform/amazon/shardingsphere/cloud-init.yml b/terraform/amazon/shardingsphere/cloud-init.yml
index 9a809e9..5ed6aea 100644
--- a/terraform/amazon/shardingsphere/cloud-init.yml
+++ b/terraform/amazon/shardingsphere/cloud-init.yml
@@ -39,6 +39,7 @@ write_files:
     [Install]
     WantedBy=default.target
 
+%{ if element(version_elems, 0) <= 5 && element(version_elems, 1) < 3 }
 - path: /run/server.yaml
   permissions: 0644
   content: |
@@ -93,7 +94,23 @@ write_files:
       proxy-mysql-default-version: 5.7.22 # In the absence of schema name, the default version will be used.
       proxy-default-port: 3307 # Proxy default port.
       proxy-netty-backlog: 1024 # Proxy netty backlog.
-
+%{ endif }
+%{ if element(version_elems, 0) >= 5 && element(version_elems, 1) > 2 }
+- path: /run/server.yaml
+  permissions: 0644
+  content: |
+    mode:
+      type: Cluster
+      repository:
+        type: ZooKeeper
+        props:
+          namespace: governance_ds
+          server-lists: ${zk_servers}
+          retryIntervalMilliseconds: 500
+          timeToLiveSeconds: 60
+          maxRetries: 3
+          operationTimeoutMilliseconds: 500
+%{ endif }
 - path: /run/install_shardingsphere_proxy.sh
   permissions: 0700
   content: |
@@ -101,7 +118,9 @@ write_files:
     wget -O /run/ss.tar.gz https://archive.apache.org/dist/shardingsphere/${version}/apache-shardingsphere-${version}-shardingsphere-proxy-bin.tar.gz
     mkdir -p /usr/local/shardingsphere-proxy
     tar xvf /run/ss.tar.gz --strip 1 -C /usr/local/shardingsphere-proxy
-    /bin/cp -avf /run/server.yaml /usr/local/shardingsphere-proxy/conf/server.yaml
+    if [ -f /run/server.yaml ]; then
+      /bin/cp -avf /run/server.yaml /usr/local/shardingsphere-proxy/conf/server.yaml
+    fi
     /bin/cp -avf /run/shardingsphere-proxy.service /usr/lib/systemd/system/shardingsphere-proxy.service
     systemctl daemon-reload
     systemctl enable shardingsphere-proxy
diff --git a/terraform/amazon/shardingsphere/main.tf b/terraform/amazon/shardingsphere/main.tf
index 7481b24..871a55c 100644
--- a/terraform/amazon/shardingsphere/main.tf
+++ b/terraform/amazon/shardingsphere/main.tf
@@ -91,6 +91,7 @@ resource "aws_launch_template" "ss" {
 
   user_data = base64encode(templatefile("${path.module}/cloud-init.yml", {
     version    = var.shardingsphere_proxy_version
+    version_elems = split(".", var.shardingsphere_proxy_version)
     zk_servers = join(",", var.zk_servers)
   }))