-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_infra.sh
29 lines (21 loc) · 1.08 KB
/
setup_infra.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!usr/bin/bash
# This script is used to setup the final infrastructure for the project.
cd infra
terraform init
terraform plan --var-file=terraform.tfvars
terraform apply
# Activate source variables
source ../.env
# Create prefect profile
PREFECT_PROFILE_NAME="new_profile"
prefect profile create ${PREFECT_PROFILE_NAME}
prefect profile use ${PREFECT_PROFILE_NAME}
prefect config set PREFECT_API_KEY=${PREFECT_API_KEY} PREFECT_API_URL="https://api.prefect.cloud/api/accounts/${PREFECT_API_ACCOUNT_ID}/workspaces/${PREFECT_API_WORKSPACE_ID}"
# Authenticate to prefect cloud
prefect cloud logout
prefect cloud login -k ${PREFECT_API_KEY}
# Use terraform output to obtain variables to create prefect blocks
python -c "import prefect_infra; prefect_infra.build_blocks(filepath_gcp_creds=$(terraform output gcp_credentials), aq_bucket_name=$(terraform output gcs_aq_bucket_name), weather_bucket_name=$(terraform output gcs_weather_bucket_name))"
# Back to root directory
cd ..
# python -c "import prefect_infra; prefect_infra.create_github_credentials_block(${terraform output github_credentials})"