| || || || |
Our EC2 instances will each have a static public IPv4 address. This will allow us to SSH into the instances directly so we can provision them. Without public IP addresses we cannot route traffic from the public Internet to the instance nor from the instance to the public Internet.
In the future we'll replace these (E)IPs with a bastion host and perhaps a NAT Gateway.
Defining an EIP is very simple:
1 2 3 4
We use the
instance attribute to inform AWS what EC2 Instance we want thr EIP to be attached to.
Finally we use the
vpc attribute to create a VPC based EIP, because we're using a VPC.
And of course we create our second EIP:
1 2 3 4
1 2 3 4 5 6 7 8 9
| ||Terraform AWS Provider|
Committing the Code¶
- Set your working directory to the
- Save the file as
git add ec2_eip.tfto add it to the Git staging area
git commit -am 'creating a pair of ipv4 ips for our ec2 instances'to commit the file to our repository
- Push the code to GitLab.com: