--- title: Create gcloud infrastructure description: A guide to creating gcloud infrastructure. --- Clone the `infctl` repo if you have not yet done so. We will work on the assumption that we are working in a home directory called `projects`. ```bash cd ~/projects if [ ! -d "infctl-cli" ]; then git clone https://codeberg.org/headshed/infctl-cli cd infctl-cli else cd infctl-cli fi ``` we need to configure some environment variables to let our build know some things about our project. ```bash cp .env.gcloud-example .env ``` edit our newly created `.env` file and give it values that are appropriate to our gcloud account, for example: ``` PROJECT_NAME="my-very-own-dev-lab" EMAIL="your.email@mailsomewhere.com" APP_DOMAIN_NAME="atestdr.yourdomain.com" ``` where each of these variables represent: * your project name, often called the project id in gcloud * your email that you wish to be identified with for DNS and TLS encryption * the domain name you want to use for this project when it is on line Activate these in the current shell with: ```bash source .env ``` Before we go any further, we need to confirm we have our gcloud environment ready and configured: ```bash gcloud compute instances list --project="$PROJECT_NAME" \ && gcloud compute disks list --project="$PROJECT_NAME" \ && gcloud compute firewall-rules list --project="$PROJECT_NAME" \ && gcloud storage buckets list --project="$PROJECT_NAME" ``` We should see pretty much an empty list but for default rules assigned for us by Google to our project to accept SSH, RDP and ICMP traffic - 4 lines in all. To build the infrastructure : ```bash LOGFORMAT=none infctl -f gcloud/tf/scripts/build-gcloud-k3s-pipeline.json ``` You should see a successful build ending with something like: ```bash Apply complete! Resources: 0 added, 0 changed, 0 destroyed. Outputs: k3s_vm_public_ip = "xxx.xxx.xxx.xxx" project_number = "..233434.." ✅ Step completed: run tofu ✅ 🚀 Pipeline completed successfully ``` Take a note of public IP address assigned to your VM as in `xxx.xxx.xxx.xxx` in the above example. You need to create an `A record` in your DNS console to point to this address, using the environment name you set for your app earlier ```bash echo $APP_DOMAIN_NAME ``` ### Setting an A Record in your chosen or Cloudflare DNS If you are using Cloudflare DNS, you can follow the below or use as a guide for your chosen DNS console... 1. Log in to your Cloudflare dashboard. 2. Select your domain. 3. Go to the **DNS** tab. 4. Click **Add record**. 5. Choose **A** as the record type. 6. Enter your subdomain (e.g., `atestdr`) in the **Name** field. 7. Enter your VM's public IP address in the **IPv4 address** field. 8. Set the record to be DNS only and a low TTL, for example 5 min. 9. Click **Save**. Your domain should now point to your VM's public IP.