Skip to content

Commit

Permalink
Google backends: gcs and firestore (#35) (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikhail Shirkov <[email protected]>
Co-authored-by: goruha <[email protected]>
  • Loading branch information
3 people authored Dec 3, 2024
1 parent 117aca4 commit 632bf29
Show file tree
Hide file tree
Showing 200 changed files with 243,814 additions and 95,206 deletions.
49 changes: 46 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,46 @@ Again set the `component`, `stack`, `planPath`, and `action` in the same manner
cosmosEndpoint: "https://my-cosmo-account.documents.azure.com:443/"
```

## Google Cloud

This action supports Google Cloud Platform (GCP). In GCP, we store Terraform plan files in Google Cloud Storage and metadata in Firestore.

To use the GCP implementation, specify `planRepositoryType` as `gcs` and `metadataRepositoryType` as `firestore`, then provide the following GCP-specific settings: `googleProjectId` to specify the project for both GCS bucket and Firestore, `bucketName` for GCS storage, and `googleFirestoreDatabaseName`/`googleFirestoreCollectionName` for Firestore metadata.

The `component`, `stack`, `planPath`, and `action` parameters work the same way as in AWS and Azure examples.

```yaml
- name: Store Plan
uses: cloudposse/github-action-terraform-plan-storage@v2
id: store-plan
with:
action: storePlan
planPath: my-plan.tfplan
component: mycomponent
stack: core-mycomponent-use1
planRepositoryType: gcs
metadataRepositoryType: firestore
bucketName: my-terraform-plans
gcpProjectId: my-gcp-project
gcpFirestoreDatabaseName: terraform-plan-metadata
gcpFirestoreCollectionName: terraform-plan-storage
- name: Get Plan
uses: cloudposse/github-action-terraform-plan-storage@v2
id: get-plan
with:
action: getPlan
planPath: my-plan.tfplan
component: mycomponent
stack: core-mycomponent-use1
planRepositoryType: gcs
metadataRepositoryType: firestore
bucketName: my-terraform-plans
gcpProjectId: my-gcp-project
gcpFirestoreDatabaseName: terraform-plan-metadata
gcpFirestoreCollectionName: terraform-plan-storage
```

> [!IMPORTANT]
> In Cloud Posse's examples, we avoid pinning modules to specific versions to prevent discrepancies between the documentation
> and the latest released versions. However, for your own projects, we strongly advise pinning each module to the exact version
Expand All @@ -152,17 +192,20 @@ Again set the `component`, `stack`, `planPath`, and `action` in the same manner
| action | which action to perform. Valid values are: 'storePlan', 'getPlan', 'taintPlan' | storePlan | true |
| blobAccountName | the name of the Azure Blob Storage account to store the plan file | N/A | false |
| blobContainerName | the name of the Azure Blob Storage container to store the plan file | N/A | false |
| bucketName | the name of the S3 bucket to store the plan file | terraform-plan-storage | false |
| bucketName | the name of the S3 or GCS bucket to store the plan file | terraform-plan-storage | false |
| commitSHA | Commit SHA to use for fetching plan | | false |
| component | the name of the component corresponding to the plan file | N/A | false |
| cosmosConnectionString | the connection string to the CosmosDB account to store the metadata | N/A | false |
| cosmosContainerName | the name of the CosmosDB container to store the metadata | N/A | false |
| cosmosDatabaseName | the name of the CosmosDB database to store the metadata | N/A | false |
| cosmosEndpoint | the endpoint of the CosmosDB account to store the metadata | N/A | false |
| failOnMissingPlan | Fail if plan is missing | true | false |
| metadataRepositoryType | the type of repository where the plan file is stored. Valid values are: 'dynamo', 'cosmodb' | dynamo | false |
| gcpFirestoreCollectionName | the name of the Firestore collection to store the metadata | terraform-plan-storage | false |
| gcpFirestoreDatabaseName | the name of the Firestore database to store the metadata | (default) | false |
| gcpProjectId | the Google Cloud project ID for GCP services (GCS, Firestore) | N/A | false |
| metadataRepositoryType | the type of repository where the plan file is stored. Valid values are: 'dynamo', 'cosmodb', 'firestore' | dynamo | false |
| planPath | path to the Terraform plan file. Required for 'storePlan' and 'getPlan' actions | N/A | false |
| planRepositoryType | the type of repository where the metadata is stored. Valid values are: 's3', 'azureblob' | s3 | false |
| planRepositoryType | the type of repository where the metadata is stored. Valid values are: 's3', 'azureblob', 'gcs' | s3 | false |
| stack | the name of the stack corresponding to the plan file | N/A | false |
| tableName | the name of the dynamodb table to store metadata | terraform-plan-storage | false |

Expand Down
40 changes: 40 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,46 @@ usage: |-
cosmosEndpoint: "https://my-cosmo-account.documents.azure.com:443/"
```
## Google Cloud
This action supports Google Cloud Platform (GCP). In GCP, we store Terraform plan files in Google Cloud Storage and metadata in Firestore.
To use the GCP implementation, specify `planRepositoryType` as `gcs` and `metadataRepositoryType` as `firestore`, then provide the following GCP-specific settings: `googleProjectId` to specify the project for both GCS bucket and Firestore, `bucketName` for GCS storage, and `googleFirestoreDatabaseName`/`googleFirestoreCollectionName` for Firestore metadata.
The `component`, `stack`, `planPath`, and `action` parameters work the same way as in AWS and Azure examples.
```yaml
- name: Store Plan
uses: cloudposse/github-action-terraform-plan-storage@v2
id: store-plan
with:
action: storePlan
planPath: my-plan.tfplan
component: mycomponent
stack: core-mycomponent-use1
planRepositoryType: gcs
metadataRepositoryType: firestore
bucketName: my-terraform-plans
gcpProjectId: my-gcp-project
gcpFirestoreDatabaseName: terraform-plan-metadata
gcpFirestoreCollectionName: terraform-plan-storage
- name: Get Plan
uses: cloudposse/github-action-terraform-plan-storage@v2
id: get-plan
with:
action: getPlan
planPath: my-plan.tfplan
component: mycomponent
stack: core-mycomponent-use1
planRepositoryType: gcs
metadataRepositoryType: firestore
bucketName: my-terraform-plans
gcpProjectId: my-gcp-project
gcpFirestoreDatabaseName: terraform-plan-metadata
gcpFirestoreCollectionName: terraform-plan-storage
```
# Other files to include in this README from the project folder
include:
- "docs/github-action.md"
Expand Down
17 changes: 14 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ inputs:
description: "the name of the Azure Blob Storage container to store the plan file"
required: false
bucketName:
description: "the name of the S3 bucket to store the plan file"
description: "the name of the S3 or GCS bucket to store the plan file"
required: false
default: "terraform-plan-storage"
commitSHA:
Expand All @@ -43,13 +43,13 @@ inputs:
required: false
default: "true"
metadataRepositoryType:
description: "the type of repository where the plan file is stored. Valid values are: 'dynamo', 'cosmodb'"
description: "the type of repository where the plan file is stored. Valid values are: 'dynamo', 'cosmodb', 'firestore'"
required: false
default: "dynamo"
planPath:
description: "path to the Terraform plan file. Required for 'storePlan' and 'getPlan' actions"
planRepositoryType:
description: "the type of repository where the metadata is stored. Valid values are: 's3', 'azureblob'"
description: "the type of repository where the metadata is stored. Valid values are: 's3', 'azureblob', 'gcs'"
required: false
default: "s3"
stack:
Expand All @@ -59,6 +59,17 @@ inputs:
description: "the name of the dynamodb table to store metadata"
required: false
default: "terraform-plan-storage"
gcpProjectId:
description: "the Google Cloud project ID for GCP services (GCS, Firestore)"
required: false
gcpFirestoreDatabaseName:
description: "the name of the Firestore database to store the metadata"
required: false
default: "(default)"
gcpFirestoreCollectionName:
description: "the name of the Firestore collection to store the metadata"
required: false
default: "terraform-plan-storage"

outputs: {}
runs:
Expand Down
Loading

0 comments on commit 632bf29

Please sign in to comment.