Skip to content

Commit 8f1d9a7

Browse files
authored
Support AWS Provider V5 (#57)
* Support AWS Provider V5 * upd * Support AWS Provider V5 * upd * updates * updates
1 parent 0a276cf commit 8f1d9a7

File tree

13 files changed

+58
-55
lines changed

13 files changed

+58
-55
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: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ We highly recommend that in your code you pin the version to the exact version y
9999
using so that your infrastructure remains stable, and update versions in a
100100
systematic way so that they do not catch you by surprise.
101101

102-
Also, because of a bug in the Terraform registry ([hashicorp/terraform#21417](https://github.com/hashicorp/terraform/issues/21417)),
103-
the registry shows many of our inputs as required when in fact they are optional.
104-
The table below correctly indicates which inputs are required.
105-
106102

107103
Note: add `${var.ssh_key_pair}` private key to the `ssh agent`.
108104

@@ -226,7 +222,7 @@ Available targets:
226222

227223
| Name | Version |
228224
|------|---------|
229-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
225+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
230226
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.0 |
231227

232228
## Providers
@@ -278,7 +274,6 @@ Available targets:
278274
| <a name="input_availability_zone"></a> [availability\_zone](#input\_availability\_zone) | Availability Zone the instance is launched in. If not set, will be launched in the first AZ of the region | `string` | `""` | no |
279275
| <a name="input_comparison_operator"></a> [comparison\_operator](#input\_comparison\_operator) | The arithmetic operation to use when comparing the specified Statistic and Threshold. Possible values are: GreaterThanOrEqualToThreshold, GreaterThanThreshold, LessThanThreshold, LessThanOrEqualToThreshold | `string` | `"GreaterThanOrEqualToThreshold"` | no |
280276
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
281-
| <a name="input_create_default_security_group"></a> [create\_default\_security\_group](#input\_create\_default\_security\_group) | Create default Security Group with only Egress traffic allowed | `bool` | `true` | no |
282277
| <a name="input_default_alarm_action"></a> [default\_alarm\_action](#input\_default\_alarm\_action) | Default alarm action | `string` | `"action/actions/AWS_EC2.InstanceId.Reboot/1.0"` | no |
283278
| <a name="input_delete_on_termination"></a> [delete\_on\_termination](#input\_delete\_on\_termination) | Whether the volume should be destroyed on instance termination | `bool` | `true` | no |
284279
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
@@ -333,7 +328,6 @@ Available targets:
333328
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
334329
| <a name="input_user_data"></a> [user\_data](#input\_user\_data) | Instance user data. Do not pass gzip-compressed data via this argument | `string` | `""` | no |
335330
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The ID of the VPC that the instance security group belongs to | `string` | n/a | yes |
336-
| <a name="input_welcome_message"></a> [welcome\_message](#input\_welcome\_message) | Welcome message | `string` | `""` | no |
337331

338332
## Outputs
339333

cloud_watch_alarm.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resource "aws_cloudwatch_metric_alarm" "default" {
1616
threshold = var.metric_threshold
1717

1818
dimensions = {
19-
InstanceId = sort(aws_instance.default.*.id)[count.index]
19+
InstanceId = sort(aws_instance.default[*].id)[count.index]
2020
}
2121

2222
alarm_actions = [

docs/terraform.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
| Name | Version |
55
|------|---------|
6-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
77
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.0 |
88

99
## Providers
@@ -55,7 +55,6 @@
5555
| <a name="input_availability_zone"></a> [availability\_zone](#input\_availability\_zone) | Availability Zone the instance is launched in. If not set, will be launched in the first AZ of the region | `string` | `""` | no |
5656
| <a name="input_comparison_operator"></a> [comparison\_operator](#input\_comparison\_operator) | The arithmetic operation to use when comparing the specified Statistic and Threshold. Possible values are: GreaterThanOrEqualToThreshold, GreaterThanThreshold, LessThanThreshold, LessThanOrEqualToThreshold | `string` | `"GreaterThanOrEqualToThreshold"` | no |
5757
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
58-
| <a name="input_create_default_security_group"></a> [create\_default\_security\_group](#input\_create\_default\_security\_group) | Create default Security Group with only Egress traffic allowed | `bool` | `true` | no |
5958
| <a name="input_default_alarm_action"></a> [default\_alarm\_action](#input\_default\_alarm\_action) | Default alarm action | `string` | `"action/actions/AWS_EC2.InstanceId.Reboot/1.0"` | no |
6059
| <a name="input_delete_on_termination"></a> [delete\_on\_termination](#input\_delete\_on\_termination) | Whether the volume should be destroyed on instance termination | `bool` | `true` | no |
6160
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
@@ -110,7 +109,6 @@
110109
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
111110
| <a name="input_user_data"></a> [user\_data](#input\_user\_data) | Instance user data. Do not pass gzip-compressed data via this argument | `string` | `""` | no |
112111
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The ID of the VPC that the instance security group belongs to | `string` | n/a | yes |
113-
| <a name="input_welcome_message"></a> [welcome\_message](#input\_welcome\_message) | Welcome message | `string` | `""` | no |
114112

115113
## Outputs
116114

eni.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ locals {
55
resource "aws_network_interface" "additional" {
66
count = local.additional_ips_count * var.instance_count
77
subnet_id = var.subnet
8-
security_groups = compact(concat(module.security_group.*.id, var.security_groups))
8+
security_groups = compact(concat(module.security_group[*].id, var.security_groups))
99

1010
tags = module.label.tags
1111
depends_on = [aws_instance.default]
1212
}
1313

1414
resource "aws_network_interface_attachment" "additional" {
1515
count = local.additional_ips_count * var.instance_count
16-
instance_id = aws_instance.default.*.id[count.index % var.instance_count]
17-
network_interface_id = aws_network_interface.additional.*.id[count.index]
16+
instance_id = aws_instance.default[*].id[count.index % var.instance_count]
17+
network_interface_id = aws_network_interface.additional[*].id[count.index]
1818
device_index = 1 + count.index
1919
depends_on = [aws_instance.default]
2020
}
2121

2222
resource "aws_eip" "additional" {
2323
count = local.additional_ips_count * var.instance_count
2424
vpc = true
25-
network_interface = aws_network_interface.additional.*.id[count.index]
25+
network_interface = aws_network_interface.additional[*].id[count.index]
2626
depends_on = [aws_instance.default]
2727
}

examples/basic/versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 4.0"
8+
}
9+
}
10+
}

examples/complete/main.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ provider "aws" {
33
}
44

55
module "vpc" {
6-
source = "cloudposse/vpc/aws"
7-
version = "0.18.1"
8-
cidr_block = "172.16.0.0/16"
6+
source = "cloudposse/vpc/aws"
7+
version = "2.1.0"
8+
9+
ipv4_primary_cidr_block = "172.16.0.0/16"
910

1011
context = module.this.context
1112
}
1213

1314
module "subnets" {
14-
source = "cloudposse/dynamic-subnets/aws"
15-
version = "0.33.0"
15+
source = "cloudposse/dynamic-subnets/aws"
16+
version = "2.3.0"
17+
1618
availability_zones = var.availability_zones
1719
vpc_id = module.vpc.vpc_id
18-
igw_id = module.vpc.igw_id
19-
cidr_block = module.vpc.vpc_cidr_block
20+
igw_id = [module.vpc.igw_id]
21+
ipv4_cidr_block = [module.vpc.vpc_cidr_block]
2022
nat_gateway_enabled = false
2123
nat_instance_enabled = false
2224

examples/complete/versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 4.0"
8+
}
9+
}
10+
}

main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ locals {
1313
locals {
1414
public_ips = compact(
1515
concat(
16-
coalescelist(aws_eip.default.*.public_ip, aws_instance.default.*.public_ip),
17-
coalescelist(aws_eip.additional.*.public_ip, [""])
16+
coalescelist(aws_eip.default[*].public_ip, aws_instance.default[*].public_ip),
17+
coalescelist(aws_eip.additional[*].public_ip, [""])
1818
)
1919
)
2020

@@ -68,7 +68,7 @@ module "label" {
6868
resource "aws_iam_instance_profile" "default" {
6969
count = signum(local.instance_count)
7070
name = module.label.id
71-
role = join("", aws_iam_role.default.*.name)
71+
role = join("", aws_iam_role.default[*].name)
7272
}
7373

7474
resource "aws_iam_role" "default" {
@@ -89,16 +89,16 @@ resource "aws_instance" "default" {
8989
ebs_optimized = var.ebs_optimized
9090
disable_api_termination = var.disable_api_termination
9191
user_data = var.user_data
92-
iam_instance_profile = join("", aws_iam_instance_profile.default.*.name)
92+
iam_instance_profile = join("", aws_iam_instance_profile.default[*].name)
9393
associate_public_ip_address = var.associate_public_ip_address
9494
key_name = signum(length(var.ssh_key_pair)) == 1 ? var.ssh_key_pair : module.ssh_key_pair.key_name
9595
subnet_id = var.subnet
9696
monitoring = var.monitoring
97-
private_ip = concat(var.private_ips, [""])[min(length(var.private_ips), count.index)]
97+
private_ip = concat(var.private_ips, [null])[min(length(var.private_ips), count.index)]
9898
source_dest_check = var.source_dest_check
9999
ipv6_address_count = var.ipv6_address_count < 0 ? null : var.ipv6_address_count
100100
ipv6_addresses = length(var.ipv6_addresses) > 0 ? var.ipv6_addresses : null
101-
vpc_security_group_ids = compact(concat(module.security_group.*.id, var.security_groups))
101+
vpc_security_group_ids = compact(concat(module.security_group[*].id, var.security_groups))
102102

103103
root_block_device {
104104
volume_type = local.root_volume_type
@@ -138,7 +138,7 @@ module "ssh_key_pair" {
138138

139139
resource "aws_eip" "default" {
140140
count = local.count_default_ips
141-
network_interface = aws_instance.default.*.primary_network_interface_id[count.index]
141+
network_interface = aws_instance.default[*].primary_network_interface_id[count.index]
142142
vpc = true
143143
depends_on = [aws_instance.default]
144144
tags = module.this.tags
@@ -158,6 +158,6 @@ resource "aws_ebs_volume" "default" {
158158
resource "aws_volume_attachment" "default" {
159159
count = signum(local.instance_count) == 1 ? var.ebs_volume_count * local.instance_count : 0
160160
device_name = element(slice(var.ebs_device_names, 0, floor(var.ebs_volume_count * local.instance_count / max(local.instance_count, 1))), count.index)
161-
volume_id = aws_ebs_volume.default.*.id[count.index]
162-
instance_id = aws_instance.default.*.id[count.index]
161+
volume_id = aws_ebs_volume.default[*].id[count.index]
162+
instance_id = aws_instance.default[*].id[count.index]
163163
}

0 commit comments

Comments
 (0)