@@ -87,8 +87,7 @@ data "aws_ami" "ubuntu-xenial" {
...
@@ -87,8 +87,7 @@ data "aws_ami" "ubuntu-xenial" {
## Notes
## Notes
*`network_interface` can't be specified together with `associate_public_ip_address`, which makes `network_interface`
*`network_interface` can't be specified together with `vpc_security_group_ids`, `associate_public_ip_address`, `subnet_id`. See [basic example](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/basic) for details.
not configurable using this module at the moment
* Changes in `ebs_block_device` argument will be ignored. Use [aws_volume_attachment](https://www.terraform.io/docs/providers/aws/r/volume_attachment.html) resource to attach and detach volumes from AWS EC2 instances. See [this example](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/volume-attachment).
* Changes in `ebs_block_device` argument will be ignored. Use [aws_volume_attachment](https://www.terraform.io/docs/providers/aws/r/volume_attachment.html) resource to attach and detach volumes from AWS EC2 instances. See [this example](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/volume-attachment).
* One of `subnet_id` or `subnet_ids` is required. If both are provided, the value of `subnet_id` is prepended to the value of `subnet_ids`.
* One of `subnet_id` or `subnet_ids` is required. If both are provided, the value of `subnet_id` is prepended to the value of `subnet_ids`.
...
@@ -98,7 +97,7 @@ data "aws_ami" "ubuntu-xenial" {
...
@@ -98,7 +97,7 @@ data "aws_ami" "ubuntu-xenial" {
| Name | Description | Type | Default | Required |
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
|------|-------------|:----:|:-----:|:-----:|
| ami | ID of AMI to use for the instance | string | n/a | yes |
| ami | ID of AMI to use for the instance | string | n/a | yes |
| associate\_public\_ip\_address | If true, the EC2 instance will have associated public IP address | bool | `"false"` | no |
| associate\_public\_ip\_address | If true, the EC2 instance will have associated public IP address | bool | `"null"` | no |
| cpu\_credits | The credit option for CPU usage (unlimited or standard) | string | `"standard"` | no |
| cpu\_credits | The credit option for CPU usage (unlimited or standard) | string | `"standard"` | no |
| disable\_api\_termination | If true, enables EC2 Instance Termination Protection | bool | `"false"` | no |
| disable\_api\_termination | If true, enables EC2 Instance Termination Protection | bool | `"false"` | no |
| ebs\_block\_device | Additional EBS block devices to attach to the instance | list(map(string)) | `[]` | no |
| ebs\_block\_device | Additional EBS block devices to attach to the instance | list(map(string)) | `[]` | no |
...
@@ -109,14 +108,14 @@ data "aws_ami" "ubuntu-xenial" {
...
@@ -109,14 +108,14 @@ data "aws_ami" "ubuntu-xenial" {
| instance\_count | Number of instances to launch | number | `"1"` | no |
| instance\_count | Number of instances to launch | number | `"1"` | no |
| instance\_initiated\_shutdown\_behavior | Shutdown behavior for the instance | string | `""` | no |
| instance\_initiated\_shutdown\_behavior | Shutdown behavior for the instance | string | `""` | no |
| instance\_type | The type of instance to start | string | n/a | yes |
| instance\_type | The type of instance to start | string | n/a | yes |
| ipv6\_address\_count | A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet. | number | `"0"` | no |
| ipv6\_address\_count | A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet. | number | `"null"` | no |
| ipv6\_addresses | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | list(string) | `[]` | no |
| ipv6\_addresses | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | list(string) | `"null"` | no |
| key\_name | The key name to use for the instance | string | `""` | no |
| key\_name | The key name to use for the instance | string | `""` | no |
| monitoring | If true, the launched EC2 instance will have detailed monitoring enabled | bool | `"false"` | no |
| monitoring | If true, the launched EC2 instance will have detailed monitoring enabled | bool | `"false"` | no |
| name | Name to be used on all resources as prefix | string | n/a | yes |
| name | Name to be used on all resources as prefix | string | n/a | yes |
| network\_interface | Customize network interfaces to be attached at instance boot time | list(map(string)) | `[]` | no |
| network\_interface | Customize network interfaces to be attached at instance boot time | list(map(string)) | `[]` | no |
| placement\_group | The Placement Group to start the instance in | string | `""` | no |
| placement\_group | The Placement Group to start the instance in | string | `""` | no |
| private\_ip | Private IP address to associate with the instance in a VPC | string | `""` | no |
| private\_ip | Private IP address to associate with the instance in a VPC | string | `"null"` | no |
| private\_ips | A list of private IP address to associate with the instance in a VPC. Should match the number of instances. | list(string) | `[]` | no |
| private\_ips | A list of private IP address to associate with the instance in a VPC. Should match the number of instances. | list(string) | `[]` | no |
| root\_block\_device | Customize details about the root block device of the instance. See Block Devices below for details | list(map(string)) | `[]` | no |
| root\_block\_device | Customize details about the root block device of the instance. See Block Devices below for details | list(map(string)) | `[]` | no |
| source\_dest\_check | Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. | bool | `"true"` | no |
| source\_dest\_check | Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. | bool | `"true"` | no |
...
@@ -127,15 +126,19 @@ data "aws_ami" "ubuntu-xenial" {
...
@@ -127,15 +126,19 @@ data "aws_ami" "ubuntu-xenial" {
| use\_num\_suffix | Always append numerical suffix to instance name, even if instance_count is 1 | bool | `"false"` | no |
| use\_num\_suffix | Always append numerical suffix to instance name, even if instance_count is 1 | bool | `"false"` | no |
| user\_data | The user data to provide when launching the instance | string | `""` | no |
| user\_data | The user data to provide when launching the instance | string | `""` | no |
| volume\_tags | A mapping of tags to assign to the devices created by the instance at launch time | map(string) | `{}` | no |
| volume\_tags | A mapping of tags to assign to the devices created by the instance at launch time | map(string) | `{}` | no |
| vpc\_security\_group\_ids | A list of security group IDs to associate with | list(string) | n/a | yes |
| vpc\_security\_group\_ids | A list of security group IDs to associate with | list(string) | `"null"` | no |
## Outputs
## Outputs
| Name | Description |
| Name | Description |
|------|-------------|
|------|-------------|
| arn | List of ARNs of instances |
| availability\_zone | List of availability zones of instances |
| availability\_zone | List of availability zones of instances |
| credit\_specification | List of credit specification of instances |
| credit\_specification | List of credit specification of instances |
| ebs\_block\_device\_volume\_ids | List of volume IDs of EBS block devices of instances |
| id | List of IDs of instances |
| id | List of IDs of instances |
| instance\_state | List of instance states of instances |
| ipv6\_addresses | List of assigned IPv6 addresses of instances |
| key\_name | List of key names of instances |
| key\_name | List of key names of instances |
| password\_data | List of Base-64 encoded encrypted password data for the instance |
| password\_data | List of Base-64 encoded encrypted password data for the instance |
| placement\_group | List of placement groups of instances |
| placement\_group | List of placement groups of instances |
...
@@ -144,6 +147,7 @@ data "aws_ami" "ubuntu-xenial" {
...
@@ -144,6 +147,7 @@ data "aws_ami" "ubuntu-xenial" {
| private\_ip | List of private IP addresses assigned to the instances |
| private\_ip | List of private IP addresses assigned to the instances |
| public\_dns | List of public DNS names assigned to the instances. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC |
| public\_dns | List of public DNS names assigned to the instances. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC |
| public\_ip | List of public IP addresses assigned to the instances, if applicable |
| public\_ip | List of public IP addresses assigned to the instances, if applicable |
| root\_block\_device\_volume\_ids | List of volume IDs of root block devices of instances |
| security\_groups | List of associated security groups of instances |
| security\_groups | List of associated security groups of instances |
| subnet\_id | List of IDs of VPC subnets of instances |
| subnet\_id | List of IDs of VPC subnets of instances |
Configuration in this directory creates EC2 instances with minimum set of arguments. It will also assign Elastic IP (EIP) to an instance.
Configuration in this directory creates EC2 instances with different sets of arguments (with Elastic IP, with network interface attached, with credit specifications).
Unspecified arguments for security group id and subnet are inherited from the default VPC.
This example outputs instance id and public DNS name as a single value and as a list.
## Usage
## Usage
...
@@ -25,12 +21,14 @@ Note that this example may create resources which can cost money. Run `terraform
...
@@ -25,12 +21,14 @@ Note that this example may create resources which can cost money. Run `terraform
|------|-------------|
|------|-------------|
| credit\_specification | Credit specification of EC2 instance (empty list for not t2 instance types) |
| credit\_specification | Credit specification of EC2 instance (empty list for not t2 instance types) |
| credit\_specification\_t2\_unlimited | Credit specification of t2-type EC2 instance |
| credit\_specification\_t2\_unlimited | Credit specification of t2-type EC2 instance |
| ebs\_block\_device\_volume\_ids | List of volume IDs of EBS block devices of instances |
| ids | List of IDs of instances |
| ids | List of IDs of instances |
| ids\_t2 | List of IDs of t2-type instances |
| ids\_t2 | List of IDs of t2-type instances |
| instance\_id | EC2 instance ID |
| instance\_id | EC2 instance ID |
| instance\_public\_dns | Public DNS name assigned to the EC2 instance |
| instance\_public\_dns | Public DNS name assigned to the EC2 instance |
| placement\_group | List of placement group |
| placement\_group | List of placement group |
| public\_dns | List of public DNS names assigned to the instances |
| public\_dns | List of public DNS names assigned to the instances |
| root\_block\_device\_volume\_ids | List of volume IDs of root block devices of instances |
| t2\_instance\_id | EC2 instance ID |
| t2\_instance\_id | EC2 instance ID |
| tags | List of tags |
| tags | List of tags |
| vpc\_security\_group\_ids | List of VPC security group ids assigned to the instances |
| vpc\_security\_group\_ids | List of VPC security group ids assigned to the instances |
description="A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet."
description="A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet."
type=number
type=number
default=0
default=null
}
}
variable"ipv6_addresses"{
variable"ipv6_addresses"{
description="Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface"
description="Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface"