#!/bin/bash #Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # #Permission is hereby granted, free of charge, to any person obtaining a copy of this #software and associated documentation files (the "Software"), to deal in the Software #without restriction, including without limitation the rights to use, copy, modify, #merge, publish, distribute, sublicense, and/or sell copies of the Software, and to #permit persons to whom the Software is furnished to do so. # #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, #INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A #PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION #OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE #SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. scripts_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR=$scripts_dir/.. # check to see if kubectl is already configured kubectl get svc || $scripts_dir/configure-eks-auth.sh # set aws region aws_region=$(aws configure get region) [[ -z "${aws_region}" ]] && echo "aws_region env variable is required" && exit 1 [[ -z "${s3_bucket_name}" ]] && echo "s3_bucket_name env variable is required" && exit 1 [[ -z "${redshift_cluster_host}" ]] && echo "redshift_cluster_host variable required" && exit 1 [[ -z "${redshift_cluster_port}" ]] && echo "redshift_cluster_port variable required" && exit 1 [[ -z "${redshift_cluster_username}" ]] && echo "redshift_cluster_username variable required" && exit 1 [[ -z "${redshift_cluster_dbname}" ]] && echo "redshift_cluster_dbname variable required" && exit 1 [[ -z "${redshift_cluster_password}" ]] && echo "redshift_cluster_password variable required" && exit 1 [[ -z "${msk_cluster_arn}" ]] && echo "msk_cluster_arn variable required" && exit 1 [[ -z "${eks_pod_sa_role_arn}" ]] && echo "eks_pod_sa_role_arn variable required" && exit 1 [[ -z "${eks_node_role_arn}" ]] && echo "eks_node_role_arn variable required" && exit 1 MSK_SERVERS=$(aws kafka --region ${aws_region} get-bootstrap-brokers \ --cluster-arn ${msk_cluster_arn} | \ grep \"BootstrapBrokerString\" | \ awk '{split($0, a, " "); print a[2]}') # update helm charts values.ymal and example client config files sed -i -e "s/\"servers\": .*/\"servers\": $MSK_SERVERS/g" \ -e "s/\"host\": .*/\"host\": \"${redshift_cluster_host}\",/g" \ -e "s/\"port\": .*/\"port\": \"${redshift_cluster_port}\",/g" \ -e "s/\"user\": .*/\"user\": \"${redshift_cluster_username}\",/g" \ -e "s/\"password\": .*/\"password\": \"${redshift_cluster_password}\",/g" \ -e "s/\"rosbag_bucket\": .*/\"rosbag_bucket\": \"${s3_bucket_name}\",/g" \ -e "s/\"cal_bucket\": .*/\"cal_bucket\": \"${s3_bucket_name}\",/g" \ -e "s|roleArn:.*|roleArn: ${eks_pod_sa_role_arn}|g" \ $DIR/a2d2/charts/a2d2-data-service/values.yaml # update helm charts values.ymal and example client config files sed -i -e "s/\"host\": .*/\"host\": \"${redshift_cluster_host}\",/g" \ -e "s/\"port\": .*/\"port\": \"${redshift_cluster_port}\",/g" \ -e "s/\"user\": .*/\"user\": \"${redshift_cluster_username}\",/g" \ -e "s/\"password\": .*/\"password\": \"${redshift_cluster_password}\",/g" \ -e "s/\"cal_bucket\": .*/\"cal_bucket\": \"${s3_bucket_name}\",/g" \ -e "s|roleArn:.*|roleArn: ${eks_pod_sa_role_arn}|g" \ $DIR/a2d2/charts/a2d2-rosbridge/values.yaml sed -i -e "s/\"servers\": .*/\"servers\": $MSK_SERVERS/g" \ $DIR/a2d2/config/c-config-ex1.json sed -i -e "s/\"servers\": .*/\"servers\": $MSK_SERVERS/g" \ $DIR/a2d2/config/c-config-ex2.json sed -i -e "s/\"servers\": .*/\"servers\": $MSK_SERVERS/g" \ $DIR/a2d2/config/c-config-ex3.json sed -i -e "s/\"servers\": .*/\"servers\": $MSK_SERVERS/g" \ $DIR/a2d2/config/c-config-ex4.json sed -i -e "s/\"servers\": .*/\"servers\": $MSK_SERVERS/g" \ $DIR/a2d2/config/c-config-lidar.json # Create kafka.config DATE=`date +%s` cat >$DIR/a2d2/config/kafka.config <> /home/ubuntu/.bashrc