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 3411b7a5 authored by Nicolas's avatar Nicolas
Browse files

Create PSC

parent b9e57767
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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
......
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