Skip to content

Support to create resources in GCP setting GOOGLE_CREDENTIAL_APPLICATIONS (via oblt-google-auth-buildkite-plugin)#3167

Merged
mrodm merged 20 commits intoelastic:mainfrom
mrodm:support_oidc_gcp_credentials
Jan 16, 2026
Merged

Support to create resources in GCP setting GOOGLE_CREDENTIAL_APPLICATIONS (via oblt-google-auth-buildkite-plugin)#3167
mrodm merged 20 commits intoelastic:mainfrom
mrodm:support_oidc_gcp_credentials

Conversation

@mrodm
Copy link
Contributor

@mrodm mrodm commented Dec 18, 2025

Fixes #2606

Our CI environments are using this buildkite plugin to set the google credentials via OIDC: https://github.com/elastic/oblt-google-auth-buildkite-plugin

As this plugin sets the GOOGLE_CREDENTIAL_APPLICATION json file including a token file (credential_source.file), these files need to be mounted in both elastic-agent and terraform containers keeping the same paths.

Example of the contents of the JSON file pointed by the GOOGLE_APPLICATION_CREDENTIALS variable:

https://github.com/elastic/oblt-google-auth-buildkite-plugin/blob/1aa2833001484f4de7520aaa245943975e184a6c/hooks/environment#L37-L47

This PR ensures that these two files are mounted in both containers via volume mounts in the same paths as in the host as read only. User still needs to add the GOOGLE_APPLICATION_CREDENTIAL environment in the test deploy configuration.

Tested in elastic/integrations#16642 and https://buildkite.com/elastic/integrations/builds/36418

  • Terraform container is able to create and destroy the required resources.
  • Elastic Agent container is able to read the bucket created by the terraform container.

Considerations:

  • Add as default label ephemeral: true in the provider configuration.

mrodm added 5 commits January 12, 2026 12:38
Set the terraform docker-compose scenario as a template in order to be
able to set the volumes just when the environment variables are defined.
This will help when executing elastic-package in local scenarios.
@mrodm mrodm force-pushed the support_oidc_gcp_credentials branch from 28131f1 to eec47eb Compare January 12, 2026 11:39
@mrodm mrodm force-pushed the support_oidc_gcp_credentials branch from cb18fb3 to c10fd3f Compare January 13, 2026 18:51
@mrodm
Copy link
Contributor Author

mrodm commented Jan 14, 2026

/test

source: ${SERVICE_LOGS_DIR}
target: /run/service_logs/
read_only: false
{{ if ne $google_application_credentials "" }}
Copy link
Contributor Author

@mrodm mrodm Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GOOGLE_APPLICATION_CREDENTIALS for agent should be set via variables in data stream.
Example for panw_cortex_xdr package (it could depend on the variables defined in each data stream/package):

data_stream:
  vars:
    service_account_file: "{{GOOGLE_APPLICATION_CREDENTIALS}}"

{
"project_id": "my-gcp-project",
"private_key_id": "some_key_id",
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test file is to check reading an invalid JSON

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a template so it can be rendered different contents depending on the facters (presence of google application credentials files).

@mrodm mrodm changed the title WIP - Support to create resources in GCP setting GOOGLE_CREDENTIAL_APPLICATIONS (via oblt-google-auth-buildkite-plugin) Support to create resources in GCP setting GOOGLE_CREDENTIAL_APPLICATIONS (via oblt-google-auth-buildkite-plugin) Jan 14, 2026
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

@mrodm mrodm marked this pull request as ready for review January 15, 2026 11:45
@mrodm mrodm requested a review from a team January 15, 2026 11:45
Comment on lines +19 to +34
{{ if ne $google_application_credentials "" }}
# Mount Google Application Credentials file provided
# Required for authenticating when resources must be created/deleted in GCP
- type: bind
source: {{ $google_application_credentials }}
target: {{ $google_application_credentials }}
read_only: true
{{ end }}
{{ if ne $google_credential_source_file "" }}
# Mount Google credential source file (token file) provided
# Required for external accounts authentication when resources must be created/deleted in GCP
- type: bind
source: {{ $google_credential_source_file }}
target: {{ $google_credential_source_file }}
read_only: true
{{ end }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added new volume mounts to include (if present) the google application credentials and the credential source file.

This approach is for both Elastic Agent and Terraform containers.

@mrodm mrodm merged commit 358d904 into elastic:main Jan 16, 2026
3 checks passed
@mrodm mrodm deleted the support_oidc_gcp_credentials branch January 16, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support to authenticate to GCP via GOOGLE_APPLICATION_CREDENTIALS file

3 participants