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 #190

Closed
hashibot opened this issue Jun 13, 2017 · 9 comments
Closed

aws_instance should allow to specify the instance state #190

hashibot opened this issue Jun 13, 2017 · 9 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@hashibot
Copy link

This issue was originally opened by @FlorinAndrei as hashicorp/terraform#7262. It was migrated here as part of the provider split. The original body of the issue is below.


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.

@hashibot hashibot added the enhancement Requests to existing resources that expand the functionality or scope. label Jun 13, 2017
@ThomasObenaus
Copy link

I would really appreciate to have this feature.

@radeksimko radeksimko added service/ec2 Issues and PRs that pertain to the ec2 service. and removed service/ec2 Issues and PRs that pertain to the ec2 service. labels Jan 25, 2018
@RoryKiefer
Copy link

+EleventyBillion

@jeromedoucet
Copy link

I will add another use case for this feature. I often use bastion instance in projects, and like other aws resources, this instance is managed by terraform. Most of the time, the bastion is stopped, and I would appreciate to be able to specify this behavior in terraform script.

@peimanja
Copy link

peimanja commented Jul 1, 2018

+1

@OfirYaron
Copy link

+1
I would love to get this feature.
if an instance is stopped and .tf implicitly state it should be running, action for running it should be taken

@queglay
Copy link

queglay commented Jan 13, 2019

+1 I would love to see this. I have teradici pcoip graphical instances that serve as backup gateways should my vpn not be working. They are expensive to forget about if left running, but super useful to have on standby.

@paulrowlands
Copy link

I would also like it, for if I stand up an instance to create an AMI from; you don't need (or want) it up after the AMI is created.

@paultyng
Copy link
Contributor

Merging this with #22 as this is a duplicate.

@ghost
Copy link

ghost commented Mar 31, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

10 participants