ine-labs / GCPGoat

GCPGoat : A Damn Vulnerable GCP Infrastructure
MIT License
349 stars 71 forks source link

Error running command sed -i #7

Closed sergargar closed 1 year ago

sergargar commented 1 year ago
Screenshot 2023-04-05 at 16 38 31
za commented 1 year ago

@sergargar Did you run $ terraform apply when getting this ERROR?

sergargar commented 1 year ago

@sergargar Did you run $ terraform apply when getting this ERROR?

Yes

za commented 1 year ago

Have you run $ terraform init? @sergargar

sergargar commented 1 year ago

Have you run $ terraform init? @sergargar

Yes

za commented 1 year ago

@sergargar can you paste the ERROR log (instead of screenshot)?

za commented 1 year ago

Hi @sergargar This command:

$ sed -i 's/"\/static/"https:\/\/storage\.googleapis\.com\/${google_storage_bucket.data_bucket.name}\/webfiles\/build\/static/g' modules/module-1/resources/storage_bucket/webfiles/build/static/js/main.adc6b28e.js

is replacing /static/ in main.adc6b28e.js file. Maybe you can try to run the command above first.

sergargar commented 1 year ago

I could execute the previous command without errors, but when doing the terraform apply, I'm still getting the following error:

│ Error: local-exec provisioner error │ │ with null_resource.file_replacement_upload, │ on main.tf line 620, in resource "null_resource" "file_replacement_upload": │ 620: provisioner "local-exec" { │ │ Error running command 'sed -i │ 's/"\/static/"https:\/\/storage.googleapis.com\/prod-blogapp-1acffa4f9e7361c6\/webfiles\/build\/static/g' │ modules/module-1/resources/storage_bucket/webfiles/build/static/js/main.adc6b28e.js │ sed -i │ 's/n.p+"static/"https:\/\/storage.googleapis.com\/prod-blogapp-1acffa4f9e7361c6\/webfiles\/build\/static/g' │ modules/module-1/resources/storage_bucket/webfiles/build/static/js/main.adc6b28e.js │ sed -i │ 'sCLOUD_FUNCTION_URLhttps://us-west1-gcp-goat-1acffa4f9e7361c6.cloudfunctions.net/backend-function`' │ modules/module-1/resources/storage_bucket/webfiles/build/static/js/main.adc6b28e.js │ ': exit status 1. Output: sed: 1: "modules/module-1/resour ...": invalid command code m │ sed: 1: "modules/module-1/resour ...": invalid command code m │ sed: 1: "modules/module-1/resour ...": invalid command code m

za commented 1 year ago

Which terraform version are you using?

sergargar commented 1 year ago

Which terraform version are you using?

+ terraform --version
Terraform v1.4.4
on darwin_arm64
+ provider registry.terraform.io/hashicorp/archive v2.3.0
+ provider registry.terraform.io/hashicorp/google v4.61.0
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hashicorp/random v3.5.0
+ provider registry.terraform.io/hashicorp/template v2.2.0
za commented 1 year ago

Hmm... this could be issue with sed on Mac @sergargar

This is my terraform version

➜  ~ terraform --version
Terraform v1.4.4
on linux_amd64

The installation steps says it requires Linux machine https://github.com/ine-labs/GCPGoat/blob/main/README.md#installation

sergargar commented 1 year ago

I will try it in a Linux machine then, thank you.