Skip to content
This repository was archived by the owner on Jul 20, 2024. It is now read-only.

Commit a95788a

Browse files
authored
Add var to handle eip outside of module (#24)
* Additional var wether to create an eip * update readme;
1 parent 9ce2167 commit a95788a

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ No requirements.
152152
| user\_data\_runcmd | Additional runcmd section of cloud-init | `list` | `[]` | no |
153153
| user\_data\_write\_files | Additional write\_files section of cloud-init | `list` | `[]` | no |
154154
| vpc\_id | ID of the VPC | `string` | n/a | yes |
155+
| eip_creation | Whether to create an eip | `bool` | `true` | no |
155156

156157
## Outputs
157158

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ resource "aws_network_interface" "this" {
3232
}
3333

3434
resource "aws_eip" "this" {
35-
count = var.enabled ? 1 : 0
35+
count = var.enabled ? var.eip_creation ? 1 : 0 : 0
3636
network_interface = aws_network_interface.this.id
3737
tags = local.common_tags
3838
}

outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
output "eip_id" {
22
description = "ID of the Elastic IP"
3-
value = var.enabled ? aws_eip.this[0].id : ""
3+
value = var.enabled ? var.eip_creation ? aws_eip.this[0].id : "" : ""
44
}
55

66
output "eip_public_ip" {
77
description = "Public IP of the Elastic IP for the NAT instance"
8-
value = var.enabled ? aws_eip.this[0].public_ip : ""
8+
value = var.enabled ? var.eip_creation ? aws_eip.this[0].public_ip : "" : ""
99
}
1010

1111
output "eni_id" {

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ variable "user_data_runcmd" {
7171
type = list
7272
default = []
7373
}
74+
variable "eip_creation" {
75+
description = "Whether to create an elastic ip"
76+
type = bool
77+
default = true
78+
}
7479

7580
locals {
7681
// Generate common tags by merging variables and default Name

0 commit comments

Comments
 (0)