1
1
#! /bin/bash
2
2
3
3
sleep_time=2
4
- env_file=" .env"
4
+ current_dir=$( pwd)
5
+ parent_dir=$( dirname " $current_dir " )
6
+
7
+ env_file=" ${parent_dir} /.env"
8
+ resources_file=" ${parent_dir} /resources.json"
5
9
6
10
# Use confluent environment
7
11
confluent login --save
@@ -21,7 +25,7 @@ export CCLOUD_BOOTSTRAP_ENDPOINT=$(confluent kafka cluster describe -o json | jq
21
25
STRIPPED_CCLOUD_BOOTSTRAP_ENDPOINT=$( echo $CCLOUD_BOOTSTRAP_ENDPOINT | sed ' s/SASL_SSL:\/\///' )
22
26
23
27
# use sed to replace kafka-cluster-endpoint with the replacement string
24
- sed -i .bak " s/kafka-cluster-endpoint/$STRIPPED_CCLOUD_BOOTSTRAP_ENDPOINT /g" $env_file
28
+ sed -i .bak " s/kafka-cluster-endpoint/$STRIPPED_CCLOUD_BOOTSTRAP_ENDPOINT /g" " $env_file "
25
29
echo " Added Kafka cluster endpoint to $env_file "
26
30
sleep $sleep_time
27
31
@@ -33,15 +37,50 @@ kafka_api_secret=$(echo $CREDENTIALS | jq -r '.api_secret')
33
37
sleep $sleep_time
34
38
35
39
# use sed to replace all instances of $kafka_api_key with the replacement string
36
- sed -i .bak " s^api-key^\" $kafka_api_key \" ^g" $env_file
37
- sed -i .bak " s^api-secret^\" $kafka_api_secret \" ^g" $env_file
40
+ sed -i .bak " s^api-key^\" $kafka_api_key \" ^g" " $env_file "
41
+ sed -i .bak " s^api-secret^\" $kafka_api_secret \" ^g" " $env_file "
38
42
echo " Added Kafka API key and secret to $env_file "
39
43
40
44
sleep $sleep_time
41
45
46
+ # Get schema registry info
47
+ export CCLOUD_SCHEMA_REGISTRY_ID=$( confluent sr cluster describe -o json | jq -r .cluster_id)
48
+ export CCLOUD_SCHEMA_REGISTRY_ENDPOINT=$( confluent sr cluster describe -o json | jq -r .endpoint_url)
49
+
50
+ echo " "
51
+ echo " Creating schema registry API key"
52
+ SR_CREDENTIALS=$( confluent api-key create --resource $CCLOUD_SCHEMA_REGISTRY_ID --description " demo-change-data-capture" -o json)
53
+ sr_api_key=$( echo $SR_CREDENTIALS | jq -r ' .api_key' )
54
+ sr_api_secret=$( echo $SR_CREDENTIALS | jq -r ' .api_secret' )
55
+ sleep $sleep_time
56
+
57
+ # use sed to replace all instances of $sr_api_key and $sr_api_secret with the replacement string
58
+ sed -i .bak " s^sr-key^\" $sr_api_key \" ^g" " $env_file "
59
+ sed -i .bak " s^sr-secret^\" $sr_api_secret \" ^g" " $env_file "
60
+ sed -i .bak " s^sr-cluster-endpoint^$CCLOUD_SCHEMA_REGISTRY_ENDPOINT ^g" " $env_file "
61
+ sleep $sleep_time
62
+
63
+ # source the $env_file file
64
+ source " $env_file "
65
+
66
+ # Create tags for topics
67
+ echo " "
68
+ echo " Creating tags"
69
+ ./create-tag.sh ./pii-tag.json
70
+ ./create-tag.sh ./private-tag.json
71
+ ./create-tag.sh ./sensitive-tag.json
72
+ ./create-tag.sh ./dataprod-tag.json
73
+ ./create-tag.sh ./raw-tag.json
74
+ ./create-tag.sh ./dlq-tag.json
75
+
76
+ # Create business metadata for topics
77
+ echo " "
78
+ echo " Creating business metadata"
79
+ ./create-business-metadata.sh ./team.txt
80
+
42
81
# Read values from resources.json and update the $env_file file.
43
82
# These resources are created by Terraform
44
- json=$( cat resources.json )
83
+ json=$( cat " $resources_file " )
45
84
46
85
oracle_endpoint=$( echo " $json " | jq -r ' .oracle_endpoint.value.address' )
47
86
postgres_products=$( echo " $json " | jq -r ' .postgres_instance_products_public_endpoint.value' )
@@ -53,14 +92,12 @@ redshift_endpoint=$(echo "$json" | jq -r '.redshift_endpoint.value')
53
92
redshift_address=$( echo $redshift_endpoint | sed ' s/:5439//' )
54
93
55
94
# Updating the $env_file file with sed command
56
- sed -i .bak " s^oracle-endpoint^$oracle_endpoint ^g" $env_file
57
- sed -i .bak " s^postgres-products^$postgres_products ^g" $env_file
58
- sed -i .bak " s^snowflake-private-key^\" $snowflake_svc_private_key \" ^g" $env_file
59
- sed -i .bak " s^redshift-address^$redshift_address ^g" $env_file
95
+ sed -i .bak " s^oracle-endpoint^$oracle_endpoint ^g" " $env_file "
96
+ sed -i .bak " s^postgres-products^$postgres_products ^g" " $env_file "
97
+ sed -i .bak " s^snowflake-private-key^\" $snowflake_svc_private_key \" ^g" " $env_file "
98
+ sed -i .bak " s^redshift-address^$redshift_address ^g" " $env_file "
60
99
61
100
echo " Added Oracle endpoint to $env_file "
62
101
echo " Added PostgreSQL endpoint to $env_file "
63
102
echo " Added Snowflake private key to $env_file "
64
103
echo " Added Amazon Redshift address to $env_file "
65
-
66
- # sleep $sleep_time
0 commit comments