|
| 1 | +provider "aws" { |
| 2 | + region = "ap-south-1" |
| 3 | +} |
| 4 | + |
1 | 5 | ###########################################################
|
2 |
| -# ECS Cluster Tests |
| 6 | +# ECS Cluster |
3 | 7 | ###########################################################
|
4 | 8 |
|
5 |
| -run "cluster_name_match" { |
| 9 | +run "ecs_cluster_attributes_match" { |
6 | 10 | command = plan
|
7 | 11 |
|
8 | 12 | module {
|
9 | 13 | source = "./"
|
10 | 14 | }
|
11 | 15 |
|
12 | 16 | variables {
|
13 |
| - cluster_name = "test-cluster" |
| 17 | + cluster_name = "example-cluster-name" |
| 18 | + |
| 19 | + execute_command_configuration = { |
| 20 | + kms_key_id = "example-key-id" |
| 21 | + logging = "DEFAULT" |
| 22 | + |
| 23 | + log_configuration = { |
| 24 | + cloud_watch_encryption_enabled = true |
| 25 | + cloud_watch_log_group_name = "example-cloudwatch-group-name" |
| 26 | + s3_bucket_name = "example-bucket" |
| 27 | + s3_bucket_encryption_enabled = true |
| 28 | + s3_key_prefix = "example-key-prefix" |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + service_connect_defaults = { |
| 33 | + namespace = "arn:aws:cloudmap:us-west-2:123456789012:namespace/ns-1234567890123456" |
| 34 | + } |
| 35 | + |
| 36 | + setting = [ |
| 37 | + { |
| 38 | + name = "containerInsights" |
| 39 | + value = "enabled" |
| 40 | + } |
| 41 | + ] |
| 42 | + |
| 43 | + tags = { |
| 44 | + Example = "Tag" |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + assert { |
| 49 | + condition = aws_ecs_cluster.this.name == var.cluster_name |
| 50 | + error_message = "Name mismatch" |
| 51 | + } |
| 52 | + |
| 53 | + assert { |
| 54 | + condition = aws_ecs_cluster.this.configuration[0].execute_command_configuration[0].kms_key_id == var.execute_command_configuration.kms_key_id |
| 55 | + error_message = "KMS Key ID mismatch" |
| 56 | + } |
| 57 | + |
| 58 | + assert { |
| 59 | + condition = aws_ecs_cluster.this.configuration[0].execute_command_configuration[0].logging == var.execute_command_configuration.logging |
| 60 | + error_message = "Logging mismatch" |
| 61 | + } |
| 62 | + |
| 63 | + assert { |
| 64 | + condition = aws_ecs_cluster.this.configuration[0].execute_command_configuration[0].log_configuration[0].cloud_watch_encryption_enabled == var.execute_command_configuration.log_configuration.cloud_watch_encryption_enabled |
| 65 | + error_message = "CloudWatch Encryption status mismatch" |
| 66 | + } |
| 67 | + |
| 68 | + assert { |
| 69 | + condition = aws_ecs_cluster.this.configuration[0].execute_command_configuration[0].log_configuration[0].cloud_watch_log_group_name == var.execute_command_configuration.log_configuration.cloud_watch_log_group_name |
| 70 | + error_message = "CloudWatch Log group name mismatch" |
| 71 | + } |
| 72 | + |
| 73 | + assert { |
| 74 | + condition = aws_ecs_cluster.this.configuration[0].execute_command_configuration[0].log_configuration[0].s3_bucket_name == var.execute_command_configuration.log_configuration.s3_bucket_name |
| 75 | + error_message = "S3 Bucket name mismatch" |
| 76 | + } |
| 77 | + |
| 78 | + assert { |
| 79 | + condition = aws_ecs_cluster.this.configuration[0].execute_command_configuration[0].log_configuration[0].s3_bucket_encryption_enabled == var.execute_command_configuration.log_configuration.s3_bucket_encryption_enabled |
| 80 | + error_message = "S3 Bucket Encryption status mismatch" |
| 81 | + } |
| 82 | + |
| 83 | + assert { |
| 84 | + condition = aws_ecs_cluster.this.configuration[0].execute_command_configuration[0].log_configuration[0].s3_key_prefix == var.execute_command_configuration.log_configuration.s3_key_prefix |
| 85 | + error_message = "S3 Key Prefix mismatch" |
| 86 | + } |
| 87 | + |
| 88 | + assert { |
| 89 | + condition = aws_ecs_cluster.this.service_connect_defaults[0].namespace == var.service_connect_defaults.namespace |
| 90 | + error_message = "Namespace mismatch" |
| 91 | + } |
| 92 | + |
| 93 | + assert { |
| 94 | + condition = aws_ecs_cluster.this.setting == toset(var.setting) |
| 95 | + error_message = "Setting mismatch" |
14 | 96 | }
|
15 | 97 |
|
16 | 98 | assert {
|
17 |
| - condition = module.ecs_cluster.name == var.cluster_name |
18 |
| - error_message = "ECS Cluster name mismatch after creation" |
| 99 | + condition = aws_ecs_cluster.this.tags == var.tags |
| 100 | + error_message = "Tags mismatch" |
19 | 101 | }
|
20 | 102 | }
|
0 commit comments