-
Notifications
You must be signed in to change notification settings - Fork 129
Description
Add support in elastic-package to use GOOGLE_APPLICATION_CREDENTIALS environment variable to be able to authenticate against GCP provider (documentation).
This variable is set in CI via this Buildkite plugin:
In order to be used by elastic-package in system tests, this variable must be added to:
- terraform container
- required to create the expected resources
volumes: - ${TF_DIR}:/stage - ${TF_OUTPUT_DIR}:/output - ${SERVICE_LOGS_DIR}:/tmp/service_logs/
- required to create the expected resources
- elastic-agent container
- elastic-agent must have access to the same files
elastic-package/internal/stack/_static/docker-compose-stack.yml.tmpl
Lines 138 to 162 in a1cc1b4
elastic-agent: image: "${ELASTIC_AGENT_IMAGE_REF}" depends_on: fleet-server: condition: service_healthy healthcheck: test: "elastic-agent status" timeout: 2s start_period: 360s retries: 180 interval: 5s hostname: docker-fleet-agent env_file: "./elastic-agent.env" cap_drop: - ALL ports: [{{ fact "agent_publish_ports" }}] volumes: - "../certs/ca-cert.pem:/etc/ssl/certs/elastic-package.pem" - type: bind source: ../../../tmp/service_logs/ target: /tmp/service_logs/ # Mount service_logs under /run too as a testing workaround for the journald input (see elastic-package#1235). - type: bind source: ../../../tmp/service_logs/ target: /run/service_logs/
- elastic-agent must have access to the same files
According to that Buildkite plugin, it should also be mounted TOKEN_FILE. This file path can be obtained via in the Buildkite pre-command hook: "${BUILDKITE_OIDC_TMPDIR}"/token.json
Requisites:
- Test all packages in integrations repository
- Test scenarios where those environment variables are not defined (e.g. our own laptops)
- It does not affect to the current authentication to upload files to the private bucket.
As context, previouslyelastic-package was testing a package using GCP resources via the GOOGLE_CREDENTIALS environment variable:
elastic-package/test/packages/parallel/gcp/data_stream/compute/_dev/deploy/tf/env.yml
Line 7 in 364fd63
- GOOGLE_CREDENTIALS=${GOOGLE_CREDENTIALS} elastic-package/test/packages/parallel/gcp/data_stream/compute/agent/stream/stream.yml.hbs
Line 8 in 364fd63
credentials_json: '{{credentials_json}}' Line 4 in 364fd63
credentials_json: '{{{GOOGLE_CREDENTIALS}}}' elastic-package/.buildkite/hooks/pre-command
Lines 98 to 102 in 364fd63
ELASTIC_PACKAGE_GCP_CREDENTIALS_SECRET=$(retry 5 vault read -field credentials ${GCP_SERVICE_ACCOUNT_SECRET_PATH} | jq -c) export ELASTIC_PACKAGE_GCP_CREDENTIALS_SECRET # Environment variables required by the service deployer export GOOGLE_CREDENTIALS=${ELASTIC_PACKAGE_GCP_CREDENTIALS_SECRET}
This package was removed in #1930
Relates