Skip to content

Commit bfb61af

Browse files
author
Nikita Dugar
committed
initial commit
0 parents  commit bfb61af

File tree

16 files changed

+1584
-0
lines changed

16 files changed

+1584
-0
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: 354 additions & 0 deletions
Large diffs are not rendered by default.

README.yaml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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 Api Gateway
9+
10+
# License of this project
11+
license: "MIT"
12+
13+
# Canonical GitHub repo
14+
github_repo: clouddrove/terraform-aws-api-gateway
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+
Terraform module to create Route53 resource on AWS for create api gateway with it's basic elements.
28+
29+
# extra content
30+
# please not remove these two If you need add more
31+
include:
32+
- "terraform.md"
33+
34+
# How to use this project
35+
usage : |-
36+
Here are examples of how you can use this module in your inventory structure:
37+
### Basic Example
38+
```hcl
39+
module "api-gateway" {
40+
source = "git::https://github.com/clouddrove/terraform-aws-api-gateway.git?ref=tags/0.12.0"
41+
name = "api-gateway"
42+
application = "clouddrove"
43+
environment = "test"
44+
label_order = ["environment", "name", "application"]
45+
enabled = true
46+
47+
# Api Gateway Resource
48+
path_parts = ["mytestresource", "mytestresource1"]
49+
50+
# Api Gateway Method
51+
method_enabled = true
52+
http_methods = ["GET", "GET"]
53+
54+
# Api Gateway Integration
55+
integration_types = ["MOCK", "AWS_PROXY"]
56+
integration_http_methods = ["POST", "POST"]
57+
uri = ["", "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations"]
58+
integration_request_parameters = [{
59+
"integration.request.header.X-Authorization" = "'static'"
60+
}, {}]
61+
request_templates = [{
62+
"application/xml" = <<EOF
63+
{
64+
"body" : $input.json('$')
65+
}
66+
EOF
67+
}, {}]
68+
69+
# Api Gateway Method Response
70+
status_codes = [200, 200]
71+
response_models = [{ "application/json" = "Empty" }, {}]
72+
response_parameters = [{ "method.response.header.X-Some-Header" = true }, {}]
73+
74+
# Api Gateway Integration Response
75+
integration_response_parameters = [{ "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }, {}]
76+
response_templates = [{
77+
"application/xml" = <<EOF
78+
#set($inputRoot = $input.path('$'))
79+
<?xml version="1.0" encoding="UTF-8"?>
80+
<message>
81+
$inputRoot.body
82+
</message>
83+
EOF
84+
}, {}]
85+
86+
# Api Gateway Deployment
87+
deployment_enabled = true
88+
stage_name = "deploy"
89+
90+
# Api Gateway Stage
91+
stage_enabled = true
92+
stage_names = ["qa", "dev"]
93+
}
94+
```
95+
### Complete Example
96+
```hcl
97+
module "api-gateway" {
98+
source = "git::https://github.com/clouddrove/terraform-aws-api-gateway.git?ref=tags/0.12.0"
99+
name = "api-gateway"
100+
application = "clouddrove"
101+
environment = "test"
102+
label_order = ["environment", "name", "application"]
103+
enabled = true
104+
105+
# Api Gateway Resource
106+
path_parts = ["mytestresource", "mytestresource1"]
107+
108+
# Api Gateway Method
109+
method_enabled = true
110+
http_methods = ["GET", "GET"]
111+
112+
# Api Gateway Integration
113+
integration_types = ["MOCK", "AWS_PROXY"]
114+
integration_http_methods = ["POST", "POST"]
115+
uri = ["", "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations"]
116+
integration_request_parameters = [{
117+
"integration.request.header.X-Authorization" = "'static'"
118+
}, {}]
119+
request_templates = [{
120+
"application/xml" = <<EOF
121+
{
122+
"body" : $input.json('$')
123+
}
124+
EOF
125+
}, {}]
126+
127+
# Api Gateway Method Response
128+
status_codes = [200, 200]
129+
response_models = [{ "application/json" = "Empty" }, {}]
130+
response_parameters = [{ "method.response.header.X-Some-Header" = true }, {}]
131+
132+
# Api Gateway Integration Response
133+
integration_response_parameters = [{ "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }, {}]
134+
response_templates = [{
135+
"application/xml" = <<EOF
136+
#set($inputRoot = $input.path('$'))
137+
<?xml version="1.0" encoding="UTF-8"?>
138+
<message>
139+
$inputRoot.body
140+
</message>
141+
EOF
142+
}, {}]
143+
144+
# Api Gateway Deployment
145+
deployment_enabled = true
146+
stage_name = "deploy"
147+
148+
# Api Gateway Stage
149+
stage_enabled = true
150+
stage_names = ["qa", "dev"]
151+
152+
# Api Gateway Client Certificate
153+
cert_enabled = true
154+
cert_description = "clouddrove"
155+
156+
# Api Gateway Authorizer
157+
authorizer_count = 2
158+
authorizer_names = ["test", "test1"]
159+
authorizer_uri = ["arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations", "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations"]
160+
authorizer_credentials = ["arn:aws:iam::xxxxxxxxxx:role/lambda-role", "arn:aws:iam::xxxxxxxxxx:role/lambda-role"]
161+
identity_sources = ["method.request.header.Authorization", "method.request.header.Authorization"]
162+
identity_validation_expressions = ["sfdgfhghrfdsdas", ""]
163+
authorizer_types = ["TOKEN", "REQUEST"]
164+
165+
# Api Gateway Gateway Response
166+
gateway_response_count = 2
167+
response_types = ["UNAUTHORIZED", "RESOURCE_NOT_FOUND"]
168+
gateway_status_codes = ["401", "404"]
169+
170+
# Api Gateway Model
171+
model_count = 2
172+
model_names = ["test", "test1"]
173+
content_types = ["application/json", "application/json"]
174+
175+
# Api Gateway Api Key
176+
key_count = 2
177+
key_names = ["test", "test1"]
178+
}
179+
```

_example/basic/example.tf

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
provider "aws" {
2+
region = "eu-west-1"
3+
}
4+
5+
module "api-gateway" {
6+
source = "git::https://github.com/clouddrove/terraform-aws-api-gateway.git?ref=tags/0.12.0"
7+
name = "api-gateway"
8+
application = "clouddrove"
9+
environment = "test"
10+
label_order = ["environment", "name", "application"]
11+
enabled = true
12+
13+
# Api Gateway Resource
14+
path_parts = ["mytestresource", "mytestresource1"]
15+
16+
# Api Gateway Method
17+
method_enabled = true
18+
http_methods = ["GET", "GET"]
19+
20+
# Api Gateway Integration
21+
integration_types = ["MOCK", "AWS_PROXY"]
22+
integration_http_methods = ["POST", "POST"]
23+
uri = ["", "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxxxx:function:test/invocations"]
24+
integration_request_parameters = [{
25+
"integration.request.header.X-Authorization" = "'static'"
26+
}, {}]
27+
request_templates = [{
28+
"application/xml" = <<EOF
29+
{
30+
"body" : $input.json('$')
31+
}
32+
EOF
33+
}, {}]
34+
35+
# Api Gateway Method Response
36+
status_codes = [200, 200]
37+
response_models = [{ "application/json" = "Empty" }, {}]
38+
response_parameters = [{ "method.response.header.X-Some-Header" = true }, {}]
39+
40+
# Api Gateway Integration Response
41+
integration_response_parameters = [{ "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }, {}]
42+
response_templates = [{
43+
"application/xml" = <<EOF
44+
#set($inputRoot = $input.path('$'))
45+
<?xml version="1.0" encoding="UTF-8"?>
46+
<message>
47+
$inputRoot.body
48+
</message>
49+
EOF
50+
}, {}]
51+
52+
# Api Gateway Deployment
53+
deployment_enabled = true
54+
stage_name = "deploy"
55+
56+
# Api Gateway Stage
57+
stage_enabled = true
58+
stage_names = ["qa", "dev"]
59+
}

_example/basic/outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Module : Route53
2+
# Description : Terraform module to create Route53 resource on AWS for managing queue.
3+
output "arn" {
4+
value = module.api-gateway.*.execution_arn
5+
description = "The Execution ARN of the REST API."
6+
}

_example/complete/example.tf

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
provider "aws" {
2+
region = "eu-west-1"
3+
}
4+
5+
module "api-gateway" {
6+
source = "git::https://github.com/clouddrove/terraform-aws-api-gateway.git?ref=tags/0.12.0"
7+
8+
name = "api-gateway"
9+
application = "clouddrove"
10+
environment = "test"
11+
label_order = ["environment", "name", "application"]
12+
enabled = true
13+
14+
# Api Gateway Resource
15+
path_parts = ["mytestresource", "mytestresource1"]
16+
17+
# Api Gateway Method
18+
method_enabled = true
19+
http_methods = ["GET", "GET"]
20+
21+
# Api Gateway Integration
22+
integration_types = ["MOCK", "AWS_PROXY"]
23+
integration_http_methods = ["POST", "POST"]
24+
uri = ["", "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations"]
25+
integration_request_parameters = [{
26+
"integration.request.header.X-Authorization" = "'static'"
27+
}, {}]
28+
request_templates = [{
29+
"application/xml" = <<EOF
30+
{
31+
"body" : $input.json('$')
32+
}
33+
EOF
34+
}, {}]
35+
36+
# Api Gateway Method Response
37+
status_codes = [200, 200]
38+
response_models = [{ "application/json" = "Empty" }, {}]
39+
response_parameters = [{ "method.response.header.X-Some-Header" = true }, {}]
40+
41+
# Api Gateway Integration Response
42+
integration_response_parameters = [{ "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }, {}]
43+
response_templates = [{
44+
"application/xml" = <<EOF
45+
#set($inputRoot = $input.path('$'))
46+
<?xml version="1.0" encoding="UTF-8"?>
47+
<message>
48+
$inputRoot.body
49+
</message>
50+
EOF
51+
}, {}]
52+
53+
# Api Gateway Deployment
54+
deployment_enabled = true
55+
stage_name = "deploy"
56+
57+
# Api Gateway Stage
58+
stage_enabled = true
59+
stage_names = ["qa", "dev"]
60+
61+
# Api Gateway Client Certificate
62+
cert_enabled = true
63+
cert_description = "clouddrove"
64+
65+
# Api Gateway Authorizer
66+
authorizer_count = 2
67+
authorizer_names = ["test", "test1"]
68+
authorizer_uri = ["arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations", "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations"]
69+
authorizer_credentials = ["arn:aws:iam::xxxxxxxxxx:role/lambda-role", "arn:aws:iam::xxxxxxxxxx:role/lambda-role"]
70+
identity_sources = ["method.request.header.Authorization", "method.request.header.Authorization"]
71+
identity_validation_expressions = ["sfdgfhghrfdsdas", ""]
72+
authorizer_types = ["TOKEN", "REQUEST"]
73+
74+
# Api Gateway Gateway Response
75+
gateway_response_count = 2
76+
response_types = ["UNAUTHORIZED", "RESOURCE_NOT_FOUND"]
77+
gateway_status_codes = ["401", "404"]
78+
79+
# Api Gateway Model
80+
model_count = 2
81+
model_names = ["test", "test1"]
82+
content_types = ["application/json", "application/json"]
83+
84+
# Api Gateway Api Key
85+
key_count = 2
86+
key_names = ["test", "test1"]
87+
}

_example/complete/outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Module : Route53
2+
# Description : Terraform module to create Route53 resource on AWS for managing queue.
3+
output "arn" {
4+
value = module.api-gateway.*.execution_arn
5+
description = "The Execution ARN of the REST API."
6+
}

0 commit comments

Comments
 (0)