Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 1480293

Browse files
author
Nils K
committed
init
1 parent ae8c85c commit 1480293

File tree

82 files changed

+3945
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3945
-0
lines changed

Diff for: 01_project/01_create_project.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
# Create project and enable billing
4+
5+
################################################################################
6+
# INCLUDE FUNCTIONS
7+
################################################################################
8+
9+
MY_INCLUDE='../inc/include.sh'
10+
# ignore SC1090
11+
# shellcheck source=/dev/null
12+
if ! source "$MY_INCLUDE"; then
13+
ME=$(basename "$0")
14+
BASE_PATH=$(dirname "$0")
15+
echo;echo "× Can not read required include file '$MY_INCLUDE'";echo
16+
echo " Please start the script directly in the directory:"
17+
echo " cd $BASE_PATH && bash $ME";echo
18+
exit 9
19+
fi
20+
21+
################################################################################
22+
# MAIN
23+
################################################################################
24+
25+
# Get first acitive billing account or exit_with_failure
26+
get_billing_account
27+
28+
# Create new project or exit_with_failure
29+
# In: MY_GCP_PROJECT, MY_GCP_FOLDER
30+
create_project
31+
32+
# Enable billing for the new project or exit_with_failure
33+
enable_billing
34+
35+
# Done
36+
echo_success "Project successfully created"

Diff for: 01_project/02_enable_services.sh

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
# Enable APIs and services
4+
5+
################################################################################
6+
# INCLUDE FUNCTIONS
7+
################################################################################
8+
9+
MY_INCLUDE='../inc/include.sh'
10+
# ignore SC1090
11+
# shellcheck source=/dev/null
12+
if ! source "$MY_INCLUDE"; then
13+
ME=$(basename "$0")
14+
BASE_PATH=$(dirname "$0")
15+
echo;echo "× Can not read required include file '$MY_INCLUDE'";echo
16+
echo " Please start the script directly in the directory:"
17+
echo " cd $BASE_PATH && bash $ME";echo
18+
exit 9
19+
fi
20+
21+
################################################################################
22+
# MAIN
23+
################################################################################
24+
25+
# Enable default services for consumption for the new project
26+
# In: MY_GCP_SERVICES
27+
enable_services
28+
29+
# Enabling interactive serial console access for all VM instances that are part the project
30+
enable_serial_console
31+
32+
# Check MY_WARNING and exit with echo_success or echo_failure
33+
# In: MY_WARNING
34+
check_warning_and_exit "All services activated"

Diff for: 01_project/10_list_project.sh

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
# List project content
4+
5+
################################################################################
6+
# INCLUDE FUNCTIONS
7+
################################################################################
8+
9+
MY_INCLUDE='../inc/include.sh'
10+
# ignore SC1090
11+
# shellcheck source=/dev/null
12+
if ! source "$MY_INCLUDE"; then
13+
ME=$(basename "$0")
14+
BASE_PATH=$(dirname "$0")
15+
echo;echo "× Can not read required include file '$MY_INCLUDE'";echo
16+
echo " Please start the script directly in the directory:"
17+
echo " cd $BASE_PATH && bash $ME";echo
18+
exit 9
19+
fi
20+
21+
################################################################################
22+
# MAIN
23+
################################################################################
24+
25+
echo_title "List project '$MY_GCP_PROJECT'"
26+
echo_web "https://console.cloud.google.com/home/activity?project=$MY_GCP_PROJECT"
27+
28+
# List all service accounts
29+
list_service_accounts
30+
31+
# List all Compute Engine routers
32+
list_routers
33+
34+
# List all Compute Engine subnets and networks
35+
list_subnets
36+
37+
# List all non-dynamic Google Compute Engine routes
38+
list_routes
39+
40+
# List all firewall rules
41+
list_firewall_rules
42+
43+
# List all storage buckets
44+
list_storage
45+
46+
# List all secret names
47+
list_secrets
48+
49+
# List all Compute Engine virtual machine instances
50+
list_vms

Diff for: 01_project/99_delete_project_and_all_data.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
# Delete project and all data
4+
5+
################################################################################
6+
# INCLUDE FUNCTIONS
7+
################################################################################
8+
9+
MY_INCLUDE='../inc/include.sh'
10+
# ignore SC1090
11+
# shellcheck source=/dev/null
12+
if ! source "$MY_INCLUDE"; then
13+
ME=$(basename "$0")
14+
BASE_PATH=$(dirname "$0")
15+
echo;echo "× Can not read required include file '$MY_INCLUDE'";echo
16+
echo " Please start the script directly in the directory:"
17+
echo " cd $BASE_PATH && bash $ME";echo
18+
exit 9
19+
fi
20+
21+
################################################################################
22+
# MAIN
23+
################################################################################
24+
25+
echo_title "Delete Google Cloud project with ID '$MY_GCP_PROJECT' and all stored data"
26+
if gcloud projects delete "$MY_GCP_PROJECT"; then
27+
echo_success "Project successfully deleted"
28+
else
29+
exit_with_failure "Project could not be deleted"
30+
fi

Diff for: 01_project/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Project
2+
3+
Create project and enable billing, APIs and services.
4+
5+
## Scripts
6+
7+
* `01_create_project.sh` : Create project and enable billing
8+
* `02_enable_services.sh` : Enable APIs and services
9+
* `10_list_project.sh` : List project content
10+
* `99_delete_project_and_all_data.sh` : Delete project and all data

Diff for: 02_network/01_create_network.sh

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
# Create a Virtual Private Cloud (VPC)
4+
5+
################################################################################
6+
# INCLUDE FUNCTIONS
7+
################################################################################
8+
9+
MY_INCLUDE='../inc/include.sh'
10+
# ignore SC1090
11+
# shellcheck source=/dev/null
12+
if ! source "$MY_INCLUDE"; then
13+
ME=$(basename "$0")
14+
BASE_PATH=$(dirname "$0")
15+
echo;echo "× Can not read required include file '$MY_INCLUDE'";echo
16+
echo " Please start the script directly in the directory:"
17+
echo " cd $BASE_PATH && bash $ME";echo
18+
exit 9
19+
fi
20+
21+
################################################################################
22+
# MAIN
23+
################################################################################
24+
25+
# Create a Compute Engine network (VPC)
26+
# In: MY_GCP_NETWORK
27+
create_network
28+
29+
# Define a subnet with IP range for the network
30+
# In: MY_GCP_SUBNET, MY_GCP_SUBNET_RANGE, MY_GCP_NETWORK, MY_GCP_REGION
31+
create_subnet
32+
33+
# Create a Compute Engine router
34+
# In: MY_GCP_ROUTER, MY_GCP_NETWORK, MY_GCP_REGION
35+
create_router
36+
37+
# Add a NAT to a Compute Engine router
38+
# In: MY_GCP_NAT, MY_GCP_ROUTER, MY_GCP_REGION
39+
create_nat
40+
41+
# Create firewall rules
42+
# In: MY_GCP_FIREWALL_RULES, MY_GCP_NETWORK
43+
create_firewall_rules
44+
45+
# Check MY_WARNING and exit with echo_success or echo_failure
46+
# In: MY_WARNING
47+
check_warning_and_exit "Virtual Private Cloud (VPC) network set up successfully"

Diff for: 02_network/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Network
2+
3+
Create a Virtual Private Cloud (VPC) network, subnet, Compute Engine router and firewall rules.
4+
5+
## Scripts
6+
7+
* `01_create_network.sh` : Create a Virtual Private Cloud (VPC)
8+
9+
## Firewall rules
10+
11+
Allow:
12+
13+
* SSH: 22
14+
* RDP: 3389
15+
* SAP Dispatcher: 3200-3299
16+
* Gateway: 3300-3399
17+
* Message server: 3600-3699
18+
* HTTP: 80
19+
* ICM HTTP: 8000-8999
20+
* HTTPS: 443
21+
* ICM HTTPS: 44300-44399
22+
* SAP Central Services: 50000-59999

Diff for: 03_storage/01_create_storage_bucket.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
# Create Google Cloud storage bucket
4+
5+
################################################################################
6+
# INCLUDE FUNCTIONS
7+
################################################################################
8+
9+
MY_INCLUDE='../inc/include.sh'
10+
# ignore SC1090
11+
# shellcheck source=/dev/null
12+
if ! source "$MY_INCLUDE"; then
13+
ME=$(basename "$0")
14+
BASE_PATH=$(dirname "$0")
15+
echo;echo "× Can not read required include file '$MY_INCLUDE'";echo
16+
echo " Please start the script directly in the directory:"
17+
echo " cd $BASE_PATH && bash $ME";echo
18+
exit 9
19+
fi
20+
21+
################################################################################
22+
# MAIN
23+
################################################################################
24+
25+
# Create Google Cloud storage bucket or exit_with_failure
26+
# In: MY_GCP_STORAGE, MY_GCP_REGION
27+
create_storage
28+
29+
# Done
30+
echo_success "Storage bucket successfully created"

Diff for: 03_storage/10_sync_storage_bucket.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
# Synchronize local directory to Google Cloud storage bucket
4+
5+
################################################################################
6+
# INCLUDE FUNCTIONS
7+
################################################################################
8+
9+
MY_INCLUDE='../inc/include.sh'
10+
# ignore SC1090
11+
# shellcheck source=/dev/null
12+
if ! source "$MY_INCLUDE"; then
13+
ME=$(basename "$0")
14+
BASE_PATH=$(dirname "$0")
15+
echo;echo "× Can not read required include file '$MY_INCLUDE'";echo
16+
echo " Please start the script directly in the directory:"
17+
echo " cd $BASE_PATH && bash $ME";echo
18+
exit 9
19+
fi
20+
21+
################################################################################
22+
# MAIN
23+
################################################################################
24+
25+
# Sync storage bucket
26+
# In: MY_GCP_STORAGE
27+
sync_storage
28+
29+
# Display object size usage
30+
du_storage
31+
32+
echo_info "Synchronize content"
33+
echo "Upload:"
34+
echo " $ gsutil -m rsync -r $MY_STORAGE_BUCKET_DIR gs://$MY_GCP_STORAGE"
35+
echo
36+
echo "Download:"
37+
echo " Linux: gsutil -m rsync -r gs://$MY_GCP_STORAGE ~/Downloads"
38+
echo " Windows: gsutil -m rsync -r gs://$MY_GCP_STORAGE %HOMEPATH%\Downloads"
39+
40+
echo_web "Browser: https://console.cloud.google.com/storage/browser/$MY_GCP_STORAGE?project=$MY_GCP_PROJECT"
41+
42+
# Check MY_WARNING and exit with echo_success or echo_failure
43+
# In: MY_WARNING
44+
check_warning_and_exit "Storage bucket synchronized successfully"

Diff for: 03_storage/99_delete_storage_bucket.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# Delete storage bucket
4+
5+
################################################################################
6+
# INCLUDE FUNCTIONS
7+
################################################################################
8+
9+
MY_INCLUDE='../inc/include.sh'
10+
# ignore SC1090
11+
# shellcheck source=/dev/null
12+
if ! source "$MY_INCLUDE"; then
13+
ME=$(basename "$0")
14+
BASE_PATH=$(dirname "$0")
15+
echo;echo "× Can not read required include file '$MY_INCLUDE'";echo
16+
echo " Please start the script directly in the directory:"
17+
echo " cd $BASE_PATH && bash $ME";echo
18+
exit 9
19+
fi
20+
21+
################################################################################
22+
# MAIN
23+
################################################################################
24+
25+
# Delete storage bucket
26+
# In: MY_GCP_STORAGE
27+
delete_storage
28+
29+
# Check MY_WARNING and exit with echo_success or echo_failure
30+
# In: MY_WARNING
31+
check_warning_and_exit "Storage bucket deleted successfully"

Diff for: 03_storage/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Cloud Storage
2+
3+
Create Google Cloud storage bucket for startup scripts and software.
4+
5+
## Pricing
6+
7+
[Google Cloud Pricing Calculator](https://cloud.google.com/products/calculator/#id=694e0c63-47b3-4a77-8d26-5404f0bceb10)
8+
9+
* 1x Standard Storage
10+
* Location: Finland
11+
* Total Amount of Storage: 15 GiB
12+
* Total Estimated Cost: USD 0.30 per 1 month
13+
14+
Information without guarantee.
15+
16+
## Scripts
17+
18+
* `01_create_storage_bucket.sh` : Create Google Cloud storage bucket
19+
* `10_sync_storage_bucket.sh` : Synchronize local directory to storage bucket
20+
* `99_delete_storage_bucket.sh` : Delete storage bucket

0 commit comments

Comments
 (0)