|
| 1 | + |
| 2 | +mock_provider "aws" { |
| 3 | + mock_data "aws_availability_zones" { |
| 4 | + defaults = { |
| 5 | + group_names = [] |
| 6 | + names = ["eu-west-2a", "eu-west-2b", "eu-west-2c"] |
| 7 | + } |
| 8 | + } |
| 9 | +} |
| 10 | + |
| 11 | +run "resolver_sharing" { |
| 12 | + command = plan |
| 13 | + |
| 14 | + variables { |
| 15 | + resolver_name = "test" |
| 16 | + tags = { |
| 17 | + Environment = "Test" |
| 18 | + } |
| 19 | + |
| 20 | + resolver_rule_groups = [ |
| 21 | + { |
| 22 | + ram_share_name = "internal" |
| 23 | + ram_principals = { |
| 24 | + "Deployments" = "arn:aws:organizations::536471746696:ou/o-7enwqk0f2c/ou-1tbg-mq4w830q" |
| 25 | + "Workloads" = "arn:aws:organizations::536471746696:ou/o-7enwqk0f2c/ou-1tbg-lk6g79d4" |
| 26 | + } |
| 27 | + rules = [ |
| 28 | + { |
| 29 | + name = "aws-appvia-local" |
| 30 | + domain = "aws.appvia.local" |
| 31 | + } |
| 32 | + ] |
| 33 | + } |
| 34 | + ] |
| 35 | + |
| 36 | + network = { |
| 37 | + name = "test" |
| 38 | + availability_zones = 2 |
| 39 | + vpc_cidr = "10.90.0.0/21" |
| 40 | + transit_gateway_id = "tgw-12222222" |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + assert { |
| 45 | + condition = length(aws_ram_principal_association.this) == length(var.resolver_rule_groups[0].ram_principals) |
| 46 | + error_message = "Expected the correct number of RAM principal associations" |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +run "resolver_creation" { |
| 51 | + command = plan |
| 52 | + |
| 53 | + variables { |
| 54 | + resolver_name = "test" |
| 55 | + tags = { |
| 56 | + Environment = "Test" |
| 57 | + } |
| 58 | + |
| 59 | + resolver_rule_groups = [ |
| 60 | + { |
| 61 | + ram_share_name = "internal" |
| 62 | + ram_principals = {} |
| 63 | + rules = [ |
| 64 | + { |
| 65 | + name = "aws-appvia-local" |
| 66 | + domain = "aws.appvia.local" |
| 67 | + } |
| 68 | + ] |
| 69 | + } |
| 70 | + ] |
| 71 | + |
| 72 | + network = { |
| 73 | + name = "test" |
| 74 | + availability_zones = 2 |
| 75 | + vpc_cidr = "10.90.0.0/21" |
| 76 | + transit_gateway_id = "tgw-12222222" |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + assert { |
| 81 | + condition = aws_route53_resolver_endpoint.this.name == var.resolver_name |
| 82 | + error_message = "Name of the resolver is incorrect" |
| 83 | + } |
| 84 | + |
| 85 | + assert { |
| 86 | + condition = length(aws_route53_resolver_endpoint.this.protocols) == length(var.resolver_protocols) |
| 87 | + error_message = "Expected protocols to be set" |
| 88 | + } |
| 89 | + |
| 90 | + assert { |
| 91 | + condition = aws_route53_resolver_endpoint.this.resolver_endpoint_type == var.resolver_endpoint_type |
| 92 | + error_message = "Expected resolver endpoint type to be set" |
| 93 | + } |
| 94 | + |
| 95 | + assert { |
| 96 | + condition = aws_route53_resolver_endpoint.this.direction == "OUTBOUND" |
| 97 | + error_message = "Expected an outbound resolver" |
| 98 | + } |
| 99 | + |
| 100 | + assert { |
| 101 | + condition = module.dns_security_group.aws_security_group.this_name_prefix[0].name_prefix == "dns-resolvers-test" |
| 102 | + error_message = "Expected security group to be created" |
| 103 | + } |
| 104 | +} |
0 commit comments