Skip to content

Commit 8977307

Browse files
committed
Push to get basic tests operational.
1 parent a1400b7 commit 8977307

File tree

3 files changed

+54
-37
lines changed

3 files changed

+54
-37
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,37 @@ You specify every ingress rule you need in just one line with words like **ssh**
2222
vpc_security_group_ids = "${module.security_group.out_security_group_ids}"
2323
}
2424

25-
2625
Output **out_security_group_ids** is a **list** whilst **out_security_group_id** is a **string**.
2726

2827
## [Examples and Tests](test-security.group)
2928

3029
**[This terraform module has runnable example integration tests](test-security.group)**. Read the instructions on how to clone the project and run the integration tests.
3130

3231

33-
## Security Group Module Inputs
32+
## Use Case
33+
34+
What is the use case flow at the heart of this security group rule creation module?
35+
36+
- a **VPC is provided** (or the default one is used)
37+
- a **security group is created** (or the default one for the VPC is used)
38+
- **ingress and egress rules are added to the security group**
39+
- the default source (and/or destination) of 0.0.0.0/0 is used
40+
- the rules can apply to specific supplied (source and/or destination) addresses
41+
42+
43+
## Inputs
3444

3545
The security group's input variables are vital to achieving the desired behaviour.
3646

3747
| Imported | Type | Default | Comment |
3848
|:-------- |:---- |:------- |:------- |
3949
**in_vpc_id** | String | vpc-1234567890 | create security group/s under VPC with this id
4050
**in_use_default** | Boolean | [ true ] | use the default security group if true else create one
41-
**in_ingress** | List | [ "postgres", "https"] | identigy the ports to allow for inbound traffic
42-
**in_egress** | List | [ "all-traffic" ] | identigy the ports to allow for outbound traffic
51+
**in_ingress** | List | [ "postgres", "https"] | identify the ports to allow for inbound traffic
52+
**in_egress** | List | [ "all-traffic" ] | identify the ports to allow for outbound traffic
4353
**in_ingress_cidr_blocks** | List | [ "0.0.0.0/0"] | list of source incoming traffic addresses to allow
4454
**in_egress_cidr_blocks** | List | [ "0.0.0.0/0"] | list of VPC source outgoing traffic addresses to allow
45-
**in_ecosystem_id** | String | kube-19188-2306 | the ecosystem's identifier including a timestamp
55+
**in_ecosystem** | String | kube-19188-2306 | the ecosystem's identifier including a timestamp
4656

4757
## Alternate Module Inputs
4858

test-security.group/README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11

2-
# Test the AWS VPC Subnets Module
2+
# Integration Tests | Security Group Rules Terraform Module
33

4-
You can unit test the [[terraform-aws-vpc-subnets module]](https://github.com/devops-ip/terraform-aws-vpc-subnets) which **creates VPCs subnets in a round robin** manner.
4+
You can [run the integration tests](security.group-test.tf) that are biased towards creating security group rules.
55

6-
$ git clone https://github.com/devops-ip/test-vpc-subnets.git
7-
$ cd test-vpc-subnets
6+
So what happens at the core of the security group integration tests?
7+
8+
- a **VPC is provided** (or the default one is used)
9+
- a **security group is created** (or the default one for the VPC is used)
10+
- **ingress and egress rules are added to the security group**
11+
- the default source (and/or destination) of 0.0.0.0/0 is used
12+
- the rules can apply to specific supplied (source and/or destination) addresses
13+
14+
## How to Run the Integration Tests
15+
16+
$ git clone https://github.com/devops-ip/terraform-aws-security-group.git
17+
$ cd terraform-aws-security-group
818
$ terraform init .
919
$ terraform apply -auto-approve
1020
$ terraform destroy -auto-approve
1121

12-
## Unit Test Pre-Conditions
22+
## Integration Test Pre-Conditions
1323

1424
Check before you run the test that
1525

1626
- terraform and git are installed
1727
- you have created an AWS IAM user with VPC permissions
18-
- your [[AWS credentials have been installed]](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-credentials.html)
19-
- headroom exists for 10 more VPCs
20-
21-
## Extend the 5 VPC Limit
22-
23-
The default VPC limit is a pithy 5 and we need at least 10 to test all the functionality in this ubiquitous VPC/Subnet creation module.
28+
- your [AWS credentials have been installed](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-credentials.html)
29+
- headroom exists for a couple more (temporary) VPCs
2430

25-
On receiving your support ticket AWS automatically ups the VPC limit if you request 25 or less.

test-security.group/security.group-test.tf

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,37 @@
55

66
locals
77
{
8-
ecosystem_id = "vs-unittest"
8+
ecosystem_id = "sgrules-test"
9+
}
10+
11+
module vpc-subnets
12+
{
13+
source = "github.com/devops-ip/terraform-aws-vpc-subnets"
14+
in_vpc_cidr = "10.123.45.0/16"
15+
in_ecosystem = "${local.ecosystem_id}"
916
}
1017

1118
module zero-param-test
1219
{
13-
source = "github.com/devops-ip/terraform-aws-vpc-subnets"
20+
source = "github.com/devops-ip/terraform-aws-security-group
1421
}
1522
1623
module last-stable-release-test-0
1724
{
18-
source = "github.com/devops-ip/terraform-aws-vpc-subnets?ref=v0.1.0002"
19-
in_vpc_cidr = "10.234.56.0/24"
25+
source = "github.com/devops-ip/terraform-aws-security-group?ref=v0.1.0001"
26+
in_ingress = [ "ssh", "http", "https" ]
2027
in_ecosystem = "${local.ecosystem_id}-00"
2128
}
2229
23-
module vpc-subnets-test-1
30+
module security-group-test-1
2431
{
25-
source = "github.com/devops-ip/terraform-aws-vpc-subnets"
26-
version = "v0.1.0002"
27-
in_vpc_cidr = "10.234.0.0/16"
32+
source = "github.com/devops-ip/terraform-aws-security-group"
33+
version = "v0.1.0001"
34+
in_vpc_id = "${module.vpc-subnets.out_vpc_id}"
2835
in_ecosystem = "${local.ecosystem_id}-01"
2936
}
3037
38+
/*
3139
module vpc-subnets-test-2
3240
{
3341
source = "github.com/devops-ip/terraform-aws-vpc-subnets"
@@ -99,18 +107,12 @@ module vpc-subnets-test-9
99107
in_ecosystem = "${local.ecosystem_id}-09"
100108
}
101109
102-
output subnet_ids_1{ value = "${module.vpc-subnets-test-1.out_subnet_ids}" }
103-
output private_subnet_ids_1{ value = "${module.vpc-subnets-test-1.out_private_subnet_ids}" }
104-
output public_subnet_ids_1{ value = "${module.vpc-subnets-test-1.out_public_subnet_ids}" }
110+
*/
105111
106-
output subnet_ids_2{ value = "${module.vpc-subnets-test-6.out_subnet_ids}" }
107-
output private_subnet_ids_2{ value = "${module.vpc-subnets-test-6.out_private_subnet_ids}" }
108-
output public_subnet_ids_2{ value = "${module.vpc-subnets-test-6.out_public_subnet_ids}" }
109112
110-
output subnet_ids_3{ value = "${module.vpc-subnets-test-7.out_subnet_ids}" }
111-
output private_subnet_ids_3{ value = "${module.vpc-subnets-test-7.out_private_subnet_ids}" }
112-
output public_subnet_ids_3{ value = "${module.vpc-subnets-test-7.out_public_subnet_ids}" }
113+
output subnet_ids_1{ value = "${module.vpc-subnets.out_subnet_ids}" }
114+
output private_subnet_ids_1{ value = "${module.vpc-subnets.out_private_subnet_ids}" }
115+
output public_subnet_ids_1{ value = "${module.vpc-subnets.out_public_subnet_ids}" }
113116
114-
output subnet_ids_4{ value = "${module.vpc-subnets-test-9.out_subnet_ids}" }
115-
output private_subnet_ids_4{ value = "${module.vpc-subnets-test-9.out_private_subnet_ids}" }
116-
output public_subnet_ids_4{ value = "${module.vpc-subnets-test-9.out_public_subnet_ids}" }
117+
output security_group_id_1 { value = "${module.security-group-test-1.out_security_group_id}" }
118+
output security_group_ids_1{ value = "${module.security-group-test-1.out_security_group_ids}" }

0 commit comments

Comments
 (0)