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

Update terragrunt support to use terragrunt run-all plan / apply / destroy #896 #910

Merged
merged 7 commits into from
May 31, 2021

Conversation

davidtam
Copy link
Contributor

@davidtam davidtam commented May 24, 2021

As described in #896 replacing deprecated terragrunt commands with run-all

brikis98
brikis98 previously approved these changes May 25, 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 for the fix! I'll kick off tests now.

@brikis98
Copy link
Member

OK, there were two test failures:

  • TestTerraformRedeployExample. I think this is a transient issue with syslog. Ignore for now, my guess is it'll pass on re-run.
  • TestTgApplyUseLockNoError. This looks related to this PR. Log output below. Could you look into it?
TestTgApplyUseLockNoError 2021-05-25T11:41:51Z logger.go:66: �[0mtest = "Hello, World"
=== CONT  TestTgApplyUseLockNoError
    apply_test.go:201: 
        	Error Trace:	apply_test.go:201
        	Error:      	"time=2021-05-25T11:41:46Z level=info msg=Stack at /tmp/TestTgApplyUseLockNoError789882540/terragrunt-no-error:
        	            	  => Module /tmp/TestTgApplyUseLockNoError789882540/terragrunt-no-error (excluded: false, dependencies: [])
        	            	
        	            	�[0m�[1mInitializing the backend...�[0m
        	            	
        	            	�[0m�[1mInitializing provider plugins...�[0m
        	            	
        	            	�[0m�[1m�[32mTerraform has been successfully initialized!�[0m�[32m�[0m
        	            	�[0m�[32m
        	            	You may now begin working with Terraform. Try running "terraform plan" to see
        	            	any changes that are required for your infrastructure. All Terraform commands
        	            	should now work.
        	            	
        	            	If you ever set or change modules or backend configuration for Terraform,
        	            	rerun this command to reinitialize your working directory. If you forget, other
        	            	commands will detect it and remind you to do so if necessary.�[0m
        	            	�[0m�[1m�[32m
        	            	Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
        	            	�[0m�[0m�[1m�[32m
        	            	Outputs:
        	            	
        	            	�[0mtest = "Hello, World"" does not contain "-lock=true"
        	Test:       	TestTgApplyUseLockNoError

@davidtam
Copy link
Contributor Author

davidtam commented May 25, 2021

Thanks @brikis98 I made some changes and added debug (see RunCommandAndGetOutputE) and I think -lock=true is passed down correctly but the output no longer contains that.

=== CONT  TestTgApplyUseLockNoError
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 retry.go:91: terragrunt [run-all apply -input=false -auto-approve -lock=true --terragrunt-non-interactive]
RunCommandAndGetOutputE {terragrunt [run-all apply -input=false -auto-approve -lock=true --terragrunt-non-interactive] /var/folders/ll/xp4ptlrd0cxcmpz0pbh41k3c0000gp/T/TestTgApplyUseLockNoError061216298/terragrunt-no-error map[] <nil>}
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: Running command terragrunt with args [run-all apply -input=false -auto-approve -lock=true --terragrunt-non-interactive]
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: time=2021-05-25T13:50:51+01:00 level=info msg=Stack at /private/var/folders/ll/xp4ptlrd0cxcmpz0pbh41k3c0000gp/T/TestTgApplyUseLockNoError061216298/terragrunt-no-error:
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66:   => Module /private/var/folders/ll/xp4ptlrd0cxcmpz0pbh41k3c0000gp/T/TestTgApplyUseLockNoError061216298/terragrunt-no-error (excluded: false, dependencies: [])
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: 
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: Initializing the backend...
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: 
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: Initializing provider plugins...
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: 
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: Terraform has been successfully initialized!
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: 
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: You may now begin working with Terraform. Try running "terraform plan" to see
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: any changes that are required for your infrastructure. All Terraform commands
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: should now work.
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: 
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: If you ever set or change modules or backend configuration for Terraform,
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: rerun this command to reinitialize your working directory. If you forget, other
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: commands will detect it and remind you to do so if necessary.
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: 
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: 
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: Outputs:
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: 
TestTgApplyUseLockNoError 2021-05-25T13:50:51+01:00 logger.go:66: test = "Hello, World"

It seems the message contains that previously because of the deprecated message:

output time=2021-05-25T14:08:33+01:00 level=warning msg='apply-all' is deprecated. Running 'terragrunt run-all apply -input=false -auto-approve -lock=true' instead. Please update your workflows to use 'terragrunt run-all apply -input=false -auto-approve -lock=true', as 'apply-all' may be removed in the future!

should that assertion be removed, or how we could assert -lock=true is passed down with run-all that has no deprecated message?

@davidtam
Copy link
Contributor Author

davidtam commented May 25, 2021

ok I further added TF_LOG=debug in the failing test do that -lock=true is present in output and hence could be asserted and the test passed locally. hope this is ok?

modules/terraform/format.go Outdated Show resolved Hide resolved
modules/terraform/apply_test.go Outdated Show resolved Hide resolved
brikis98
brikis98 previously approved these changes May 27, 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.

Great, thanks! I'll kick off tests now.

@brikis98
Copy link
Member

Pre-commit hook failed:

[INFO] Initializing environment for https://github.com/gruntwork-io/pre-commit.
goimports................................................................Failed
- hook id: goimports
- files were modified by this hook

modules/terraform/apply_test.go

Please run goimports!

@davidtam
Copy link
Contributor Author

I am really sorry - I have run goimports and push again...

@brikis98
Copy link
Member

No prob! I'll re-run tests now.

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.

Tests passed! Merging now.

@brikis98 brikis98 merged commit d1db009 into gruntwork-io:master May 31, 2021
@brikis98
Copy link
Member

@davidtam
Copy link
Contributor Author

great!! thank you!!

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.

Update terragrunt support to use terragrunt run-all plan / apply / destroy
2 participants