-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathinstance-eip.tf
57 lines (39 loc) · 1.26 KB
/
instance-eip.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* this will create a aws instance and attach a EIP to it
read the steps at the end of the file, carefully
god bless you
You also need to export your AWS KEY and AWS SECRET for
successful execution
export AWS_ACCESS_KEY=<your key>
export AWS_SECRET_ACCESS_KEY=<your secret>
filename - instance-eip.tf
*/
provider "aws" {
region = "ap-south-1"
}
resource "aws_instance" "ourfirst" {
ami = "ami-0447a12f28fddb066"
instance_type = "t2.micro"
}
resource "aws_eip" "ourfirst" {
instance = "${aws_instance.ourfirst.id}"
}
/*
run
# terraform validate
# terraform plan
# terraform apply
You can also use - terraform show, to display created resources
and after checking the instance on aws dashboard
terraform destroy
Saving plan output. Terraform plan allows us to save output to a file
# terraform plan -out myplan-`date +'%s'`.plan
We can create different plan output for every new step added.
This will create a file with timestamp. This file can also be used to
apply.
# terraform apply myplan-date<somevalue>.plan
These plan outputs then become small steps we could apply
to our infrastructure, incrementally and carefully.
You can use the -target flag on both the terraform
plan and terraform apply commands.
#terraform plan -target aws_eip.ourfirst
*/