Created
August 28, 2025 19:00
-
-
Save epk/fe401f4dad7c4d6176a7d9684d0d7633 to your computer and use it in GitHub Desktop.
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
| export PROJECT=shopify-cloud-network | |
| export NAME=test-xrialb | |
| # Create self-signed certificate | |
| openssl req -x509 -newkey rsa:2048 -keyout $NAME-private.key -out $NAME-cert.pem -days 365 -nodes -subj "/CN=*.example.com" | |
| # Set the file variables | |
| export LB_PRIVATE_KEY=$NAME-private.key | |
| export LB_CERT=$NAME-cert.pem | |
| # Setup GCP Resources | |
| cat > $NAME-url-map.yaml <<EOF | |
| defaultUrlRedirect: | |
| hostRedirect: www.shopify.com | |
| pathRedirect: /404 | |
| redirectResponseCode: SEE_OTHER | |
| stripQuery: true | |
| name: $NAME-url-map | |
| EOF | |
| # Import URL Map from config | |
| gcloud compute url-maps import $NAME-url-map \ | |
| --project=$PROJECT \ | |
| --global \ | |
| --source=$NAME-url-map.yaml | |
| # Create Certificate | |
| gcloud certificate-manager certificates create $NAME-certificate \ | |
| --project=$PROJECT \ | |
| --private-key-file=$LB_PRIVATE_KEY \ | |
| --certificate-file=$LB_CERT \ | |
| --scope=all-regions | |
| # Create Target HTTPS Proxy | |
| gcloud compute target-https-proxies create $NAME-https-proxy \ | |
| --project=$PROJECT \ | |
| --certificate-manager-certificates=$NAME-certificate \ | |
| --url-map=https://www.googleapis.com/compute/v1/projects/$PROJECT/global/urlMaps/$NAME-url-map \ | |
| --global | |
| # Cleanup | |
| rm $LB_PRIVATE_KEY $LB_CERT | |
| rm $NAME-url-map.yaml | |
| gcloud compute target-https-proxies delete $NAME-https-proxy --project=$PROJECT | |
| gcloud compute url-maps delete $NAME-url-map --project=$PROJECT --global | |
| gcloud certificate-manager certificates delete $NAME-certificate --project=$PROJECT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment