forked from confluentinc/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEVX-815: Automatically spin up a CCloud stack for developers to test (…
- Loading branch information
Showing
9 changed files
with
885 additions
and
470 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ log.* | |
*.csr | ||
*.srl | ||
*_creds | ||
**/stack-configs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
![image](../../images/confluent-logo-300-2.png) | ||
|
||
# Fully Managed Stack in Confluent Cloud | ||
|
||
## Overview | ||
|
||
This script creates a stack of fully managed services in Confluent Cloud. | ||
It is a quick way to create fully managed resources in Confluent Cloud, which you can then use for learning and building other demos. | ||
Do not use this in a production environment. | ||
The script uses the Confluent Cloud CLI to dynamically do the following in Confluent Cloud: | ||
|
||
* Create a new environment | ||
* Create a new service account | ||
* Create a new Kafka cluster and associated credentials | ||
* Enable Schema Registry and associated credentials | ||
* Create a new KSQL app and associated credentials | ||
* Create ACLs with wildcard for the service account | ||
* Generate a local configuration file with all above connection information, useful for other demos/automation | ||
|
||
## DISCLAIMER | ||
|
||
This demo is learning purposes only. | ||
If you choose to run it against your Confluent Cloud cluster, be aware that it creates resources and incurs charges. | ||
It is for demo purposes only and should be used only on a non-production cluster. | ||
|
||
## Create | ||
|
||
To create the stack: | ||
|
||
```bash | ||
./ccloud_stack_create.sh | ||
``` | ||
|
||
## Destroy | ||
|
||
To destroy the stack, pass the client properties file auto-generated in the step above: | ||
|
||
```bash | ||
./ccloud stack_destroy.sh stack-configs/java-service-account-<SERVICE_ACCOUNT_ID>.config | ||
``` | ||
|
||
# Other Resources | ||
|
||
See other [Confluent Cloud demos](../README.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
######################################### | ||
# This script uses real Confluent Cloud resources. | ||
# To avoid unexpected charges, carefully evaluate the cost of resources before launching the script and ensure all resources are destroyed after you are done running it. | ||
######################################### | ||
|
||
|
||
# Source library | ||
. ../../utils/helper.sh | ||
|
||
check_ccloud_version 1.0.0 || exit 1 | ||
check_jq || exit 1 | ||
check_ccloud_logged_in || exit 1 | ||
|
||
prompt_continue_cloud_demo || exit 1 | ||
|
||
enable_ksql=false | ||
read -p "Do you also want to create a Confluent Cloud KSQL app (hourly charges may apply)? [y/n] " -n 1 -r | ||
echo | ||
if [[ $REPLY =~ ^[Yy]$ ]] | ||
then | ||
enable_ksql=true | ||
fi | ||
|
||
echo | ||
echo "Creating..." | ||
cloud_create_demo_stack $enable_ksql | ||
|
||
echo | ||
echo "Validating..." | ||
SERVICE_ACCOUNT_ID=$(ccloud kafka cluster list -o json | jq -r '.[0].name' | awk -F'-' '{print $4;}') | ||
CONFIG_FILE=stack-configs/java-service-account-$SERVICE_ACCOUNT_ID.config | ||
check_ccloud_config $CONFIG_FILE || exit 1 | ||
../ccloud-generate-cp-configs.sh $CONFIG_FILE > /dev/null | ||
source delta_configs/env.delta | ||
|
||
if $enable_ksql ; then | ||
MAX_WAIT=720 | ||
echo "Waiting up to $MAX_WAIT seconds for Confluent Cloud KSQL cluster to be UP" | ||
retry $MAX_WAIT check_ccloud_ksql_endpoint_ready $KSQL_ENDPOINT || exit 1 | ||
fi | ||
|
||
ccloud_demo_preflight_check $CLOUD_KEY $CONFIG_FILE $enable_ksql || exit 1 | ||
|
||
echo | ||
echo "ACLs for service account: $SERVICE_ACCOUNT_ID" | ||
ccloud kafka acl list --service-account $SERVICE_ACCOUNT_ID | ||
|
||
echo | ||
echo "Local client configuration file written to $CONFIG_FILE" | ||
echo | ||
|
||
echo | ||
echo "To destroy this Confluent Cloud stack run ->" | ||
echo " ./ccloud_stack_destroy.sh $CONFIG_FILE" | ||
echo | ||
|
||
echo | ||
ENVIRONMENT=$(ccloud environment list | grep demo-env-$SERVICE_ACCOUNT_ID | tr -d '\*' | awk '{print $1;}') | ||
echo "Tip: 'ccloud' CLI has been set to the new environment $ENVIRONMENT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
|
||
# Source library | ||
. ../../utils/helper.sh | ||
|
||
check_ccloud_version 1.0.0 || exit 1 | ||
check_jq || exit 1 | ||
check_ccloud_logged_in || exit 1 | ||
|
||
if [ -z "$1" ]; then | ||
echo "ERROR: Must supply argument that is the client configuration file created from './ccloud_stack_create.sh'. (Is it in stacks-config/ folder?) " | ||
exit 1 | ||
else | ||
CONFIG_FILE=$1 | ||
fi | ||
|
||
check_ccloud_config $CONFIG_FILE || exit 1 | ||
../ccloud-generate-cp-configs.sh $CONFIG_FILE > /dev/null | ||
source delta_configs/env.delta | ||
SERVICE_ACCOUNT_ID=$(ccloud_cli_get_service_account $CLOUD_KEY $CONFIG_FILE) || exit 1 | ||
|
||
echo | ||
echo "Destroying..." | ||
cloud_delete_demo_stack $SERVICE_ACCOUNT_ID | ||
|
||
echo | ||
echo "Tip: 'ccloud' CLI currently has no environment set" |
Oops, something went wrong.