Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit f69718a2 authored by Nicolas's avatar Nicolas
Browse files

Create Bash script for PSC

parent ac95b7fb
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ image: busybox:latest
variables:
TF_ROOT_ELASTIC: ${CI_PROJECT_DIR}/manifests/elastic
TF_ROOT_MAGENTO: ${CI_PROJECT_DIR}/manifests/magento
GCLOUD_ROOT_PSC: ${CI_PROJECT_DIR}/manifests/psc
cache:
- key: elastic
......@@ -135,15 +136,6 @@ gcloud-psc:
echo "Activate Service Account: OK"
gcloud config set project $GCP_PROJECT_ID
echo "Set Project: OK"
echo " "
echo "Private IP Google Access is enabled on subnet: $(gcloud compute networks subnets describe $GCP_SUBNETWORK_NAME --region=$GCP_REGION --format="get(privateIpGoogleAccess)")"
gcloud compute addresses create $GCP_INTERNAL_IP_NAME --region=$GCP_REGION --subnet=$GCP_SUBNETWORK_NAME
echo "Internal IP: $(gcloud compute addresses describe $GCP_INTERNAL_IP_NAME --region=$GCP_REGION --format="get(address)")"
echo " "
gcloud compute forwarding-rules create $GCP_PSC_NAME --region=$GCP_REGION --network=$GCP_NETWORK_NAME --address=$GCP_INTERNAL_IP_NAME --target-service-attachment=$ELASTIC_SERVICE_ATTACHMENT_URI
echo "Is connection accepted? $(gcloud compute forwarding-rules describe $GCP_PSC_NAME --region=$GCP_REGION --format="get(pscConnectionStatus)")"
echo " "
gcloud dns managed-zones create $GCP_DNS_ZONE_MAGENTO_ELASTIC --description="Managed by GitLab CI" --dns-name=$ELASTIC_DNS_ZONE. --visibility=private --networks=$GCP_NETWORK_NAME
gcloud dns record-sets transaction start --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC"
gcloud dns record-sets transaction add $(gcloud compute addresses describe $GCP_INTERNAL_IP_NAME --region=$GCP_REGION --format="get(address)") --name="*.$ELASTIC_DNS_ZONE." --ttl="30" --type="A" --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC"
gcloud dns record-sets transaction execute --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC"
cd $GCLOUD_ROOT_PSC
chmod +x ./setting-psc.sh
./setting-psc.sh
#!/bin/bash
PRIVATE_IP_ENABLED=$(gcloud compute networks subnets describe $GCP_SUBNETWORK_NAME --region=$GCP_REGION --format="get(privateIpGoogleAccess)")
if [[ $PRIVATE_IP_ENABLED == "True" ]]; then
echo 'PRIVATE_IP_ENABLED'
else
gcloud compute networks subnets update $GCP_SUBNETWORK_NAME --region=$GCP_REGION --enable-private-ip-google-access
fi
ADDRESS_CREATED=$(gcloud compute addresses describe $GCP_INTERNAL_IP_NAME --region=$GCP_REGION --format="get(status)")
if [[ $ADDRESS_CREATED == "IN_USE" ]]; then
echo 'ADDRESS_CREATED'
else
gcloud compute addresses create $GCP_INTERNAL_IP_NAME --region=$GCP_REGION --subnet=$GCP_SUBNETWORK_NAME
fi
FORWARDING_RULE_ACCEPTED=$(gcloud compute forwarding-rules describe $GCP_PSC_NAME --region=$GCP_REGION --format="get(pscConnectionStatus)")
if [[ $FORWARDING_RULE_ACCEPTED == "ACCEPTED" ]]; then
echo 'FORWARDING_RULE_ACCEPTED'
else
gcloud compute forwarding-rules create $GCP_PSC_NAME --region=$GCP_REGION --network=$GCP_NETWORK_NAME --address=$GCP_INTERNAL_IP_NAME --target-service-attachment=$ELASTIC_SERVICE_ATTACHMENT_URI
fi
#DNS_ZONE_CREATED=$(gcloud)
gcloud dns managed-zones create $GCP_DNS_ZONE_MAGENTO_ELASTIC --description="Managed by GitLab CI" --dns-name=$ELASTIC_DNS_ZONE. --visibility=private --networks=$GCP_NETWORK_NAME
gcloud dns record-sets transaction start --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC"
gcloud dns record-sets transaction add $(gcloud compute addresses describe $GCP_INTERNAL_IP_NAME --region=$GCP_REGION --format="get(address)") --name="*.$ELASTIC_DNS_ZONE." --ttl="30" --type="A" --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC"
gcloud dns record-sets transaction execute --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment