diff --git a/modules/eks-cluster/README.md b/modules/eks-cluster/README.md index 18021d69..dfa3f03c 100644 --- a/modules/eks-cluster/README.md +++ b/modules/eks-cluster/README.md @@ -92,6 +92,7 @@ module "eks_cluster" { | [private\_subnet\_ids](#output\_private\_subnet\_ids) | Private subnet IDs | | [private\_vpc\_cidr\_blocks](#output\_private\_vpc\_cidr\_blocks) | Private VPC CIDR blocks | | [public\_vpc\_cidr\_blocks](#output\_public\_vpc\_cidr\_blocks) | Public VPC CIDR blocks | +| [vpc\_azs](#output\_vpc\_azs) | VPC AZs of the cluster | | [vpc\_id](#output\_vpc\_id) | VPC id of the cluster | | [vpc\_main\_route\_table\_id](#output\_vpc\_main\_route\_table\_id) | The ID of the main route table associated with this VPC | diff --git a/modules/eks-cluster/outputs.tf b/modules/eks-cluster/outputs.tf index 8a7c2174..a56bcfc4 100644 --- a/modules/eks-cluster/outputs.tf +++ b/modules/eks-cluster/outputs.tf @@ -96,6 +96,11 @@ output "vpc_id" { value = module.vpc.vpc_id } +output "vpc_azs" { + description = "VPC AZs of the cluster" + value = module.vpc.azs +} + output "private_vpc_cidr_blocks" { value = module.vpc.private_subnets_cidr_blocks description = "Private VPC CIDR blocks" diff --git a/test/src/custom_eks_opensearch_test.go b/test/src/custom_eks_opensearch_test.go index f27b6371..e24f7abd 100644 --- a/test/src/custom_eks_opensearch_test.go +++ b/test/src/custom_eks_opensearch_test.go @@ -85,6 +85,8 @@ func (suite *CustomEKSOpenSearchTestSuite) TestCustomEKSAndOpenSearch() { "name": suite.clusterName, "region": suite.region, "np_desired_node_count": suite.expectedNodes, + // we test the usage of a single zone + "availability_zones_count": 1, } suite.sugaredLogger.Infow("Creating EKS cluster...", "extraVars", suite.varTf) @@ -126,6 +128,9 @@ func (suite *CustomEKSOpenSearchTestSuite) TestCustomEKSAndOpenSearch() { // idempotency test terraform.InitAndApply(suite.T(), terraformOptions) + expectedVpcAZs := fmt.Sprintf("[%sa]", suite.varTf["region"]) // must match availability_zones_count, by default it's the first zone + suite.Assert().Equal(expectedVpcAZs, terraform.Output(suite.T(), terraformOptions, "vpc_azs")) + sess, err := utils.GetAwsClient() suite.Require().NoErrorf(err, "Failed to get aws client") diff --git a/test/src/custom_eks_rds_test.go b/test/src/custom_eks_rds_test.go index f23e1e71..bc30dbb3 100644 --- a/test/src/custom_eks_rds_test.go +++ b/test/src/custom_eks_rds_test.go @@ -84,6 +84,8 @@ func (suite *CustomEKSRDSTestSuite) TestCustomEKSAndRDS() { "name": suite.clusterName, "region": suite.region, "np_desired_node_count": suite.expectedNodes, + // we test the definition of specific AZs + "availability_zones": string{fmt.Sprintf("%sb", suite.region), fmt.Sprintf("%sc", suite.region)}, } suite.sugaredLogger.Infow("Creating EKS cluster...", "extraVars", suite.varTf) @@ -125,6 +127,10 @@ func (suite *CustomEKSRDSTestSuite) TestCustomEKSAndRDS() { // idempotency test terraform.InitAndApply(suite.T(), terraformOptions) + // basic tests after terraform apply + expectedVpcAZs := fmt.Sprintf("[%sb %sc]", suite.varTf["region"], suite.varTf["region"]) + suite.Assert().Equal(expectedVpcAZs, terraform.Output(suite.T(), terraformOptions, "vpc_azs")) + sess, err := utils.GetAwsClient() suite.Require().NoErrorf(err, "Failed to get aws client") diff --git a/test/src/default_eks_test.go b/test/src/default_eks_test.go index 9d2907c6..8a74ae3c 100644 --- a/test/src/default_eks_test.go +++ b/test/src/default_eks_test.go @@ -141,6 +141,7 @@ func (suite *DefaultEKSTestSuite) baseChecksEKS(terraformOptions *terraform.Opti suite.Assert().NotEmpty(terraform.Output(suite.T(), terraformOptions, "ebs_cs_arn")) suite.Assert().NotEmpty(terraform.Output(suite.T(), terraformOptions, "external_dns_arn")) suite.Assert().NotEmpty(terraform.Output(suite.T(), terraformOptions, "vpc_id")) + suite.Assert().NotEmpty(terraform.Output(suite.T(), terraformOptions, "vpc_azs")) suite.Assert().NotEmpty(terraform.Output(suite.T(), terraformOptions, "private_vpc_cidr_blocks")) suite.Assert().NotEmpty(terraform.Output(suite.T(), terraformOptions, "private_subnet_ids")) suite.Assert().NotEmpty(terraform.Output(suite.T(), terraformOptions, "default_security_group_id")) @@ -159,6 +160,9 @@ func (suite *DefaultEKSTestSuite) baseChecksEKS(terraformOptions *terraform.Opti expectedPublicVpcCidrBlocks := "[10.192.96.0/19 10.192.128.0/19 10.192.160.0/19]" suite.Assert().Equal(expectedPublicVpcCidrBlocks, terraform.Output(suite.T(), terraformOptions, "public_vpc_cidr_blocks")) + expectedVpcAZs := fmt.Sprintf("[%sa %sb %sc]", suite.varTf["region"], suite.varTf["region"], suite.varTf["region"]) + suite.Assert().Equal(expectedVpcAZs, terraform.Output(suite.T(), terraformOptions, "vpc_azs")) + sess, err := utils.GetAwsClient() suite.Require().NoErrorf(err, "Failed to get aws client")