diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 56d01f23b9fb726613d80c7c2bd6d95062fdf627..2919531164a74f6458866ac5a9bed5f8670498a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,6 +50,7 @@ check-magento: TF_VAR_ec_apikey: $EC_API_KEY TF_VAR_project_id: $GCP_PROJECT_ID TF_VAR_region: $GCP_REGION + TF_VAR_vpc_network_name: $GCP_NETWORK_NAME TF_VAR_vpc_subnetwork_name: $GCP_SUBNETWORK_NAME GCP_SA_GITLAB: $GCP_SA_GITLAB script: |- @@ -98,6 +99,7 @@ apply-magento: TF_VAR_ec_apikey: $EC_API_KEY TF_VAR_project_id: $GCP_PROJECT_ID TF_VAR_region: $GCP_REGION + TF_VAR_vpc_network_name: $GCP_NETWORK_NAME TF_VAR_vpc_subnetwork_name: $GCP_SUBNETWORK_NAME GCP_SA_GITLAB: $GCP_SA_GITLAB script: |- @@ -120,11 +122,28 @@ gcloud-psc: GCP_PROJECT_ID: $GCP_PROJECT_ID GCP_SA_GITLAB: $GCP_SA_GITLAB GCP_REGION: $GCP_REGION + GCP_NETWORK_NAME: $GCP_NETWORK_NAME GCP_SUBNETWORK_NAME: $GCP_SUBNETWORK_NAME + GCP_INTERNAL_IP_NAME: $GCP_INTERNAL_IP_NAME + GCP_PSC_NAME: $GCP_PSC_NAME + GCP_DNS_ZONE_MAGENTO_ELASTIC: $GCP_DNS_ZONE_MAGENTO_ELASTIC + ELASTIC_SERVICE_ATTACHMENT_URI: $ELASTIC_SERVICE_ATTACHMENT_URI + ELASTIC_DNS_ZONE: $ELASTIC_DNS_ZONE script: |- echo $GCP_SA_GITLAB > gcp-sa.json gcloud auth activate-service-account --key-file gcp-sa.json echo "Activate Service Account: OK" gcloud config set project $GCP_PROJECT_ID echo "Set Project: OK" - echo "Private IP Google Access is enabled on subnet: $(gcloud compute networks subnets describe $GCP_SUBNETWORK_NAME --region=$GCP_REGION --format="get(privateIpGoogleAccess)")" \ No newline at end of file + 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" \ No newline at end of file diff --git a/manifests/magento/variables.tf b/manifests/magento/variables.tf index 0215b1dedcb4c2149afd9c48b22eec7f76e91f4d..b9aff63704b46c9f7744bbea74362f1e41ab6490 100644 --- a/manifests/magento/variables.tf +++ b/manifests/magento/variables.tf @@ -8,8 +8,7 @@ variable "region" { ### Network & Subnetwork variable "vpc_network_name" { - type = string - default = "vpc-magento" + type = string } variable "vpc_subnetwork_name" { type = string