jason-johnson / azure-pipelines-tasks-terraform

Azure Pipelines extension for Terraform
MIT License
127 stars 55 forks source link

add support for google cloud storage backend #241

Closed charleszipp closed 2 years ago

charleszipp commented 2 years ago

This adds support for using Google Cloud Storage as the terraform backend.

- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-cli.TerraformCLI@0
  displayName: 'terraform init'
  inputs:
    command: init
    workingDirectory: $(test_templates_dir)
    backendType: gcs
    # Google Credentials (i.e. for service account) in JSON file format in Azure DevOps Secure Files
    backendGcsCredentials: gcs-backend-key.json
    # GCS bucket name
    backendGcsBucket: gcs-trfrm-alpha-eus-czp
    # GCS Bucket path to state file
    backendGcsPrefix: 'azure-pipelines-terraform/infrax'

All gcs backend inputs are optional to allow for partial configuration (i.e. some config in task inputs and others from self configured env variables). This is in line with what was added as part of #15

Authentication is facilitated by a key file in json format being uploaded to Library > Secure Files. The task will download the file to the agent and use it to authenticate against the target GCS bucket.