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

aws_instance should allow to specify the instance state #7262

Closed
FlorinAndrei opened this issue Jun 21, 2016 · 6 comments
Closed

aws_instance should allow to specify the instance state #7262

FlorinAndrei opened this issue Jun 21, 2016 · 6 comments

Comments

@FlorinAndrei
Copy link

Terraform Version

Terraform v0.6.16

Affected Resource(s)

  • aws_instance

There seems to be no way to specify the instance state in a template. I would like to be able to do something like this:

resource "aws_instance" "web" {
    ami = "ami-408c7f28"
    instance_type = "t1.micro"
    state = "stopped"
#    state = "running"
    tags {
        Name = "HelloWorld"
    }
}

The default value for state should be "running".

Use case: Terraform is great for creating / destroying test or development environments quickly (semi-temporary environments). But sometimes creating an environment may include a long initial step, like importing a DB from backups. If that's the case, I don't want to create the environment every morning, wait for DB to be imported, and then destroy it in the evening.

Instead, I want to create the environment today, in the morning, and wait for the DB import once. Then, at the end of the day, turn off all instances and go home. That could be accomplished by specifying the state for all instances in a global variable, and changing that variable from "running" to "stopped", then run terraform apply.

Then the next morning I'll just change the state back to "running", run terraform apply and have the environment up and running very quickly. The initial DB import would not have to be performed again every day. This would save a lot of time in such cases.

@kamaltherocky
Copy link

+1 , we have a similar use case to shutdown instances when they are not used. currently we are doing it outside of terraform through SDK. it would be good if terraform can support it

@FlorinAndrei
Copy link
Author

Don't know if it makes a difference, but for my use case it's okay if state is not supported for instances being newly created. I've never had a case where an instance had to be created directly in the "stopped" state - I'm not even sure if the cloud API supports that, and I don't care TBH.

However, the state semantics become important for instances that are already created, and I just want to modify their state - flipping back and forth between running and stopped.

Hope that clarifies the use case I'm thinking about.

@eedwardsdisco
Copy link

@FlorinAndrei is correct that the underlying API does not support requesting an instance in a 'stopped' state. [RunInstances]

@Deserved
Copy link

+1 The over use cases can be:

  • I have instance that I want to use 1-2 times a month for high load operations
  • I have instances that I do not want to run (cost save), but I want to have them for a rollback plan.

@clstokes
Copy link
Contributor

Related to #1579.

@ghost
Copy link

ghost commented Apr 10, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants