Giter Club home page Giter Club logo

tflock's People

Contributors

jaredledvina avatar minamijoyo avatar spkane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tflock's Issues

Lock should be fail if there is no lock setting.

Summary:

Lock should be fail if there is no lock setting.

Version:

tflock v0.0.1

Expected behavior:

lock fails

Actual behavior:

no error

Step to reproduce:

Given the following configuration

terraform {
  backend "s3" {
    region         = "ap-northeast-1"
    bucket         = "hoge"
    key            = "fuga/terraform.tfstate"
    // dynamodb_table = "tflock"
  }
}

Run tflock

$ tflock
$ echo $?
0

Check terraform plan

$ terraform plan
=> no error

Fails to lock with error 'Backend reinitialization required. Please run "terraform init".'

When I run tflock, I hit the following error:

> terraform init
...

> tflock
Backend reinitialization required. Please run "terraform init".
Reason: Backend configuration changed for "gcs"

The "backend" is the interface that Terraform uses to store state,
perform operations, etc. If this message is showing up, it means that the
Terraform configuration you're using is using a custom configuration for
the Terraform backend.

Changes to backend configurations require reinitialization. This allows
Terraform to set up the new configuration, copy existing state, etc. This is
only done during "terraform init". Please run that command now then try again.

If the change reason above is incorrect, please verify your configuration
hasn't changed and try again. At this point, no changes to your existing
configuration or state have been made.

Error loading the state: Initialization required. Please see the error message above.

Running terraform plan after the above error still works as well.

Environment info:
We're using the gcs backend with terraform 1.4.6 and used rev 528959cb04c76b71454220b5c9b39aa9ae7f26ba to build tflock.

Let me know if I can provide any more details or if I'm doing something obviously wrong.

tflock crashes in the latest 1.x versions of terraform

When i run tflock on terraform scripts i get the following segmentation fault error

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x101143eec]

goroutine 1 [running]:
github.com/hashicorp/terraform/command/views.(*StateLockerHuman).Locking(0x14000061450?)
	/Users/kishanb/go/pkg/mod/github.com/hashicorp/terraform@v0.15.1/command/views/state_locker.go:35 +0x1c
github.com/hashicorp/terraform/internal/helper/slowmessage.Do(0x102a5b890?, 0x140006f2a00, 0x1400099fcb8)
	/Users/kishanb/go/pkg/mod/github.com/hashicorp/terraform@v0.15.1/internal/helper/slowmessage/slowmessage.go:29 +0xec
github.com/hashicorp/terraform/command/clistate.(*locker).Lock(0x140000613b0, {0x12b7e0f58?, 0x1400094be00}, {0x1020bec6f, 0x6})
	/Users/kishanb/go/pkg/mod/github.com/hashicorp/terraform@v0.15.1/command/clistate/state.go:120 +0x248
main.(*LockCommand).Run(0x1400017c700, {0x0?, 0x103a31bc0?, 0x14000164a80?})
	/Users/kishanb/Programming/Personal/tflock/main.go:40 +0x188
github.com/mitchellh/cli.(*CLI).Run(0x140000c8c80)
	/Users/kishanb/go/pkg/mod/github.com/mitchellh/cli@v1.1.2/cli.go:262 +0x4a8
main.main()
	/Users/kishanb/Programming/Personal/tflock/main.go:116 +0x318

Terraform version

$ terraform version
Terraform v1.3.7
on darwin_arm64

Simulation

To simulate run the tflock command and run terraform plan command for this sample terraform file after creating the state bucket and dynamodb table

terraform {
  backend "s3" {
    bucket = "state-bucket-cc5b487c-a7d8-4751-b436-43f50994e962"
    key    = "path/file"
    region = "us-east-2"
    encrypt = true
    dynamodb_table = "terraform-state-lock-table"
  }
}

resource "aws_s3_bucket" "spike_data_bucket" {
  bucket = "spike-data-bucket-cc5b487c-a7d8-4751-b436-43f50994e962"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.