-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: Create EIP association for EC2 #372
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,8 @@ module "ec2_complete" { | |
} | ||
] | ||
|
||
create_eip_public = true | ||
|
||
tags = local.tags | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -603,3 +603,26 @@ resource "aws_iam_instance_profile" "this" { | |||||
create_before_destroy = true | ||||||
} | ||||||
} | ||||||
|
||||||
################################################################################ | ||||||
# Elastic IP | ||||||
################################################################################ | ||||||
|
||||||
resource "aws_eip" "public" { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Why call it "public"? Can it be of another type? |
||||||
count = local.create && var.create_eip_public && !var.create_spot_instance ? 1 : 0 | ||||||
|
||||||
instance = try( | ||||||
aws_instance.this[0].id, | ||||||
aws_instance.ignore_ami[0].id, | ||||||
null, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
) | ||||||
|
||||||
domain = var.eip_public_domain | ||||||
|
||||||
tags = merge(var.tags, var.eip_public_tags) | ||||||
|
||||||
depends_on = [ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need in "depends_on" since it is already having references in "instance" argument. |
||||||
aws_instance.this, | ||||||
aws_instance.ignore_ami | ||||||
] | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,3 +229,22 @@ output "ephemeral_block_device" { | |
null | ||
) | ||
} | ||
|
||
################################################################################ | ||
# Elastic IP | ||
################################################################################ | ||
|
||
output "eip_public_id" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all of these variables and outputs should be stripped of |
||
description = "Contains the EIP allocation ID" | ||
value = try(aws_eip.public[0].id, null) | ||
} | ||
|
||
output "eip_public_dns" { | ||
description = "Public DNS associated with the Elastic IP address" | ||
value = try(aws_eip.public[0].public_dns, null) | ||
} | ||
|
||
output "eip_public_ip" { | ||
description = "Contains the public IP address" | ||
value = try(aws_eip.public[0].public_ip, null) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a way to "create EIP", "bring your own EIP" and use aws_eip_association to manage the relations.