Skip to content

Commit 598fb24

Browse files
kwagdysinan
authored andcommitted
added guides till Elastic IP
1 parent 74432f8 commit 598fb24

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

  • docs/docs/create-elastic-ip-for-your-instance
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
layout: doc
3+
title: Assign Elastic IP
4+
permalink: /docs/create-elastic-ip-for-your-instance
5+
parent: /docs/home
6+
---
7+
8+
# {{ page.title }}
9+
10+
To attach an Elastic IP (_static IP_) to your instance, you will need to use the `aws_eip` header and make sure you define the instance it should be attached to using the instance **ID**.
11+
12+
### AWS EIP
13+
14+
Here is how the `aws_eip` section should be configured to associate it with your instance.
15+
16+
```yaml
17+
aws_eip:
18+
<name-your-eip-header>:
19+
instance: '${aws_instance._<your-instance-name>_.id}'
20+
vpc: false
21+
```
22+
23+
The `vpc` is an optional boolean value to indicate whether your instance is in a VPC or not
24+
25+
### Full Stack Example
26+
27+
Here is a stack that creates one VM and associates an Elastic IP to this particular VM. Notice that the VM name is the same name used in the `aws_eip` section to retireve the instance ID
28+
29+
```yaml
30+
# This stack creates a single instance
31+
# and associate an EIP to this instance
32+
33+
provider:
34+
aws:
35+
access_key: '${var.aws_access_key}'
36+
secret_key: '${var.aws_secret_key}'
37+
resource:
38+
aws_instance:
39+
my-server:
40+
instance_type: t2.nano
41+
aws_eip:
42+
my-server-eip:
43+
instance: '${aws_instance.my-server.id}'
44+
vpc: false
45+
```
46+
After your VM starts, you can retrieve the instance EIP using the below command (_use the exact command, please do not change the IP, this is an Amazon provided URL to retrieve your VM IP address_). Please note that the VM public IP will no longer be valid at this point, and you will need to use the EIP
47+
48+
curl http://169.254.169.254/latest/meta-data/public-ipv4 </instance-name>

0 commit comments

Comments
 (0)