Skip to content

Commit

Permalink
skip: update autotest for peering-connection, launch, kafka
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-shcherbak committed May 30, 2024
1 parent 24fa4b4 commit 5ff88e1
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 91 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tf_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
# resource_priority_list:
# type: string
# description: Priority list for resources (you can remove unnecessary resources during testing)
# default: 'efs'
# default: 'efsdata.terraform_remote_state.common.outputs.sg_1_id'
# required: true

concurrency:
Expand All @@ -22,7 +22,7 @@ env:
CORE_TESTING_FOLDER: ${{ github.workspace }}
OUTPUT_DIR: ${{ github.workspace }}/auto_policy_testing/output
AWS_DEFAULT_REGION: ${{ vars.AWS_REGION }}
resource_priority_list: 'log'
resource_priority_list: 'peering-connection,launch'
RED: '\033[0;31m'

jobs:
Expand Down
4 changes: 4 additions & 0 deletions auto_policy_testing/green/common_resources/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ output "kms_key_arn" {
value = aws_kms_key.this.arn
}

output "sg_1_id" {
value = aws_security_group.this.id
}

output "wafregional_acl_id" {
value = aws_wafregional_web_acl.this.id
}
39 changes: 7 additions & 32 deletions auto_policy_testing/green/kafka/kafka.tf
Original file line number Diff line number Diff line change
@@ -1,47 +1,22 @@
resource "aws_vpc" "this" {
cidr_block = "192.168.0.0/22"
}

resource "aws_subnet" "subnet_1" {
availability_zone = data.aws_availability_zones.this.names[0]
cidr_block = "192.168.0.0/24"
vpc_id = aws_vpc.this.id
}

resource "aws_subnet" "subnet_2" {
availability_zone = data.aws_availability_zones.this.names[1]
cidr_block = "192.168.1.0/24"
vpc_id = aws_vpc.this.id
}

resource "aws_subnet" "subnet_3" {
availability_zone = data.aws_availability_zones.this.names[2]
cidr_block = "192.168.2.0/24"
vpc_id = aws_vpc.this.id
}

resource "aws_security_group" "this" {
vpc_id = aws_vpc.this.id
}
# Takes min to deploy

resource "aws_msk_cluster" "this" {
cluster_name = "${module.naming.resource_prefix.kafka}"
kafka_version = "2.6.2"
number_of_broker_nodes = 3
kafka_version = "3.5.1"
number_of_broker_nodes = 2

broker_node_group_info {
instance_type = "kafka.t3.small"
client_subnets = [
aws_subnet.subnet_1.id,
aws_subnet.subnet_2.id,
aws_subnet.subnet_3.id,
data.terraform_remote_state.common.outputs.vpc_subnet_1_id,
data.terraform_remote_state.common.outputs.vpc_subnet_2_id
]
storage_info {
ebs_storage_info {
volume_size = 5
volume_size = 1
}
}
security_groups = [aws_security_group.this.id]
security_groups = [data.terraform_remote_state.common.outputs.sg_1_id]
}

encryption_info {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
resource "aws_vpc_peering_connection" "this" {
peer_owner_id = data.aws_caller_identity.this.account_id
peer_vpc_id = aws_vpc.vpc1.id
vpc_id = aws_vpc.vpc2.id
peer_vpc_id = data.terraform_remote_state.common.outputs.vpc_id
vpc_id = aws_vpc.vpc.id
auto_accept = true
}

resource "aws_vpc" "vpc1" {
resource "aws_vpc" "vpc" {
cidr_block = "10.1.0.0/16"
}

resource "aws_vpc" "vpc2" {
cidr_block = "10.2.0.0/16"
}
4 changes: 4 additions & 0 deletions auto_policy_testing/red/common_resources/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ output "vpc_subnet_2_id" {

output "vpc_subnet_3_id" {
value = aws_subnet.subnet3.id
}

output "sg_1_id" {
value = aws_security_group.this.id
}
8 changes: 8 additions & 0 deletions auto_policy_testing/red/common_resources/sg.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "aws_security_group" "this" {
name = module.naming.resource_prefix.security_group
vpc_id = aws_vpc.this.id
tags = {
Name = "${module.naming.resource_prefix.security_group}"
}
}

43 changes: 8 additions & 35 deletions auto_policy_testing/red/kafka/kafka.tf
Original file line number Diff line number Diff line change
@@ -1,35 +1,9 @@
resource "aws_vpc" "this" {
cidr_block = "192.168.0.0/22"
}

resource "aws_subnet" "subnet_1" {
availability_zone = data.aws_availability_zones.this.names[0]
cidr_block = "192.168.0.0/24"
vpc_id = aws_vpc.this.id
}

resource "aws_subnet" "subnet_2" {
availability_zone = data.aws_availability_zones.this.names[1]
cidr_block = "192.168.1.0/24"
vpc_id = aws_vpc.this.id
}

resource "aws_subnet" "subnet_3" {
availability_zone = data.aws_availability_zones.this.names[2]
cidr_block = "192.168.2.0/24"
vpc_id = aws_vpc.this.id
}

resource "aws_security_group" "this" {
vpc_id = aws_vpc.this.id
}

resource "aws_msk_cluster" "this" {
cluster_name = "${module.naming.resource_prefix.kafka}"
kafka_version = "2.6.2"
number_of_broker_nodes = 3
provider = aws.provider2

cluster_name = "${module.naming.resource_prefix.kafka}"
kafka_version = "3.5.1"
number_of_broker_nodes = 2

encryption_info {
encryption_in_transit {
client_broker = "TLS_PLAINTEXT"
Expand All @@ -40,15 +14,14 @@ resource "aws_msk_cluster" "this" {
broker_node_group_info {
instance_type = "kafka.t3.small"
client_subnets = [
aws_subnet.subnet_1.id,
aws_subnet.subnet_2.id,
aws_subnet.subnet_3.id,
data.terraform_remote_state.common.outputs.vpc_subnet_1_id,
data.terraform_remote_state.common.outputs.vpc_subnet_2_id
]
storage_info {
ebs_storage_info {
volume_size = 5
volume_size = 1
}
}
security_groups = [aws_security_group.this.id]
security_groups = [data.terraform_remote_state.common.outputs.sg_1_id]
}
}
6 changes: 3 additions & 3 deletions auto_policy_testing/red/launch/data.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
data "aws_ami" "this" {
most_recent = true
owners = ["amazon"]

filter {
name = "name"
values = ["amzn2-ami-hvm*"]
name = "name"
values = ["amzn2-ami-hvm*"]
}
}
4 changes: 2 additions & 2 deletions auto_policy_testing/red/launch/launch.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "aws_launch_configuration" "this" {
name_prefix = "${module.naming.resource_prefix.launch_config}"
name_prefix = module.naming.resource_prefix.launch_config
image_id = data.aws_ami.this.id
instance_type = "t2.micro"
associate_public_ip_address = true
associate_public_ip_address = true
metadata_options {
http_endpoint = "enabled"
http_tokens = "optional"
Expand Down
13 changes: 4 additions & 9 deletions auto_policy_testing/red/peering-connection/peering_connection.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
resource "aws_vpc_peering_connection" "this" {
peer_owner_id = data.aws_caller_identity.this.account_id
peer_vpc_id = aws_vpc.vpc1.id
vpc_id = aws_vpc.vpc2.id
auto_accept = true
provider = aws.provider2
peer_owner_id = data.aws_caller_identity.this.account_id
peer_vpc_id = data.terraform_remote_state.common.outputs.vpc_id
vpc_id = aws_vpc.vpc.id
}

resource "aws_vpc" "vpc1" {
cidr_block = "10.1.0.0/16"
}

resource "aws_vpc" "vpc2" {
resource "aws_vpc" "vpc" {
cidr_block = "10.2.0.0/16"
}
2 changes: 1 addition & 1 deletion auto_policy_testing/shared_tf_modules/naming/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ output "resource_prefix" {
sagemaker_model = "${local.suffix}-${var.resource_type}-sagemaker-model-${local.compliance_status}"
sagemaker_notebook = "${local.suffix}-${var.resource_type}-sagemaker-notebook-${local.compliance_status}"
qldb = "${local.suffix}-${var.resource_type}-qldb-${local.compliance_status}"
kafka = "${local.suffix}_${var.resource_type}_kafka_${local.compliance_status}"
kafka = "${local.suffix}-${var.resource_type}-kafka-${local.compliance_status}"
acm = "${local.suffix}.${local.compliance_status}"
launch_config = "${local.suffix}_${var.resource_type}_launch_config_${local.compliance_status}"
nat_gateway = "${local.suffix}_${var.resource_type}_ng_${local.compliance_status}"
Expand Down

0 comments on commit 5ff88e1

Please sign in to comment.