This repository was archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
[ECO-1681] add terraform support #10
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -1 +1,8 @@ | ||
.env | ||
terraform/creds.json | ||
terraform/.terraform | ||
terraform/.terraform.lock.hcl | ||
terraform/.terraform.tfstate.lock.info | ||
terraform/*.tfvars | ||
terraform/*.tfstate | ||
terraform/*.backup | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,56 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
which jq > /dev/null 2>&1 || echo "ERROR: cannot find jq in PATH." && exit 1 | ||
which cloud-sql-proxy > /dev/null 2>&1 || echo "ERROR: cannot find cloud-sql-proxy in PATH." && exit 1 | ||
|
||
if [[ -z "$PROJECT_ID" ]]; then | ||
echo "Must provide PROJECT_ID in environment" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
echo "Setting project:" | ||
gcloud config set project "$PROJECT_ID" | ||
|
||
echo "Enabling GCP APIs (be patient):" | ||
gcloud services enable \ | ||
artifactregistry.googleapis.com \ | ||
cloudbuild.googleapis.com \ | ||
cloudresourcemanager.googleapis.com \ | ||
compute.googleapis.com \ | ||
iam.googleapis.com \ | ||
run.googleapis.com \ | ||
servicenetworking.googleapis.com \ | ||
sqladmin.googleapis.com \ | ||
vpcaccess.googleapis.com | ||
|
||
echo "Creating service account:" | ||
gcloud iam service-accounts create terraform | ||
|
||
service_account_name="terraform@$PROJECT_ID.iam.gserviceaccount.com" | ||
|
||
script_dir=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")") | ||
|
||
gcloud iam service-accounts keys create \ | ||
"$script_dir/creds.json" \ | ||
--iam-account $service_account_name | ||
|
||
gcloud projects add-iam-policy-binding $PROJECT_ID \ | ||
--member serviceAccount:$service_account_name \ | ||
--role roles/editor | ||
|
||
# https://stackoverflow.com/a/61250654 | ||
gcloud projects add-iam-policy-binding $PROJECT_ID \ | ||
--member serviceAccount:$service_account_name \ | ||
--role roles/run.admin | ||
|
||
# https://serverfault.com/questions/942115 | ||
gcloud projects add-iam-policy-binding $PROJECT_ID \ | ||
--member serviceAccount:$service_account_name \ | ||
--role roles/compute.networkAdmin | ||
|
||
# https://stackoverflow.com/a/54351644 | ||
gcloud projects add-iam-policy-binding $PROJECT_ID \ | ||
--member serviceAccount:$service_account_name \ | ||
--role roles/servicenetworking.serviceAgent |
This file contains hidden or 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,76 @@ | ||
terraform { | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "5.8.0" | ||
} | ||
} | ||
required_version = ">= 0.12, < 2.0.0" | ||
} | ||
|
||
provider "google" { | ||
credentials = "creds.json" | ||
project = var.project_id | ||
region = var.region | ||
zone = var.zone | ||
} | ||
|
||
provider "google-beta" { | ||
credentials = "creds.json" | ||
project = var.project_id | ||
region = var.region | ||
zone = var.zone | ||
} | ||
|
||
module "db" { | ||
db_root_password = var.db_root_password | ||
credentials_file = var.credentials_file | ||
region = var.region | ||
source = "./modules/db" | ||
} | ||
|
||
module "processor" { | ||
db_conn_str_private = module.db.db_conn_str_private | ||
contract_address = var.contract_address | ||
migrations_complete = module.db.migrations_complete | ||
grpc_auth_token = var.grpc_auth_token | ||
grpc_data_service_url = var.grpc_data_service_url | ||
source = "./modules/processor" | ||
sql_network_id = module.db.sql_network_id | ||
starting_version = var.starting_version | ||
zone = var.zone | ||
} | ||
|
||
module "no_auth_policy" { | ||
source = "./modules/no_auth_policy" | ||
} | ||
|
||
module "postgrest" { | ||
db_conn_str_private = module.db.db_conn_str_private | ||
migrations_complete = module.db.migrations_complete | ||
no_auth_policy_data = module.no_auth_policy.policy_data | ||
postgrest_max_rows = var.postgrest_max_rows | ||
region = var.region | ||
source = "./modules/postgrest" | ||
sql_vpc_connector_id = module.db.sql_vpc_connector_id | ||
} | ||
|
||
module "mqtt" { | ||
db_conn_str_private = module.db.db_conn_str_private | ||
mosquitto_password = var.mosquitto_password | ||
source = "./modules/mqtt" | ||
sql_network_id = module.db.sql_network_id | ||
zone = var.zone | ||
} | ||
|
||
module "grafana" { | ||
db_conn_str_private_grafana = module.db.db_conn_str_private_grafana | ||
db_private_ip_and_port = module.db.db_private_ip_and_port | ||
grafana_admin_password = var.grafana_admin_password | ||
grafana_public_password = var.grafana_public_password | ||
migrations_complete = module.db.migrations_complete | ||
no_auth_policy_data = module.no_auth_policy.policy_data | ||
region = var.region | ||
source = "./modules/grafana" | ||
sql_vpc_connector_id = module.db.sql_vpc_connector_id | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.