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 state leaks on interrupt #18051

Closed
ialidzhikov opened this issue Mar 11, 2021 · 3 comments
Closed

Terraform state leaks on interrupt #18051

ialidzhikov opened this issue Mar 11, 2021 · 3 comments
Labels
provider Pertains to the provider itself, rather than any interaction with AWS. service/ec2 Issues and PRs that pertain to the ec2 service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.

Comments

@ialidzhikov
Copy link
Contributor

ialidzhikov commented Mar 11, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

$ terraform -version
Terraform v0.12.26
+ provider.aws v3.18.0

Affected Resource(s)

  • aws_vpc

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

provider "aws" {
  access_key = var.ACCESS_KEY_ID
  secret_key = var.SECRET_ACCESS_KEY
  region     = "eu-west-1"
  version    = "3.18.0"
}

resource "aws_vpc" "vpc" {
    cidr_block           = "10.250.0.0/16"
    enable_dns_support   = true
    enable_dns_hostnames = true

    tags = {
      Name = "deleteme"
    }
}

Debug Output

Panic Output

Expected Behavior

I would expect when I interrupt a running terraform apply process, no terraform state to be leaked.

Actual Behavior

When you interrupt a running terraform apply process, the resource is actually being created but not saved in the terraform state.

Steps to Reproduce

  1. Run terraform apply
$ terraform apply -var-file=creds.tfvars --auto-approve
  1. Interrupt with ^C as soon as you see that the VPC is being created.
$ terraform apply -var-file=creds.tfvars --auto-approve
aws_vpc.vpc: Creating...
^CInterrupt received.
Please wait for Terraform to exit or data loss may occur.
Gracefully shutting down...
Stopping operation...

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
  1. Checkout the cloudprovider and see that the requested VPC is created and it is not saved in the terraform state
$ aws ec2 describe-vpcs --output=json

        {
            "CidrBlock": "10.250.0.0/16",
            "DhcpOptionsId": "dopt-ab0f2ecc",
            "State": "available",
            "VpcId": "vpc-05866c95df657d7ac",
            "InstanceTenancy": "default",
            "CidrBlockAssociationSet": [
                {
                    "AssociationId": "vpc-cidr-assoc-0587023f907f7e62e",
                    "CidrBlock": "10.250.0.0/16",
                    "CidrBlockState": {
                        "State": "associated"
                    }
                }
            ],
            "IsDefault": false,
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "deleteme"
                }
            ]
        },

Important Factoids

References

  • #0000
@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label Mar 11, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 11, 2021
@ewbankkit
Copy link
Contributor

@ialidzhikov Thanks for raising this issue.
I think consistent behavior on cancellation requires #4177 and #15090.
Let's leave this one open for now as an explicit use case.

@ewbankkit ewbankkit added the provider Pertains to the provider itself, rather than any interaction with AWS. label Mar 11, 2021
@anGie44 anGie44 removed the needs-triage Waiting for first response or review from a maintainer. label Mar 12, 2021
@github-actions
Copy link

github-actions bot commented Mar 2, 2023

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Mar 2, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2023
@github-actions
Copy link

github-actions bot commented May 2, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
provider Pertains to the provider itself, rather than any interaction with AWS. service/ec2 Issues and PRs that pertain to the ec2 service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.
Projects
None yet
Development

No branches or pull requests

3 participants