DEV Community

Discussion on: Configuring an isolated network in Google Cloud

nikhilakki profile image
Nikhil Akki

Great tutorial series, loving it so far... I have a question - What env value to set for AUTHORIZED_NETWORK?

chabane profile image
Chabane R. Author

Thanks for your feedback :+1

AUTHORIZED_NETWORK could be your local ip (curl -s
or the public IP of your private network

nikhilakki profile image
Nikhil Akki

Thanks for the quick response, this helped and I was able to run the scripts, however, with some modifications.

  1. sed -i "s,,$AUTHORIZED_NETWORK,g" terraform.tfvars gave an error - sed: 1: "terraform.tfvars": undefined label 'erraform.tfvars'. I modified it to sed "s//$AUTHORIZED_NETWORK/g" terraform.tfvars I haven't really used sed tool before (followed steps from this link). Eventually I gave up and replaced the value for AUTHORIZED_NETWORK to the IP I got from the url.
  2. All other definitions in *.tf files error-ed out due to missing definition/property - project. I created a variable project in with default value as "" and referenced it in each definition as project = var.project.
  3. Created an file for running these set of commands -
cd infra/plan

export AUTHORIZED_NETWORK=$(curl -s
export TF_VAR_project=$PROJECT_ID

echo 'TF_VAR_project =' $PROJECT_ID

# sed -i "s,<AUTHORIZED_NETWORK>,$AUTHORIZED_NETWORK,g" terraform.tfvars

terraform init \
    -backend-config="bucket=${TERRAFORM_BUCKET_NAME}" \

terraform apply
Enter fullscreen mode Exit fullscreen mode

It all worked at the end, but my approach seems a hacky one, let me know your thoughts.

Looking forward to reading the next posts in the series. 😃

Thread Thread
nikhilakki profile image
Nikhil Akki

Great series... thanks again for sharing it :-) I was able to setup and customise the scripts as per my requirements.