minamijoyo / tfmigrate

A Terraform / OpenTofu state migration tool for GitOps
MIT License
1.14k stars 57 forks source link

Support GCS as a history storage #103

Closed KengoTODA closed 2 years ago

KengoTODA commented 2 years ago

Just like #23, this PR adds a support for GCS history backend. But it provides less configurations than #23, refer to https://github.com/minamijoyo/tfmigrate-storage/pull/3 for detail.

minamijoyo commented 2 years ago

Hi @KengoTODA, Thank you for working on this!

I tried to test this branch with docker-compose, but failed to initialize the test fixture for storage_gcs.

$ docker-compose build
$ docker-compose run --rm tfmigrate /bin/bash

bash-5.1# mkdir -p tmp/dir1 && cd tmp/dir1
bash-5.1# terraform init -from-module=../../test-fixtures/storage_gcs
Copying configuration from "../../test-fixtures/storage_gcs"...

Initializing the backend...
╷
│ Error: Failed to get existing workspaces: querying Cloud Storage failed: googleapi: Error 401: Anonymous caller does not have storage.objects.list access to the Google Cloud Storage bucket., required
│
│
╵

bash-5.1# terraform -v
Terraform v1.2.8
on linux_amd64
bash-5.1# echo $STORAGE_EMULATOR_HOST
http://fake-gcs-server:4443

I guess the error looks related to an issue mentioned in https://github.com/minamijoyo/tfmigrate/pull/23#issuecomment-902352674 by @w1mvy 🤔

@KengoTODA Was it successful on this branch in your environment?

KengoTODA commented 2 years ago

Thanks for your review!
It's my mistake, I've added necessary code to run the terraform and tfmigrate in the container. Sorry for making you got confused!

minamijoyo commented 2 years ago

It works now. It's a bit tricky but acceptable to use s3 backend as Terraform state backend for testing gcs storage as tfmigrate history 👍

KengoTODA commented 2 years ago

Thank you!

minamijoyo commented 2 years ago

@KengoTODA I've just released it in v0.3.7 🚀 Thank you for your contribution!