Skip to content

Commit

Permalink
Data source: use aws_subnets over aws_subnet_ids (#1113)
Browse files Browse the repository at this point in the history
For compatibility with AWS provider v4, switch to using the new resource.
  • Loading branch information
rhoboat authored May 10, 2022
1 parent 62f6d38 commit d48fccc
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
9 changes: 6 additions & 3 deletions examples/terraform-asg-scp-example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ resource "aws_launch_template" "sample_launch_template" {
}

resource "aws_autoscaling_group" "sample_asg" {
vpc_zone_identifier = data.aws_subnet_ids.default_subnets.ids
vpc_zone_identifier = data.aws_subnets.default_subnets.ids

desired_capacity = 1
max_size = 1
Expand Down Expand Up @@ -102,7 +102,10 @@ data "aws_vpc" "default" {
default = true
}

data "aws_subnet_ids" "default_subnets" {
vpc_id = data.aws_vpc.default.id
data "aws_subnets" "default_subnets" {
filter {
name = "vpc-id"
values = [data.aws_vpc.default.id]
}
}

9 changes: 6 additions & 3 deletions examples/terraform-aws-ecs-example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ data "aws_vpc" "default" {
default = true
}

data "aws_subnet_ids" "all" {
vpc_id = data.aws_vpc.default.id
data "aws_subnets" "all" {
filter {
name = "vpc-id"
values = [data.aws_vpc.default.id]
}
}

# ---------------------------------------------------------------------------------------------------------------------
Expand All @@ -47,7 +50,7 @@ resource "aws_ecs_service" "example" {
launch_type = "FARGATE"

network_configuration {
subnets = data.aws_subnet_ids.all.ids
subnets = data.aws_subnets.all.ids
}
}

Expand Down
9 changes: 6 additions & 3 deletions examples/terraform-aws-rds-example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ data "aws_vpc" "default" {
default = true
}

data "aws_subnet_ids" "all" {
vpc_id = data.aws_vpc.default.id
data "aws_subnets" "all" {
filter {
name = "vpc-id"
values = [data.aws_vpc.default.id]
}
}

# ---------------------------------------------------------------------------------------------------------------------
Expand All @@ -35,7 +38,7 @@ data "aws_subnet_ids" "all" {

resource "aws_db_subnet_group" "example" {
name = var.name
subnet_ids = data.aws_subnet_ids.all.ids
subnet_ids = data.aws_subnets.all.ids

tags = {
Name = var.name
Expand Down
11 changes: 7 additions & 4 deletions examples/terraform-redeploy-example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ resource "aws_autoscaling_group" "web_servers" {
min_elb_capacity = 3

# Deploy into all the subnets (and therefore AZs) available
vpc_zone_identifier = data.aws_subnet_ids.default.ids
vpc_zone_identifier = data.aws_subnets.default.ids

# Automatically register this ASG's Instances in the ALB and use the ALB's health check to determine when an Instance
# needs to be replaced
Expand Down Expand Up @@ -173,7 +173,7 @@ resource "aws_security_group_rule" "web_server_allow_all_outbound" {
resource "aws_alb" "web_servers" {
name = var.instance_name
security_groups = [aws_security_group.alb.id]
subnets = data.aws_subnet_ids.default.ids
subnets = data.aws_subnets.default.ids

# This is here because aws_alb_listener.http depends on this resource and sets create_before_destroy to true
lifecycle {
Expand Down Expand Up @@ -294,7 +294,10 @@ data "aws_vpc" "default" {
default = true
}

data "aws_subnet_ids" "default" {
vpc_id = data.aws_vpc.default.id
data "aws_subnets" "default" {
filter {
name = "vpc-id"
values = [data.aws_vpc.default.id]
}
}

3 changes: 2 additions & 1 deletion modules/aws/lambda_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package aws

import (
"github.com/stretchr/testify/require"
"testing"

"github.com/stretchr/testify/require"
)

func TestFunctionError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion modules/terraform/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestParallelism(t *testing.T) {
Apply(t, options)
end = time.Now()
duration := end.Sub(start)
require.Greater(t, int64(duration.Seconds()), int64(25))
require.GreaterOrEqual(t, int64(duration.Seconds()), int64(25))
}
func TestTgApplyUseLockNoError(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit d48fccc

Please sign in to comment.