-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
provider/aws: EC2 instance - multiple private ips #6387
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 |
---|---|---|
|
@@ -14,12 +14,12 @@ and deleted. Instances also support [provisioning](/docs/provisioners/index.html | |
## Example Usage | ||
|
||
``` | ||
# Create a new instance of the `ami-408c7f28` (Ubuntu 14.04) on an | ||
# Create a new instance of the `ami-408c7f28` (Ubuntu 14.04) on an | ||
# t1.micro node with an AWS Tag naming it "HelloWorld" | ||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
resource "aws_instance" "web" { | ||
ami = "ami-408c7f28" | ||
instance_type = "t1.micro" | ||
|
@@ -41,9 +41,9 @@ The following arguments are supported: | |
EBS-optimized. | ||
* `disable_api_termination` - (Optional) If true, enables [EC2 Instance | ||
Termination Protection](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminating-instances.html#Using_ChangingDisableAPITermination) | ||
* `instance_initiated_shutdown_behavior` - (Optional) Shutdown behavior for the | ||
instance. Amazon defaults this to `stop` for EBS-backed instances and | ||
`terminate` for instance-store instances. Cannot be set on instance-store | ||
* `instance_initiated_shutdown_behavior` - (Optional) Shutdown behavior for the | ||
instance. Amazon defaults this to `stop` for EBS-backed instances and | ||
`terminate` for instance-store instances. Cannot be set on instance-store | ||
instances. See [Shutdown Behavior](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminating-instances.html#Using_ChangingInstanceInitiatedShutdownBehavior) for more information. | ||
* `instance_type` - (Required) The type of instance to start | ||
* `key_name` - (Optional) The key name to use for the instance. | ||
|
@@ -52,9 +52,11 @@ instances. See [Shutdown Behavior](https://docs.aws.amazon.com/AWSEC2/latest/Use | |
If you are within a non-default VPC, you'll need to use `vpc_security_group_ids` instead. | ||
* `vpc_security_group_ids` - (Optional) A list of security group IDs to associate with. | ||
* `subnet_id` - (Optional) The VPC Subnet ID to launch in. | ||
* `associate_public_ip_address` - (Optional) Associate a public ip address with an instance in a VPC. Boolean value. | ||
* `private_ip` - (Optional) Private IP address to associate with the | ||
instance in a VPC. | ||
* `associate_public_ip_address` - (Optional) Associate a public ip address with an instance in a VPC. Boolean value. | ||
* `private_ip` - (Optional, Deprecated) Private IP address to associate with the | ||
instance in a VPC. This | ||
attribute is deprecated, please use the `private_ips` attribute instead. | ||
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. I would omit any description for deprecated arguments - it should be mentioned in docs so people aren't confused why things still work, but we should make it more obvious that things just won't work in the near future. i.e.
|
||
* `private_ips` - (Optional) A list of private IP addresses to accociate with the instance's first network interface in a VPC. | ||
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.
|
||
* `source_dest_check` - (Optional) Controls if traffic is routed to the instance when | ||
the destination address does not match the instance. Used for NAT or VPNs. Defaults true. | ||
* `user_data` - (Optional) The user data to provide when launching the instance. | ||
|
@@ -136,13 +138,14 @@ The following attributes are exported: | |
* `availability_zone` - The availability zone of the instance. | ||
* `placement_group` - The placement group of the instance. | ||
* `key_name` - The key name of the instance | ||
* `public_dns` - The public DNS name assigned to the instance. For EC2-VPC, this | ||
* `public_dns` - The public DNS name assigned to the instance. For EC2-VPC, this | ||
is only available if you've enabled DNS hostnames for your VPC | ||
* `public_ip` - The public IP address assigned to the instance, if applicable. **NOTE**: If you are using an [`aws_eip`](/docs/providers/aws/r/eip.html) with your instance, you should refer to the EIP's address directly and not use `public_ip`, as this field will change after the EIP is attached. | ||
* `private_dns` - The private DNS name assigned to the instance. Can only be | ||
used inside the Amazon EC2, and only available if you've enabled DNS hostnames | ||
* `private_dns` - The private DNS name assigned to the instance. Can only be | ||
used inside the Amazon EC2, and only available if you've enabled DNS hostnames | ||
for your VPC | ||
* `private_ip` - The private IP address assigned to the instance | ||
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. I'd turn this line into:
|
||
* `private_ips` - A list of private IP addresses assigned to the instance's first network interface. | ||
* `security_groups` - The associated security groups. | ||
* `vpc_security_group_ids` - The associated security groups in non-default VPC | ||
* `subnet_id` - The VPC subnet ID. |
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.
I think we'll need to refactor the whole conditional block to keep handling EC2 Classic vs VPC correctly.
I'm still ok with deprecating
private_ip
in favour ofprivate_ips
, but we will need to add some checks for EC2 Classic &&len(private_ips) > 1
cases. I think we should error out as early as we can in such cases.See #7568 which may help in making decisions. We need to be prepared for scenarios where we don't have the list of supported platforms though - I'd suggest we 1st try assigning multiple IPs and error out with an informative error message (e.g.
("Assigning %d IPs failed: %s (hint: EC2 Classic accounts don't support multiple private IPs for EC2 instances)", len(ips), err)
).I'm aware that it may be difficult to test on EC2 Classic and many/most of us run VPC-only accounts, but we can at least stick to expectations described in AWS docs: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-vpc.html#differences-ec2-classic-vpc
I recommend carefully reading specifically the following two sections: