-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathupdate-ssl-cert.sh
18 lines (15 loc) · 1.12 KB
/
update-ssl-cert.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# If you have enabled HTTPS and want to update the SSL certificate, this script will help make it easier to do the swap.
# Update these values for your use!
region="us-west4"
cert_name="my-cert"
tmp_cert_name="my-tmp-cert"
private_key_file="terraform/certs/self-signed.key"
certificate_file="terraform/certs/self-signed.crt"
# Create a temporary ssl-certificate
gcloud compute ssl-certificates create $tmp_cert_name --certificate $certificate_file --private-key $private_key_file --region $region
gcloud compute target-https-proxies update l7-xlb-proxy-https --ssl-certificates $tmp_cert_name --region $region
gcloud compute ssl-certificates delete $cert_name --region $region --quiet
# Update again to change the ssl-certificate name back to the original name, so there is not an error when running `terraform destroy``
gcloud compute ssl-certificates create $cert_name --certificate $certificate_file --private-key $private_key_file --region $region
gcloud compute target-https-proxies update l7-xlb-proxy-https --ssl-certificates $cert_name --region $region
gcloud compute ssl-certificates delete $tmp_cert_name --region $region --quiet