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

Add Traffic filter in Elastic

parent e2f4c7bf
No related branches found
No related tags found
No related merge requests found
...@@ -15,30 +15,6 @@ cache: ...@@ -15,30 +15,6 @@ cache:
paths: paths:
- ${TF_ROOT_MAGENTO}/.terraform - ${TF_ROOT_MAGENTO}/.terraform
check-elastic:
stage: test
tags:
- docker
image:
name: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
entrypoint: [""]
variables:
TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/elastic
TF_VAR_ec_apikey: $EC_API_KEY
script: |-
cd $TF_ROOT_ELASTIC
gitlab-terraform init
gitlab-terraform validate
gitlab-terraform fmt -check
gitlab-terraform plan
gitlab-terraform plan-json
artifacts:
name: plan
paths:
- ${TF_ROOT_ELASTIC}/plan.cache
reports:
terraform: ${TF_ROOT_ELASTIC}/plan.json
check-magento: check-magento:
stage: test stage: test
tags: tags:
...@@ -69,23 +45,6 @@ check-magento: ...@@ -69,23 +45,6 @@ check-magento:
reports: reports:
terraform: ${TF_ROOT_MAGENTO}/plan.json terraform: ${TF_ROOT_MAGENTO}/plan.json
apply-elastic:
stage: deploy
needs:
- check-elastic
tags:
- docker
image:
name: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
entrypoint: [""]
variables:
TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/elastic
TF_VAR_ec_apikey: $EC_API_KEY
script: |-
cd $TF_ROOT_ELASTIC
gitlab-terraform init
gitlab-terraform apply -auto-approve
apply-magento: apply-magento:
stage: deploy stage: deploy
needs: needs:
...@@ -112,7 +71,6 @@ apply-magento: ...@@ -112,7 +71,6 @@ apply-magento:
gcloud-psc: gcloud-psc:
stage: deploy stage: deploy
needs: needs:
- apply-elastic
- apply-magento - apply-magento
tags: tags:
- docker - docker
...@@ -143,12 +101,47 @@ gcloud-psc: ...@@ -143,12 +101,47 @@ gcloud-psc:
paths: paths:
- ${CI_PROJECT_DIR}/pscConnectionId.env - ${CI_PROJECT_DIR}/pscConnectionId.env
check-elastic:
stage: test
tags:
- docker
needs:
- gcloud-psc
image:
name: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
entrypoint: [""]
variables:
TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/elastic
TF_VAR_ec_apikey: $EC_API_KEY
script: |-
export TF_VAR_psc_connection_id=$(cat ${CI_PROJECT_DIR}/pscConnectionId.env | grep GCP_PSC_CONNECTION_ID | cut -d = -f2)
cd $TF_ROOT_ELASTIC
gitlab-terraform init
gitlab-terraform validate
gitlab-terraform fmt -check
gitlab-terraform plan
gitlab-terraform plan-json
artifacts:
name: plan
paths:
- ${TF_ROOT_ELASTIC}/plan.cache
reports:
terraform: ${TF_ROOT_ELASTIC}/plan.json
elastic-traffic-filter: apply-elastic:
stage: deploy stage: deploy
needs: needs:
- gcloud-psc - check-elastic
tags: tags:
- docker - docker
image:
name: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
entrypoint: [""]
variables:
TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/elastic
TF_VAR_ec_apikey: $EC_API_KEY
script: |- script: |-
cat ${CI_PROJECT_DIR}/pscConnectionId.env export TF_VAR_psc_connection_id=$(cat ${CI_PROJECT_DIR}/pscConnectionId.env | grep GCP_PSC_CONNECTION_ID | cut -d = -f2)
cd $TF_ROOT_ELASTIC
gitlab-terraform init
gitlab-terraform apply -auto-approve
...@@ -19,6 +19,16 @@ data "ec_stack" "stack" { ...@@ -19,6 +19,16 @@ data "ec_stack" "stack" {
region = var.region region = var.region
} }
resource "ec_deployment_traffic_filter" "traffic-filter" {
name = "traffic-filter"
region = var.region
type = "gcp_private_service_connect_endpoint"
rule {
source = var.psc_connection_id
}
}
resource "ec_deployment" "elasticsearch_cluster" { resource "ec_deployment" "elasticsearch_cluster" {
name = var.cluster_name name = var.cluster_name
region = data.ec_stack.stack.region region = data.ec_stack.stack.region
...@@ -43,4 +53,8 @@ resource "ec_deployment" "elasticsearch_cluster" { ...@@ -43,4 +53,8 @@ resource "ec_deployment" "elasticsearch_cluster" {
zone_count = 1 zone_count = 1
} }
} }
traffic_filter = [
ec_deployment_traffic_filter.traffic-filter.id
]
} }
...@@ -7,8 +7,12 @@ variable "region" { ...@@ -7,8 +7,12 @@ variable "region" {
default = "gcp-europe-west1" default = "gcp-europe-west1"
} }
variable "psc_connection_id" {
type = string
}
### Cluster ### Cluster
variable "cluster_name" { variable "cluster_name" {
type = string type = string
default = "elastic-for-gke-magento" default = "elastic-for-gke-magento"
} }
\ No newline at end of file
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