Skip to content

Commit 57314ae

Browse files
author
Kamlesh
committed
terraform 0.12.0
1 parent 1a9f6be commit 57314ae

File tree

14 files changed

+381
-64
lines changed

14 files changed

+381
-64
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ignored files
2+
*.tfstate
3+
*.tfstate.backup
4+
.terraform
5+
.idea
6+
*.iml

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
repos:
2+
- repo: git://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.12.0
4+
hooks:
5+
- id: terraform_fmt
6+
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v2.0.0
9+
hooks:
10+
- id: check-merge-conflict
11+
- id: trailing-whitespace
12+
- id: check-yaml
13+
- id: check-added-large-files

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Cloud Drove
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export GENIE_PATH ?= $(shell 'pwd')/../../../genie
2+
3+
include $(GENIE_PATH)/Makefile

README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,120 @@
1+
<!-- This file was automatically generated by the `geine`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->
12

23

4+
<h1 align="center">
5+
Terraform AWS Security Group
6+
</h1>
7+
8+
<p align="center" style="font-size: 1.2rem;">
9+
This terraform module creates set of Security Group and Security Group Rules resources in various combinations.
10+
</p>
11+
12+
<p align="center">
13+
14+
<a href="https://www.terraform.io">
15+
<img src="https://img.shields.io/badge/Terraform-v0.12-green" alt="Terraform">
16+
</a>
17+
<a href="LICENSE.md">
18+
<img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="Licence">
19+
</a>
20+
21+
22+
</p>
23+
<p align="center">
24+
25+
<a href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/terraform-aws-security-group'>
26+
<img title="Share on Facebook" src="https://user-images.githubusercontent.com/50652676/62817743-4f64cb80-bb59-11e9-90c7-b057252ded50.png" />
27+
</a>
28+
<a href='https://www.linkedin.com/shareArticle?mini=true&title=Terraform+AWS+Security+Group&url=https://github.com/clouddrove/terraform-aws-security-group'>
29+
<img title="Share on LinkedIn" src="https://user-images.githubusercontent.com/50652676/62817742-4e339e80-bb59-11e9-87b9-a1f68cae1049.png" />
30+
</a>
31+
<a href='https://twitter.com/intent/tweet/?text=Terraform+AWS+Security+Group&url=https://github.com/clouddrove/terraform-aws-security-group'>
32+
<img title="Share on Twitter" src="https://user-images.githubusercontent.com/50652676/62817740-4c69db00-bb59-11e9-8a79-3580fbbf6d5c.png" />
33+
</a>
34+
35+
</p>
36+
<hr>
37+
38+
39+
40+
41+
42+
## Prerequisites
43+
44+
This module has a few dependencies:
45+
46+
47+
48+
49+
50+
51+
## Examples
52+
53+
**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-aws-security-group/releases).
54+
55+
56+
### Simple Example
57+
Here is an example of how you can use this module in your inventory structure:
58+
```hcl
59+
module "security_group" {
60+
source = "git::https://github.com/clouddrove/terraform-aws-security-group.git"
61+
name = "security-group"
62+
application = "clouddrove"
63+
environment = "test"
64+
label_order = ["environment", "name", "application"]
65+
vpc_id = "vpc-xxxxxxxxx"
66+
allowed_ip = ["172.16.0.0/16", "10.0.0.0/16"]
67+
allowed_ports = [22, 27017]
68+
}
69+
```
70+
71+
72+
73+
## Inputs
74+
75+
| Name | Description | Type | Default | Required |
76+
|------|-------------|:----:|:-----:|:-----:|
77+
| allowed_ip | List of allowed ip. | list | `<list>` | no |
78+
| allowed_ports | List of allowed ingress ports. | list | `<list>` | no |
79+
| application | Application (e.g. `cd` or `clouddrove`). | string | `` | no |
80+
| description | The security group description. | string | `Instance default security group (only egress access is allowed).` | no |
81+
| enable_security_group | Enable default Security Group with only Egress traffic allowed. | bool | `true` | no |
82+
| environment | Environment (e.g. `prod`, `dev`, `staging`). | string | `` | no |
83+
| label_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
84+
| name | Name (e.g. `app` or `cluster`). | string | `` | no |
85+
| security_groups | List of Security Group IDs allowed to connect to the instance. | list | `<list>` | no |
86+
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`). | map(string) | `<map>` | no |
87+
| vpc_id | The ID of the VPC that the instance security group belongs to. | string | `` | no |
88+
89+
## Outputs
90+
91+
| Name | Description |
92+
|------|-------------|
93+
| security_group_ids | IDs on the AWS Security Groups associated with the instance. |
94+
| tags | A mapping of public tags to assign to the resource. |
95+
96+
97+
98+
## Testing
99+
100+
101+
102+
## Feedback
103+
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-aws-security-group/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com).
104+
105+
If you have found it worth your time, go ahead and give us a * on [our GitHub](https://github.com/clouddrove/terraform-aws-security-group)!
106+
107+
## About us
108+
109+
At [CloudDrove][website], we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.
110+
111+
<p align="center">We are <b> The Cloud Experts!</b></p>
112+
<hr />
113+
<p align="center">We ❤️ <a href="https://github.com/clouddrove">Open Source</a> and you can check out <a href="https://github.com/clouddrove">our other modules</a> to get help with your new Cloud ideas.</p>
114+
115+
[website]: https://clouddrove.com
116+
[github]: https://github.com/clouddrove
117+
[linkedin]: https://cpco.io/linkedin
118+
[twitter]: https://twitter.com/clouddrove/
119+
[email]: https://clouddrove.com/contact-us.html
120+
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=

README.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
#
3+
# This is the canonical configuration for the `README.md`
4+
# Run `make readme` to rebuild the `README.md`
5+
#
6+
7+
# Name of this project
8+
name : Terraform AWS Security Group
9+
10+
# License of this project
11+
license: "MIT"
12+
13+
# Canonical GitHub repo
14+
github_repo: clouddrove/terraform-aws-security-group
15+
16+
# Badges to display
17+
badges:
18+
- name: "Terraform"
19+
image: "https://img.shields.io/badge/Terraform-v0.12-green"
20+
url: "https://www.terraform.io"
21+
- name: "Licence"
22+
image: "https://img.shields.io/badge/License-MIT-blue.svg"
23+
url: "LICENSE.md"
24+
25+
# description of this project
26+
description: |-
27+
This terraform module creates set of Security Group and Security Group Rules resources in various combinations.
28+
29+
# extra content
30+
include:
31+
- "terraform.md"
32+
33+
# How to use this project
34+
usage : |-
35+
### Simple Example
36+
Here is an example of how you can use this module in your inventory structure:
37+
```hcl
38+
module "security_group" {
39+
source = "git::https://github.com/clouddrove/terraform-aws-security-group.git"
40+
name = "security-group"
41+
application = "clouddrove"
42+
environment = "test"
43+
label_order = ["environment", "name", "application"]
44+
vpc_id = "vpc-xxxxxxxxx"
45+
allowed_ip = ["172.16.0.0/16", "10.0.0.0/16"]
46+
allowed_ports = [22, 27017]
47+
}
48+
```

_example/example.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
provider "aws" {
2+
region = "eu-west-1"
3+
}
4+
5+
module "vpc" {
6+
source = "git::https://github.com/clouddrove/terraform-aws-vpc.git"
7+
8+
name = "vpc"
9+
application = "clouddrove"
10+
environment = "test"
11+
label_order = ["environment", "name", "application"]
12+
13+
cidr_block = "10.0.0.0/16"
14+
}
15+
16+
module "security_group" {
17+
source = "git::https://github.com/clouddrove/terraform-aws-security-group.git"
18+
19+
name = "security-group"
20+
application = "clouddrove"
21+
environment = "test"
22+
label_order = ["environment", "name", "application"]
23+
24+
vpc_id = module.vpc.vpc_id
25+
description = "Instance default security group (only egress access is allowed)."
26+
allowed_ip = ["172.16.0.0/16", "10.0.0.0/16"]
27+
allowed_ports = [22, 27017]
28+
}

_example/outputs.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "tags" {
2+
value = module.security_group.tags
3+
description = "A mapping of tags to assign to the resource."
4+
}
5+
6+
output "security_group_ids" {
7+
value = module.security_group.security_group_ids
8+
description = "A mapping of security group ids."
9+
}

_test/securitygroup_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Managed By : CloudDrove
2+
// Description : This Terratest is used to test the Terraform VPC module.
3+
// Copyright @ CloudDrove. All Right Reserved.
4+
package test
5+
6+
import (
7+
"testing"
8+
"github.com/stretchr/testify/assert"
9+
"github.com/gruntwork-io/terratest/modules/terraform"
10+
)
11+
12+
func Test(t *testing.T) {
13+
t.Parallel()
14+
15+
terraformOptions := &terraform.Options{
16+
// Source path of Terraform directory.
17+
TerraformDir: "../_example",
18+
Upgrade: true,
19+
}
20+
21+
// This will run 'terraform init' and 'terraform application' and will fail the test if any errors occur
22+
terraform.InitAndApply(t, terraformOptions)
23+
24+
// To clean up any resources that have been created, run 'terraform destroy' towards the end of the test
25+
defer terraform.Destroy(t, terraformOptions)
26+
27+
// To get the value of an output variable, run 'terraform output'
28+
Id := terraform.Output(t, terraformOptions, "security_group_ids")
29+
Tags := terraform.OutputMap(t, terraformOptions, "tags")
30+
31+
// Check that we get back the outputs that we expect
32+
assert.Equal(t, "test-security-group-clouddrove", Tags["Name"])
33+
assert.Contains(t, Id, "sg-")
34+
}

example/example.tf

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)