Skip to content

Commit

Permalink
adding more unit tests for terraform v12
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuf Kanchwala committed Jul 27, 2020
1 parent b2a8a46 commit 60d243d
Show file tree
Hide file tree
Showing 11 changed files with 376 additions and 1,918 deletions.
7 changes: 7 additions & 0 deletions pkg/iac-providers/terraform/v12/load-dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ func TestLoadIacDir(t *testing.T) {
tfv12: TfV12{},
wantErr: nil,
},
{
name: "module directory",
tfConfigDir: "./testdata/moduleconfigs",
tfJSONFile: "./testdata/tfjson/moduleconfigs.json",
tfv12: TfV12{},
wantErr: nil,
},
}

for _, tt := range table2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,3 @@ resource "aws_cloudtrail" "missing-multi-region" {
s3_key_prefix = "prefix"
include_global_service_events = false
}

resource "aws_cloudtrail" "false-multi-region" {
name = "tf-trail-foobar"
s3_bucket_name = "some-s3-bucket"
s3_key_prefix = "prefix"
include_global_service_events = false
is_multi_region_trail = false
}

resource "aws_cloudtrail" "missing-kms" {
name = "missing-kms"
s3_bucket_name = "some-s3-bucket"
s3_key_prefix = "prefix"
include_global_service_events = false
}

resource "aws_cloudtrail" "with-kms" {
name = "with-kms"
s3_bucket_name = "some-s3-bucket"
s3_key_prefix = "prefix"
include_global_service_events = false
kms_key_id = "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
}
24 changes: 0 additions & 24 deletions pkg/iac-providers/terraform/v12/testdata/moduleconfigs/efs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,3 @@ resource "aws_efs_file_system" "efsNotEncrypted" {
Name = "not-encrypted"
}
}


resource "aws_efs_file_system" "efsEncryptedFalse" {
creation_token = "my-product"

tags = {
Name = "encrypted"
}

encrypted = false

}

resource "aws_efs_file_system" "efsEncryptedWithNoKms" {
creation_token = "my-product"

tags = {
Name = "encrypted"
}

encrypted = true

}

Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,3 @@ resource "aws_elasticache_cluster" "noMemcachedInElastiCache" {
parameter_group_name = "default.memcached1.4"
port = 11211
}


resource "aws_elasticache_cluster" "redis_version_compliant" {
cluster_id = "cluster-example"
engine = "redis"
node_type = "cache.m4.large"
num_cache_nodes = 1
parameter_group_name = "default.redis3.2"
engine_version = "3.2.10"
port = 6379
}


resource "aws_elasticache_cluster" "redis_version_non_compliant" {
cluster_id = "cluster-example"
engine = "redis"
node_type = "cache.m4.large"
num_cache_nodes = 1
parameter_group_name = "default.redis3.2"
engine_version = "3.2.0"
port = 6379
}
13 changes: 0 additions & 13 deletions pkg/iac-providers/terraform/v12/testdata/moduleconfigs/elb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,3 @@ resource "aws_load_balancer_policy" "elbWeakCipher" {
value = "true"
}
}

resource "aws_load_balancer_policy" "elbSsLTsLProtocol" {
load_balancer_name = "some-name"
policy_name = "wu-tang-ssl"
policy_type_name = "SSLNegotiationPolicyType"

policy_attribute {
name = "Protocol-SSLv3"
value = "true"
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,3 @@ resource "aws_kinesis_stream" "kinesisEncryptedWithKms" {
Environment = "kinesisEncryptedWithKms"
}
}

resource "aws_kinesis_stream" "unencrypted_aws_kinesis_stream" {
name = "terraform-kinesis-test"
shard_count = 1
retention_period = 48

shard_level_metrics = [
"IncomingBytes",
"OutgoingBytes",
]

tags = {
Environment = "test"
}
}



resource "aws_kinesis_stream" "kinesis_encrypted_but_no_kms_provided" {
name = "kinesisEncryptedWithKms"
shard_count = 1
retention_period = 48

shard_level_metrics = [
"IncomingBytes",
"OutgoingBytes",
]

encryption_type = "KMS"
}

76 changes: 0 additions & 76 deletions pkg/iac-providers/terraform/v12/testdata/moduleconfigs/s3/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,79 +7,3 @@ resource "aws_s3_bucket" "noS3BucketSseRules" {
Environment = "Dev"
}
}


resource "aws_s3_bucket" "s3BucketSseRulesWithKmsNull" {
bucket = "mybucket"
acl = "private"

tags = {
Name = "s3BucketSseRulesWithNoKms"
Environment = "Dev"
}

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
}
}
}
}

resource "aws_s3_bucket" "s3BucketNoWebsiteIndexDoc" {
bucket = "website"
acl = "public-read"

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
kms_master_key_id = "some-key-id"
sse_algorithm = "aws:kms"
}
}
}

website {
index_document = "index.html"
error_document = "error.html"
}
}

resource "aws_s3_bucket" "s3VersioningMfaFalse" {
bucket = "tf-test"

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
kms_master_key_id = "some-key-id"
sse_algorithm = "aws:kms"
}
}
}

versioning {
enabled = true
mfa_delete = false
}
}

resource "aws_s3_bucket" "allUsersReadAccess" {
bucket = "my-tf-test-bucket"
acl = "public-read"
}

resource "aws_s3_bucket" "authUsersReadAccess" {
bucket = "my-tf-test-bucket"
acl = "authenticated-read"
}

resource "aws_s3_bucket" "allUsersWriteAccess" {
bucket = "my-tf-test-bucket"
acl = "public-write"
}

resource "aws_s3_bucket" "allUsersReadWriteAccess" {
bucket = "my-tf-test-bucket"
acl = "public-read-write"
}
Loading

0 comments on commit 60d243d

Please sign in to comment.