Skip to content

Commit

Permalink
CB-25754 Configurable CP region, security group and added destroy script
Browse files Browse the repository at this point in the history
  • Loading branch information
daszabo committed Aug 1, 2024
1 parent 7dd1304 commit 47a6eed
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 7 deletions.
21 changes: 21 additions & 0 deletions aws/destroy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Copyright 2024 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cd cdp-tf-quickstarts/aws

source variables.sh

${HOME}/terraform destroy -auto-approve
27 changes: 25 additions & 2 deletions aws/quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,31 @@
export TF_VAR_aws_region="${1:-""}"
export TF_VAR_env_prefix="${2:-""}"
export ACCOUNT_ID="${3:-""}"
export TF_VAR_deployment_template="${4:-"semi-private"}"
export CDP_REGION="${4:-"us-west-1"}"
export TF_VAR_deployment_template="${5:-"semi-private"}"
export TF_VAR_ingress_extra_cidrs_and_ports="${6:-"{ cidrs = [\"0.0.0.0/0\"], ports = [443, 22] }"}"
export TF_VAR_env_tags='{"deploy_tool": "express-tf", "env_prefix": "'"$2"'"}'
export TF_VAR_create_vpc_endpoints="false"
export TF_VAR_environment_async_creation="true"
export TF_VAR_datalake_async_creation="true"
export TF_VAR_ingress_extra_cidrs_and_ports='{ cidrs = ["0.0.0.0/0"], ports = [443, 22] }'

# Save TF variables to file
output_file="variables.sh"

cat <<EOF > $output_file
export TF_VAR_aws_region="${TF_VAR_aws_region}"
export TF_VAR_env_prefix="${TF_VAR_env_prefix}"
export ACCOUNT_ID="${ACCOUNT_ID}"
export TF_VAR_deployment_template="${TF_VAR_deployment_template}"
export TF_VAR_env_tags="${TF_VAR_env_tags}"
export TF_VAR_create_vpc_endpoints="${TF_VAR_create_vpc_endpoints}"
export TF_VAR_environment_async_creation="${TF_VAR_environment_async_creation}"
export TF_VAR_datalake_async_creation="${TF_VAR_datalake_async_creation}"
export TF_VAR_ingress_extra_cidrs_and_ports="${TF_VAR_ingress_extra_cidrs_and_ports}"
EOF

# Make the file executable
chmod +x $output_file

# Install Terraform
curl -fsSL https://releases.hashicorp.com/terraform/1.7.1/terraform_1.7.1_linux_amd64.zip -o terraform.zip
Expand All @@ -36,6 +55,10 @@ cd cdp-tf-quickstarts/aws
# Install CDP CLI and Log In
pip install cdpcli

config_file="${HOME}/.cdp/config"
region_config="cdp_region = ${CDP_REGION}"
echo "$region_config" >> "$config_file"

cdp login --account-id "${ACCOUNT_ID}" --use-device-code

# Apply Terraform Quickstart Module
Expand Down
21 changes: 21 additions & 0 deletions azure/destroy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Copyright 2024 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cd cdp-tf-quickstarts/azure

source variables.sh

terraform destroy -auto-approve
28 changes: 25 additions & 3 deletions azure/quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.

export TF_VAR_azure_region"=${1:-""}"
export TF_VAR_azure_region="${1:-""}"
export TF_VAR_env_prefix="${2:-""}"
export ACCOUNT_ID="${3:-""}"
export TF_VAR_deployment_template="${4:-"semi-private"}"
export CDP_REGION="${4:-"us-west-1"}"
export TF_VAR_deployment_template="${5:-"semi-private"}"
export TF_VAR_ingress_extra_cidrs_and_ports="${6:-"{ cidrs = [\"0.0.0.0/0\"], ports = [443, 22] }"}"
export TF_VAR_env_tags='{"deploy_tool": "express-tf", "env_prefix": "'"$2"'"}'
export TF_VAR_environment_async_creation="true"
export TF_VAR_datalake_async_creation="true"
export TF_VAR_ingress_extra_cidrs_and_ports='{ cidrs = ["0.0.0.0/0], ports = [443, 22] }'

# Save TF variables to file
output_file="variables.sh"

cat <<EOF > $output_file
export TF_VAR_azure_region="${TF_VAR_azure_region}"
export TF_VAR_env_prefix="${TF_VAR_env_prefix}"
export ACCOUNT_ID="${ACCOUNT_ID}"
export TF_VAR_deployment_template="${TF_VAR_deployment_template}"
export TF_VAR_env_tags="${TF_VAR_env_tags}"
export TF_VAR_environment_async_creation="${TF_VAR_environment_async_creation}"
export TF_VAR_datalake_async_creation="${TF_VAR_datalake_async_creation}"
export TF_VAR_ingress_extra_cidrs_and_ports="${TF_VAR_ingress_extra_cidrs_and_ports}"
EOF

# Make the file executable
chmod +x $output_file

# Checkout CDP Quickstart Repository
git clone --branch v0.7.2 https://github.com/cloudera-labs/cdp-tf-quickstarts.git
Expand All @@ -30,6 +48,10 @@ cd cdp-tf-quickstarts/azure
# Install CDP CLI and Log In
pip install cdpcli

config_file="${HOME}/.cdp/config"
region_config="cdp_region = ${CDP_REGION}"
echo "$region_config" >> "$config_file"

cdp login --account-id "${ACCOUNT_ID}" --use-device-code

# Apply Terraform Quickstart Module
Expand Down
21 changes: 21 additions & 0 deletions gcp/destroy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Copyright 2024 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cd cdp-tf-quickstarts/gcp

source variables.sh

terraform destroy -auto-approve
27 changes: 25 additions & 2 deletions gcp/quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,30 @@ export TF_VAR_gcp_project="${1:-""}"
export TF_VAR_gcp_region="${2:-""}"
export TF_VAR_env_prefix="${3:-""}"
export ACCOUNT_ID="${4:-""}"
export TF_VAR_deployment_template="${5:-"semi-private"}"
export CDP_REGION="${5:-"us-west-1"}"
export TF_VAR_deployment_template="${6:-"semi-private"}"
export TF_VAR_ingress_extra_cidrs_and_ports="${7:-"{ cidrs = [\"0.0.0.0/0\"], ports = [443, 22] }"}"
export TF_VAR_env_tags='{"deploy_tool": "express-tf", "env_prefix": "'"$2"'"}'
export TF_VAR_environment_async_creation="true"
export TF_VAR_datalake_async_creation="true"
export TF_VAR_ingress_extra_cidrs_and_ports='{ cidrs = ["0.0.0.0/0"], ports = [443, 22] }'

# Save TF variables to file
output_file="variables.sh"

cat <<EOF > $output_file
export TF_VAR_gcp_project="${TF_VAR_gcp_project}"
export TF_VAR_gcp_region="${TF_VAR_gcp_region}"
export TF_VAR_env_prefix="${TF_VAR_env_prefix}"
export ACCOUNT_ID="${ACCOUNT_ID}"
export TF_VAR_deployment_template="${TF_VAR_deployment_template}"
export TF_VAR_env_tags="${TF_VAR_env_tags}"
export TF_VAR_environment_async_creation="${TF_VAR_environment_async_creation}"
export TF_VAR_datalake_async_creation="${TF_VAR_datalake_async_creation}"
export TF_VAR_ingress_extra_cidrs_and_ports="${TF_VAR_ingress_extra_cidrs_and_ports}"
EOF

# Make the file executable
chmod +x $output_file

# Checkout CDP Quickstart Repository
git clone --branch v0.7.2 https://github.com/cloudera-labs/cdp-tf-quickstarts.git
Expand All @@ -31,6 +50,10 @@ cd cdp-tf-quickstarts/gcp
# Install CDP CLI and Log In
pip install cdpcli

config_file="${HOME}/.cdp/config"
region_config="cdp_region = ${CDP_REGION}"
echo "$region_config" >> "$config_file"

cdp login --account-id "${ACCOUNT_ID}" --use-device-code

# Apply Terraform Quickstart Module
Expand Down

0 comments on commit 47a6eed

Please sign in to comment.