Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[terraform] add init options -reconfigure and -migrate-state #923

Merged
merged 5 commits into from
Jun 25, 2021

Conversation

wasfree
Copy link

@wasfree wasfree commented Jun 9, 2021

As mentioned in #839 it's may a good idea to have terraform init options -reconfigure and -migrate-state configurable.

This PR will add:

  • Additional terraform.options Reconfigure and MigrateState
  • MigrateState does also enable -force-copy to suppress the prompt for confirmation (similar to -auto-approve)
  • Tests for both options TestInitReconfigureBackend and TestInitBackendMigration
  • Options directly appended in InitE func due to the fact this options only used by terraform init and do not require any parameters which would require specific formatting

Reference to terraform documentation:
https://www.terraform.io/docs/cli/commands/init.html#backend-initialization

Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Code changes LGTM except for some tiny NITs. Once those are resolved, I can kick off tests.

modules/terraform/init_test.go Outdated Show resolved Hide resolved
@wasfree wasfree requested a review from brikis98 June 17, 2021 14:53
brikis98
brikis98 previously approved these changes Jun 18, 2021
Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! I'll kick off tests now.

@brikis98
Copy link
Member

Precommit check failed:

goimports................................................................Failed
- hook id: goimports
- files were modified by this hook

modules/terraform/init_test.go

Please run goimports!

@wasfree
Copy link
Author

wasfree commented Jun 19, 2021

Precommit check failed:

goimports................................................................Failed
- hook id: goimports
- files were modified by this hook

modules/terraform/init_test.go

Please run goimports!

Sorry, missed that step in contribution guidelines. Please run tests again.

@wasfree wasfree requested a review from brikis98 June 19, 2021 09:12
Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

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

LGTM, I'll kick off tests again!

@brikis98
Copy link
Member

Looks like there were some relevant test failures:

    init_test.go:109: 
        	Error Trace:	init_test.go:109
        	Error:      	An error is expected but got nil.
        	Test:       	TestInitReconfigureBackend
        	Messages:   	Backend initialization with changed configuration should fail without -reconfigure option

And:

    init_test.go:139: 
        	Error Trace:	init_test.go:139
        	Error:      	An error is expected but got nil.
        	Test:       	TestInitBackendMigration
        	Messages:   	Backend initialization with changed configuration should fail without -migrate-state option

@wasfree
Copy link
Author

wasfree commented Jun 21, 2021

Looks like there were some relevant test failures:

    init_test.go:109: 
        	Error Trace:	init_test.go:109
        	Error:      	An error is expected but got nil.
        	Test:       	TestInitReconfigureBackend
        	Messages:   	Backend initialization with changed configuration should fail without -reconfigure option

And:

    init_test.go:139: 
        	Error Trace:	init_test.go:139
        	Error:      	An error is expected but got nil.
        	Test:       	TestInitBackendMigration
        	Messages:   	Backend initialization with changed configuration should fail without -migrate-state option

This is related to terraform version used for the test, in version v0.15.0 backend re-initialization was accepted without -migrate-state or -reconfigure. In the meantime the version was updated to v0.15.5 with new behavior e4f4b36 . Rebase done, test should use now v0.15.5.

@bada09089
Copy link

Hey @yorinasub17, could you please also review this PR.

Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. We are doing a virtual company offsite this week, so it's been quite busy. Updates LGTM, I'll re-run the tests now.

@brikis98
Copy link
Member

There were some intermittent test failures, but I think they were unrelated to this PR, so I'm going to merge. Thanks!

@brikis98 brikis98 merged commit 22ada23 into gruntwork-io:master Jun 25, 2021
@brikis98
Copy link
Member

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.

Make possible to use Terraform init -reconfigure
3 participants