Skip to content

Commit f38dd58

Browse files
author
Nikita Dugar
authored
Merge pull request #8 from clouddrove/CD-209
Upgrade terraform version to 0.13.0 and Update pipelines
2 parents 1c8ff53 + 4300fbd commit f38dd58

File tree

11 files changed

+195
-27
lines changed

11 files changed

+195
-27
lines changed

.github/workflows/readme.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 'Create README.md file'
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
jobs:
8+
readme-create:
9+
name: 'readme-create'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: 'Checkout'
13+
uses: actions/checkout@master
14+
15+
- name: Set up Python 3.7.
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: '3.x'
19+
20+
- name: 'create readme'
21+
uses: 'clouddrove/[email protected]'
22+
with:
23+
actions_subcommand: 'readme'
24+
github_token: '${{ secrets.GITHUB}}'
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
27+
28+
29+
- name: pre-commit check errors
30+
uses: pre-commit/[email protected]
31+
continue-on-error: true
32+
33+
- name: pre-commit fix erros
34+
uses: pre-commit/[email protected]
35+
continue-on-error: true
36+
37+
- name: 'push readme'
38+
uses: 'clouddrove/[email protected]'
39+
continue-on-error: true
40+
with:
41+
actions_subcommand: 'push'
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
44+
45+
- name: 'Slack Notification'
46+
uses: clouddrove/action-slack@v2
47+
with:
48+
status: ${{ job.status }}
49+
fields: repo,author
50+
author_name: 'CloudDrove'
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
53+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
54+
if: always()

.github/workflows/terraform.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 'Terraform GitHub Actions'
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
7+
jobs:
8+
terraform:
9+
name: 'Terraform'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: 'Checkout'
13+
uses: actions/checkout@master
14+
15+
- name: Configure AWS Credentials
16+
uses: clouddrove/configure-aws-credentials@v1
17+
with:
18+
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
19+
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
20+
aws-region: us-east-2
21+
22+
- name: 'Terraform Format'
23+
uses: 'clouddrove/[email protected]'
24+
with:
25+
actions_subcommand: 'fmt'
26+
27+
- name: 'Terraform init'
28+
uses: 'clouddrove/[email protected]'
29+
with:
30+
actions_subcommand: 'init'
31+
tf_actions_working_dir: ./_example/basic
32+
33+
- name: 'Terraform validate'
34+
uses: 'clouddrove/[email protected]'
35+
with:
36+
actions_subcommand: 'validate'
37+
tf_actions_working_dir: ./_example/basic
38+
39+
- name: 'Terraform plan'
40+
uses: 'clouddrove/[email protected]'
41+
with:
42+
actions_subcommand: 'plan'
43+
tf_actions_working_dir: ./_example/basic
44+
45+
- name: 'Slack Notification'
46+
uses: clouddrove/action-slack@v2
47+
with:
48+
status: ${{ job.status }}
49+
fields: repo,author
50+
author_name: 'CloudDrove'
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
53+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
54+
if: always()

.github/workflows/terratest.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: 'Terratest GitHub Actions'
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
types: [labeled]
7+
8+
jobs:
9+
terraform:
10+
name: 'Terraform'
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- name: 'Checkout'
15+
uses: actions/checkout@master
16+
17+
- name: Configure AWS Credentials
18+
uses: clouddrove/configure-aws-credentials@v1
19+
with:
20+
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
21+
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
22+
aws-region: us-east-2
23+
24+
- name: 'Terratest'
25+
if: ${{ github.event.label.name == 'terratest' }}
26+
uses: 'clouddrove/[email protected]'
27+
with:
28+
actions_subcommand: 'terratest'
29+
tf_actions_working_dir: '_test/basic'
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: 'Slack Notification'
34+
uses: clouddrove/action-slack@v2
35+
with:
36+
status: ${{ job.status }}
37+
fields: repo,author
38+
author_name: 'CloudDrove'
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
41+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
42+
if: always()

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
*.tfstate.backup
44
.terraform
55
.idea
6-
*.iml
6+
*.iml
7+
go.sum

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
repos:
22
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.12.0
3+
rev: v1.43.0
44
hooks:
55
- id: terraform_fmt
66

77
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v2.0.0
8+
rev: v3.2.0
99
hooks:
1010
- id: check-merge-conflict
11-
- id: trailing-whitespace
1211
- id: check-yaml
1312
- id: check-added-large-files
13+
- id: trailing-whitespace

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Cloud Drove
3+
Copyright (c) 2020 Cloud Drove
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.yaml

+10-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66

77
# Name of this project
8-
name : Terraform AWS Api Gateway
8+
name: Terraform AWS Api Gateway
99

1010
# License of this project
1111
license: "MIT"
@@ -16,13 +16,14 @@ github_repo: clouddrove/terraform-aws-api-gateway
1616
# Badges to display
1717
badges:
1818
- name: "Terraform"
19-
image: "https://img.shields.io/badge/Terraform-v0.12-green"
19+
image: "https://img.shields.io/badge/Terraform-v0.13-green"
2020
url: "https://www.terraform.io"
2121
- name: "Licence"
2222
image: "https://img.shields.io/badge/License-MIT-blue.svg"
2323
url: "LICENSE.md"
2424

2525
# description of this project
26+
# yamllint disable rule:line-length
2627
description: |-
2728
Terraform module to create Route53 resource on AWS for create api gateway with it's basic elements.
2829
@@ -32,12 +33,14 @@ include:
3233
- "terraform.md"
3334

3435
# How to use this project
35-
usage : |-
36+
# yamllint disable rule:line-length
37+
usage: |-
3638
Here are examples of how you can use this module in your inventory structure:
3739
### Basic Example
3840
```hcl
3941
module "api-gateway" {
40-
source = "git::https://github.com/clouddrove/terraform-aws-api-gateway.git?ref=tags/0.12.2"
42+
source = "clouddrove/api-gateway/aws"
43+
version = "0.13.0"
4144
name = "api-gateway"
4245
application = "clouddrove"
4346
environment = "test"
@@ -95,7 +98,8 @@ usage : |-
9598
### Complete Example
9699
```hcl
97100
module "api-gateway" {
98-
source = "git::https://github.com/clouddrove/terraform-aws-api-gateway.git?ref=tags/0.12.2"
101+
source = "clouddrove/api-gateway/aws"
102+
version = "0.13.0"
99103
name = "api-gateway"
100104
application = "clouddrove"
101105
environment = "test"
@@ -176,4 +180,4 @@ usage : |-
176180
key_count = 2
177181
key_names = ["test", "test1"]
178182
}
179-
```
183+
```

_example/basic/example.tf

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,34 @@ module "api-gateway" {
1111
enabled = true
1212

1313
# Api Gateway Resource
14-
path_parts = ["mytestresource", "mytestresource1"]
14+
path_parts = ["mytestresource"]
1515

1616
# Api Gateway Method
1717
method_enabled = true
18-
http_methods = ["GET", "GET"]
18+
http_methods = ["GET"]
1919

2020
# 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"]
21+
integration_types = ["MOCK"]
22+
integration_http_methods = ["POST"]
23+
uri = [""]
2424
integration_request_parameters = [{
2525
"integration.request.header.X-Authorization" = "'static'"
26-
}, {}]
26+
}]
2727
request_templates = [{
2828
"application/xml" = <<EOF
2929
{
3030
"body" : $input.json('$')
3131
}
3232
EOF
33-
}, {}]
33+
}]
3434

3535
# 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 }, {}]
36+
status_codes = [200]
37+
response_models = [{ "application/json" = "Empty" }]
38+
response_parameters = [{ "method.response.header.X-Some-Header" = true }]
3939

4040
# Api Gateway Integration Response
41-
integration_response_parameters = [{ "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }, {}]
41+
integration_response_parameters = [{ "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }]
4242
response_templates = [{
4343
"application/xml" = <<EOF
4444
#set($inputRoot = $input.path('$'))
@@ -47,13 +47,13 @@ EOF
4747
$inputRoot.body
4848
</message>
4949
EOF
50-
}, {}]
50+
}]
5151

5252
# Api Gateway Deployment
5353
deployment_enabled = true
5454
stage_name = "deploy"
5555

5656
# Api Gateway Stage
5757
stage_enabled = true
58-
stage_names = ["qa", "dev"]
58+
stage_names = ["qa"]
5959
}

_test/basic/go.mod

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module github.com/clouddrove-terraform-aws-api-gateway/basic
2+
3+
go 1.13
4+
5+
require (
6+
github.com/gruntwork-io/terratest v0.30.7
7+
github.com/stretchr/testify v1.6.1
8+
)

main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# for resources. You can use terraform-labels to implement a strict naming
77
# convention.
88
module "labels" {
9-
source = "git::https://github.com/clouddrove/terraform-labels.git?ref=tags/0.12.0"
9+
source = "git::https://github.com/clouddrove/terraform-labels.git?ref=tags/0.13.0"
1010

1111
name = var.name
1212
application = var.application
@@ -16,7 +16,7 @@ module "labels" {
1616
}
1717

1818
# Module : Api Gateway
19-
# Description : Terraform module to create Api Gateway resource on AWS for creating api.
19+
# Description : Terraform module to create Api Gateway resource on AWS for creatng api.
2020
resource "aws_api_gateway_rest_api" "default" {
2121
count = var.enabled ? 1 : 0
2222

versions.tf

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Terraform version
22
terraform {
3-
required_version = ">= 0.12"
3+
required_version = ">= 0.12.0, < 0.14.0"
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
}
8+
}
49
}

0 commit comments

Comments
 (0)