Skip to content

Commit f7457a5

Browse files
jamengualgithub-actions[bot]max-loburaknysh
authored
Adding external ENIs (#159)
* Adding external ENIs * Adding docs * Updating examples modules * adding new example and fixing vars * Update examples/external-eni/main.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update examples/external-eni/main.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update examples/external-eni/main.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update examples/external-eni/main.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update examples/external-eni/main.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update examples/external-eni/main.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update examples/external-eni/main.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fmt * reade * tflint fixes * tflint fixes * precommit/terraform * Fixing complete example * Update examples/complete/main.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Fixing complete example * Update readme * Update to bridcrew rules * Update to bridcrew rules * Update to bridcrew rules * Update to bridcrew rules * Update to bridgecrew rules * Update outputs.tf Co-authored-by: Andriy Knysh <[email protected]> * Addresing feedback and adding new test to run * Addresing feedback and adding new test to run * Addresing feedback and adding new test to run * fixing tests * fixing tests * addressing feedback * Update outputs.tf Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * addressing feedback --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Max Lobur <[email protected]> Co-authored-by: Andriy Knysh <[email protected]>
1 parent 7638437 commit f7457a5

18 files changed

+775
-52
lines changed

.github/workflows/release-branch.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- 'docs/**'
1111
- 'examples/**'
1212
- 'test/**'
13+
- 'README.*'
1314

1415
permissions:
1516
contents: write

.github/workflows/release-published.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ permissions:
1111

1212
jobs:
1313
terraform-module:
14-
uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/release.yml@main
14+
uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/release-published.yml@main

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ Available targets:
237237
| [aws_network_interface_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_interface_attachment) | resource |
238238
| [aws_volume_attachment.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/volume_attachment) | resource |
239239
| [null_resource.check_alarm_action](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
240-
| [null_resource.instance_profile_dependency](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
241240
| [aws_ami.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
242241
| [aws_ami.info](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
243242
| [aws_caller_identity.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
@@ -271,7 +270,7 @@ Available targets:
271270
| <a name="input_disable_api_termination"></a> [disable\_api\_termination](#input\_disable\_api\_termination) | Enable EC2 Instance Termination Protection | `bool` | `false` | no |
272271
| <a name="input_ebs_device_name"></a> [ebs\_device\_name](#input\_ebs\_device\_name) | Name of the EBS device to mount | `list(string)` | <pre>[<br> "/dev/xvdb",<br> "/dev/xvdc",<br> "/dev/xvdd",<br> "/dev/xvde",<br> "/dev/xvdf",<br> "/dev/xvdg",<br> "/dev/xvdh",<br> "/dev/xvdi",<br> "/dev/xvdj",<br> "/dev/xvdk",<br> "/dev/xvdl",<br> "/dev/xvdm",<br> "/dev/xvdn",<br> "/dev/xvdo",<br> "/dev/xvdp",<br> "/dev/xvdq",<br> "/dev/xvdr",<br> "/dev/xvds",<br> "/dev/xvdt",<br> "/dev/xvdu",<br> "/dev/xvdv",<br> "/dev/xvdw",<br> "/dev/xvdx",<br> "/dev/xvdy",<br> "/dev/xvdz"<br>]</pre> | no |
273272
| <a name="input_ebs_iops"></a> [ebs\_iops](#input\_ebs\_iops) | Amount of provisioned IOPS. This must be set with a volume\_type of `io1`, `io2` or `gp3` | `number` | `0` | no |
274-
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | Launched EC2 instance will be EBS-optimized | `bool` | `false` | no |
273+
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | Launched EC2 instance will be EBS-optimized | `bool` | `true` | no |
275274
| <a name="input_ebs_throughput"></a> [ebs\_throughput](#input\_ebs\_throughput) | Amount of throughput. This must be set if volume\_type is set to `gp3` | `number` | `0` | no |
276275
| <a name="input_ebs_volume_count"></a> [ebs\_volume\_count](#input\_ebs\_volume\_count) | Count of EBS volumes that will be attached to the instance | `number` | `0` | no |
277276
| <a name="input_ebs_volume_encrypted"></a> [ebs\_volume\_encrypted](#input\_ebs\_volume\_encrypted) | Whether to encrypt the additional EBS volumes | `bool` | `true` | no |
@@ -280,6 +279,8 @@ Available targets:
280279
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
281280
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
282281
| <a name="input_evaluation_periods"></a> [evaluation\_periods](#input\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold. | `number` | `5` | no |
282+
| <a name="input_external_network_interface_enabled"></a> [external\_network\_interface\_enabled](#input\_external\_network\_interface\_enabled) | Wheter to attach an external ENI as the eth0 interface for the instance. Any change to the interface will force instance recreation. | `bool` | `false` | no |
283+
| <a name="input_external_network_interfaces"></a> [external\_network\_interfaces](#input\_external\_network\_interfaces) | The external interface definitions to attach to the instances. This depends on the instance type | <pre>list(object({<br> delete_on_termination = bool<br> device_index = number<br> network_card_index = number<br> network_interface_id = string<br> }))</pre> | `null` | no |
283284
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
284285
| <a name="input_instance_initiated_shutdown_behavior"></a> [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Specifies whether an instance stops or terminates when you initiate shutdown from the instance. Can be one of 'stop' or 'terminate'. | `string` | `null` | no |
285286
| <a name="input_instance_profile"></a> [instance\_profile](#input\_instance\_profile) | A pre-defined profile to attach to the instance (default is to build our own) | `string` | `""` | no |

cloudwatch-alarm.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ resource "aws_cloudwatch_metric_alarm" "default" {
2121
depends_on = [null_resource.check_alarm_action]
2222

2323
dimensions = {
24-
InstanceId = join("", aws_instance.default.*.id)
24+
InstanceId = one(aws_instance.default[*].id)
2525
}
2626

2727
alarm_actions = [

docs/terraform.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
| [aws_network_interface_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_interface_attachment) | resource |
4141
| [aws_volume_attachment.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/volume_attachment) | resource |
4242
| [null_resource.check_alarm_action](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
43-
| [null_resource.instance_profile_dependency](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
4443
| [aws_ami.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
4544
| [aws_ami.info](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
4645
| [aws_caller_identity.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
@@ -74,7 +73,7 @@
7473
| <a name="input_disable_api_termination"></a> [disable\_api\_termination](#input\_disable\_api\_termination) | Enable EC2 Instance Termination Protection | `bool` | `false` | no |
7574
| <a name="input_ebs_device_name"></a> [ebs\_device\_name](#input\_ebs\_device\_name) | Name of the EBS device to mount | `list(string)` | <pre>[<br> "/dev/xvdb",<br> "/dev/xvdc",<br> "/dev/xvdd",<br> "/dev/xvde",<br> "/dev/xvdf",<br> "/dev/xvdg",<br> "/dev/xvdh",<br> "/dev/xvdi",<br> "/dev/xvdj",<br> "/dev/xvdk",<br> "/dev/xvdl",<br> "/dev/xvdm",<br> "/dev/xvdn",<br> "/dev/xvdo",<br> "/dev/xvdp",<br> "/dev/xvdq",<br> "/dev/xvdr",<br> "/dev/xvds",<br> "/dev/xvdt",<br> "/dev/xvdu",<br> "/dev/xvdv",<br> "/dev/xvdw",<br> "/dev/xvdx",<br> "/dev/xvdy",<br> "/dev/xvdz"<br>]</pre> | no |
7675
| <a name="input_ebs_iops"></a> [ebs\_iops](#input\_ebs\_iops) | Amount of provisioned IOPS. This must be set with a volume\_type of `io1`, `io2` or `gp3` | `number` | `0` | no |
77-
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | Launched EC2 instance will be EBS-optimized | `bool` | `false` | no |
76+
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | Launched EC2 instance will be EBS-optimized | `bool` | `true` | no |
7877
| <a name="input_ebs_throughput"></a> [ebs\_throughput](#input\_ebs\_throughput) | Amount of throughput. This must be set if volume\_type is set to `gp3` | `number` | `0` | no |
7978
| <a name="input_ebs_volume_count"></a> [ebs\_volume\_count](#input\_ebs\_volume\_count) | Count of EBS volumes that will be attached to the instance | `number` | `0` | no |
8079
| <a name="input_ebs_volume_encrypted"></a> [ebs\_volume\_encrypted](#input\_ebs\_volume\_encrypted) | Whether to encrypt the additional EBS volumes | `bool` | `true` | no |
@@ -83,6 +82,8 @@
8382
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
8483
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
8584
| <a name="input_evaluation_periods"></a> [evaluation\_periods](#input\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold. | `number` | `5` | no |
85+
| <a name="input_external_network_interface_enabled"></a> [external\_network\_interface\_enabled](#input\_external\_network\_interface\_enabled) | Wheter to attach an external ENI as the eth0 interface for the instance. Any change to the interface will force instance recreation. | `bool` | `false` | no |
86+
| <a name="input_external_network_interfaces"></a> [external\_network\_interfaces](#input\_external\_network\_interfaces) | The external interface definitions to attach to the instances. This depends on the instance type | <pre>list(object({<br> delete_on_termination = bool<br> device_index = number<br> network_card_index = number<br> network_interface_id = string<br> }))</pre> | `null` | no |
8687
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
8788
| <a name="input_instance_initiated_shutdown_behavior"></a> [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Specifies whether an instance stops or terminates when you initiate shutdown from the instance. Can be one of 'stop' or 'terminate'. | `string` | `null` | no |
8889
| <a name="input_instance_profile"></a> [instance\_profile](#input\_instance\_profile) | A pre-defined profile to attach to the instance (default is to build our own) | `string` | `""` | no |

eni.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ resource "aws_network_interface" "additional" {
1818

1919
resource "aws_network_interface_attachment" "additional" {
2020
count = local.additional_ips_count
21-
instance_id = join("", aws_instance.default.*.id)
21+
instance_id = one(aws_instance.default[*].id)
2222
network_interface_id = aws_network_interface.additional[count.index].id
2323
device_index = 1 + count.index
2424
}
2525

2626
resource "aws_eip" "additional" {
27+
#bridgecrew:skip=BC_AWS_NETWORKING_48: Skiping `Ensure all EIP addresses allocated to a VPC are attached to EC2 instances` because it is incorrectly flagging that this instance does not belong to a VPC even though subnet_id is configured.
2728
count = local.additional_ips_count
28-
vpc = true
29+
domain = "vpc"
2930
network_interface = aws_network_interface.additional[count.index].id
3031
}

examples/complete/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module "aws_key_pair" {
1515

1616
module "vpc" {
1717
source = "cloudposse/vpc/aws"
18-
version = "1.1.1"
18+
version = "2.1.0"
1919

2020
ipv4_primary_cidr_block = "172.16.0.0/16"
2121

@@ -24,7 +24,7 @@ module "vpc" {
2424

2525
module "subnets" {
2626
source = "cloudposse/dynamic-subnets/aws"
27-
version = "2.0.3"
27+
version = "2.3.0"
2828

2929
availability_zones = var.availability_zones
3030
vpc_id = module.vpc.vpc_id
@@ -86,5 +86,7 @@ module "ec2_instance" {
8686
instance_profile = aws_iam_instance_profile.test.name
8787
tenancy = var.tenancy
8888

89+
depends_on = [aws_iam_instance_profile.test]
90+
8991
context = module.this.context
9092
}

0 commit comments

Comments
 (0)