Skip to main content
Stores the state as an object in a configurable prefix in a pre-existing bucket on Google Cloud Storage (GCS). The bucket must exist prior to configuring the backend. This backend supports state locking. Warning! It is highly recommended that you enable Object Versioning on the GCS bucket to allow for state recovery in the case of accidental deletions and human error. Read more about this backend in the Terraform docs: https://developer.hashicorp.com/terraform/language/settings/backends/gcs

Initializer

import cdktn

cdktn.GcsBackendConfig(
  bucket: str,
  access_token: str = None,
  credentials: str = None,
  encryption_key: str = None,
  impersonate_service_account: str = None,
  impersonate_service_account_delegates: typing.List[str] = None,
  kms_encryption_key: str = None,
  prefix: str = None,
  storeage_custom_endpoint: str = None
)

Properties

NameTypeDescription
bucketstr(Required) The name of the GCS bucket.
access_tokenstr(Optional) A temporary [OAuth 2.0 access token] obtained from the Google Authorization server, i.e. the Authorization: Bearer token used to authenticate HTTP requests to GCP APIs. This is an alternative to credentials. If both are specified, access_token will be used over the credentials field.
credentialsstr(Optional) Local path to Google Cloud Platform account credentials in JSON format.
encryption_keystr(Optional) A 32 byte base64 encoded ‘customer supplied encryption key’ used to encrypt all state.
impersonate_service_accountstr(Optional) The service account to impersonate for accessing the State Bucket.
impersonate_service_account_delegatestyping.List[str](Optional) The delegation chain for an impersonating a service account.
kms_encryption_keystr(Optional) A Cloud KMS key (‘customer-managed encryption key’) used when reading and writing state files in the bucket.
prefixstr(Optional) GCS prefix inside the bucket.
storeage_custom_endpointstr(Optional) A URL containing three parts: the protocol, the DNS name pointing to a Private Service Connect endpoint, and the path for the Cloud Storage API (/storage/v1/b).

bucketRequired

bucket: str
  • Type: str
(Required) The name of the GCS bucket. This name must be globally unique.

access_tokenOptional

access_token: str
  • Type: str
(Optional) A temporary [OAuth 2.0 access token] obtained from the Google Authorization server, i.e. the Authorization: Bearer token used to authenticate HTTP requests to GCP APIs. This is an alternative to credentials. If both are specified, access_token will be used over the credentials field.

credentialsOptional

credentials: str
  • Type: str
(Optional) Local path to Google Cloud Platform account credentials in JSON format. If unset, Google Application Default Credentials are used. The provided credentials must have Storage Object Admin role on the bucket. Warning: if using the Google Cloud Platform provider as well, it will also pick up the GOOGLE_CREDENTIALS environment variable.

encryption_keyOptional

encryption_key: str
  • Type: str
(Optional) A 32 byte base64 encoded ‘customer supplied encryption key’ used to encrypt all state.

impersonate_service_accountOptional

impersonate_service_account: str
  • Type: str
(Optional) The service account to impersonate for accessing the State Bucket. You must have roles/iam.serviceAccountTokenCreator role on that account for the impersonation to succeed. If you are using a delegation chain, you can specify that using the impersonate_service_account_delegates field. Alternatively, this can be specified using the GOOGLE_IMPERSONATE_SERVICE_ACCOUNT environment variable.

impersonate_service_account_delegatesOptional

impersonate_service_account_delegates: typing.List[str]
  • Type: typing.List[str]
(Optional) The delegation chain for an impersonating a service account.

kms_encryption_keyOptional

kms_encryption_key: str
  • Type: str
(Optional) A Cloud KMS key (‘customer-managed encryption key’) used when reading and writing state files in the bucket. Format should be projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}/cryptoKeys/{{name}}. For more information, including IAM requirements, see Customer-managed Encryption Keys.

prefixOptional

prefix: str
  • Type: str
(Optional) GCS prefix inside the bucket. Named states for workspaces are stored in an object called < prefix >/< name >.tfstate.

storeage_custom_endpointOptional

storeage_custom_endpoint: str
  • Type: str
(Optional) A URL containing three parts: the protocol, the DNS name pointing to a Private Service Connect endpoint, and the path for the Cloud Storage API (/storage/v1/b). See here for more details