Skip to content

Commit 2f6b9f8

Browse files
Sohananmolnagpal
Sohan
authored andcommitted
github action (#8)
* github action * github action * github action * github action
1 parent c4b7ff7 commit 2f6b9f8

File tree

7 files changed

+125
-26
lines changed

7 files changed

+125
-26
lines changed

.github/workflows/terraform.yml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: 'Terraform GitHub Actions'
2+
on:
3+
- pull_request
4+
5+
jobs:
6+
terraform:
7+
name: 'Terraform'
8+
runs-on: ubuntu-latest
9+
steps:
10+
11+
- name: 'Checkout'
12+
uses: actions/checkout@master
13+
14+
- name: 'Terraform Format'
15+
uses: clouddrove/github-actions@v2.0
16+
with:
17+
actions_subcommand: 'fmt'
18+
19+
- name: 'Terraform Init APNS complete'
20+
uses: clouddrove/github-actions@v2.0
21+
with:
22+
actions_subcommand: 'init'
23+
tf_actions_working_dir: ./_example/APNS/complete
24+
25+
- name: 'Terraform Init APNS basic'
26+
uses: clouddrove/github-actions@v2.0
27+
with:
28+
actions_subcommand: 'init'
29+
tf_actions_working_dir: ./_example/APNS/basic
30+
31+
- name: 'Terraform Init GCM'
32+
uses: clouddrove/github-actions@v2.0
33+
with:
34+
actions_subcommand: 'init'
35+
tf_actions_working_dir: ./_example/GCM
36+
37+
38+
- name: Configure AWS Credentials
39+
uses: clouddrove/configure-aws-credentials@v1
40+
with:
41+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
42+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
43+
aws-region: us-east-2
44+
45+
- name: 'Terraform Plan For APNS complete'
46+
uses: clouddrove/github-actions@v2.0
47+
with:
48+
actions_subcommand: 'plan'
49+
tf_actions_working_dir: ./_example/APNS/complete
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: 'Terraform Plan For APNS basic'
54+
uses: clouddrove/github-actions@v2.0
55+
with:
56+
actions_subcommand: 'plan'
57+
tf_actions_working_dir: ./_example/APNS/basic
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
61+
- name: 'Terraform For Plan GCM'
62+
uses: clouddrove/github-actions@v2.0
63+
with:
64+
actions_subcommand: 'plan'
65+
tf_actions_working_dir: ./_example/GCM
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
69+
- name: 'Terratest For APNS complete'
70+
uses: clouddrove/github-actions@v2.0
71+
with:
72+
actions_subcommand: 'terratest'
73+
tf_actions_working_dir: ./_test/APNS/complete
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: 'Terratest For APNS basic'
78+
uses: clouddrove/github-actions@v2.0
79+
with:
80+
actions_subcommand: 'terratest'
81+
tf_actions_working_dir: ./_test/APNS/basic
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
85+
- name: 'Slack Notification'
86+
uses: clouddrove/action-slack@v2
87+
with:
88+
status: ${{ job.status }}
89+
fields: repo,author
90+
author_name: 'Clouddrove'
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
93+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required
94+
if: always()

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ Here are some examples of how you can use this module in your inventory structur
7171
#### Basic
7272
```hcl
7373
module "sns" {
74-
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.0"
74+
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.1"
7575
name = "basic-sns"
7676
application = "clouddrove"
7777
environment = "test"
78-
label_order = ["environment", "name", "application"]
78+
label_order = ["environment", "application", "name"]
7979
platform = "APNS"
8080
key = "../../certificates/private_key.pem"
8181
certificate = "../../certificates/cert.pem"
@@ -84,11 +84,11 @@ Here are some examples of how you can use this module in your inventory structur
8484
#### Complete
8585
```hcl
8686
module "sns" {
87-
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.0"
87+
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.1"
8888
name = "sns"
8989
application = "clouddrove"
9090
environment = "test"
91-
label_order = ["environment", "name", "application"]
91+
label_order = ["environment", "application", "name"]
9292
platform = "APNS"
9393
key = file("../../certificates/private_key.pem")
9494
certificate = file("../../certificates/cert.pem")
@@ -138,11 +138,11 @@ Here are some examples of how you can use this module in your inventory structur
138138
### GCM
139139
```hcl
140140
module "sns" {
141-
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.0"
141+
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.1"
142142
name = "sqs"
143143
application = "clouddrove"
144144
environment = "test"
145-
label_order = ["environment", "name", "application"]
145+
label_order = ["environment", "application", "name"]
146146
platform = "GCM"
147147
key = "AAAAKHQaqe1w:APA91bEgwftAYq6N2YV8TeU2k4bRj0k1q2I7Q47ZvFPLQm-ESbD2Fhjj3U9wNNuZ2aC-QZVdgDrN5C6E3Ec08AWhMgbs4b72gNvqcXh1JBoR6yLwretghyjutTR4yRmT0vWdhz4_PW1AwDC0aVoH"
148148
}

README.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ usage : |-
3838
#### Basic
3939
```hcl
4040
module "sns" {
41-
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.0"
41+
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.1"
4242
name = "basic-sns"
4343
application = "clouddrove"
4444
environment = "test"
45-
label_order = ["environment", "name", "application"]
45+
label_order = ["environment", "application", "name"]
4646
platform = "APNS"
4747
key = "../../certificates/private_key.pem"
4848
certificate = "../../certificates/cert.pem"
@@ -51,11 +51,11 @@ usage : |-
5151
#### Complete
5252
```hcl
5353
module "sns" {
54-
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.0"
54+
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.1"
5555
name = "sns"
5656
application = "clouddrove"
5757
environment = "test"
58-
label_order = ["environment", "name", "application"]
58+
label_order = ["environment", "application", "name"]
5959
platform = "APNS"
6060
key = file("../../certificates/private_key.pem")
6161
certificate = file("../../certificates/cert.pem")
@@ -105,11 +105,11 @@ usage : |-
105105
### GCM
106106
```hcl
107107
module "sns" {
108-
source = "git::https://github.com/clouddrove/terraform-aws-sns.git"
108+
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.1"
109109
name = "sqs"
110110
application = "clouddrove"
111111
environment = "test"
112-
label_order = ["environment", "name", "application"]
112+
label_order = ["environment", "application", "name"]
113113
platform = "GCM"
114114
key = "AAAAKHQaqe1w:APA91bEgwftAYq6N2YV8TeU2k4bRj0k1q2I7Q47ZvFPLQm-ESbD2Fhjj3U9wNNuZ2aC-QZVdgDrN5C6E3Ec08AWhMgbs4b72gNvqcXh1JBoR6yLwretghyjutTR4yRmT0vWdhz4_PW1AwDC0aVoH"
115115
}

_example/APNS/basic/example.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ provider "aws" {
33
}
44

55
module "sns" {
6-
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.0"
6+
source = "./../../../"
77

88
name = "basic-sns"
99
application = "clouddrove"
1010
environment = "test"
11-
label_order = ["environment", "name", "application"]
11+
label_order = ["environment", "application", "name"]
1212

1313
platform = "APNS"
1414
key = "../../certificates/private_key.pem"

_example/APNS/complete/example.tf

+13-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ provider "aws" {
22
region = "eu-west-1"
33
}
44

5+
data "aws_caller_identity" "current" {}
6+
7+
58
module "sqs" {
6-
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.0"
9+
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.2"
710

811
name = "sqs"
912
application = "clouddrove"
1013
environment = "test"
11-
label_order = ["environment", "name", "application"]
14+
label_order = ["environment", "application", "name"]
1215

1316
delay_seconds = 90
1417
max_message_size = 2048
@@ -26,18 +29,20 @@ data "aws_iam_policy_document" "document" {
2629
type = "AWS"
2730
identifiers = ["*"]
2831
}
29-
actions = ["sqs:SendMessage"]
30-
resources = ["arn:aws:sqs:eu-west-1:866067750630:test-sqs-clouddrove"]
32+
actions = ["sqs:SendMessage"]
33+
resources = [
34+
format("arn:aws:sqs:eu-west-1:%s:test-clouddrove-sqs", data.aws_caller_identity.current.account_id)
35+
]
3136
}
3237
}
3338

3439
module "sns" {
35-
source = "git::https://github.com/clouddrove/terraform-aws-sns.git"
40+
source = "./../../../"
3641

3742
name = "sns"
3843
application = "clouddrove"
3944
environment = "test"
40-
label_order = ["environment", "name", "application"]
45+
label_order = ["environment", "application", "name"]
4146

4247
platform = "APNS"
4348
enable_sms_preference = true
@@ -70,7 +75,7 @@ data "aws_iam_policy_document" "sns-topic-policy" {
7075
variable = "AWS:SourceOwner"
7176

7277
values = [
73-
866067750630,
78+
data.aws_caller_identity.current.account_id,
7479
]
7580
}
7681
effect = "Allow"
@@ -79,7 +84,7 @@ data "aws_iam_policy_document" "sns-topic-policy" {
7984
identifiers = ["*"]
8085
}
8186
resources = [
82-
"arn:aws:sns:eu-west-1:866067750630:app/APNS/test-sns-clouddrove",
87+
format("arn:aws:sns:eu-west-1:%s:app/APNS/test-clouddrove-sns", data.aws_caller_identity.current.account_id)
8388
]
8489
sid = "__default_statement_ID"
8590
}

_example/GCM/example.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ provider "aws" {
33
}
44

55
module "sns" {
6-
source = "git::https://github.com/clouddrove/terraform-aws-sns.git?ref=tags/0.12.0"
6+
source = "./../../"
77

88
name = "sqs"
99
application = "clouddrove"
1010
environment = "test"
11-
label_order = ["environment", "name", "application"]
11+
label_order = ["environment", "application", "name"]
1212

1313
platform = "GCM"
1414
gcm_key = "AAAA8TYQCtc:APesgdrthyujioyhtgfds4icP_6Kyz3OT2Ms1cbJZDOq3AkCAt5tNpNE0g3oUQBdind1g7891cdrVAxbOmzL3XRd0ktgkFne2OwI7pC5an877XcBNQiHPMHT7dN7TykI2o6O2K"

outputs.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#Module : SNS
22
#Description : Terraform module is used to setup SNS service to manage notifications on application.
33
output "id" {
4-
value = join("", aws_sns_platform_application.default.*.id )
4+
value = join("", aws_sns_platform_application.default.*.id)
55
description = "The ID of the SNS platform application."
66
}
77

88
output "arn" {
9-
value = join("", aws_sns_platform_application.default.*.arn)
9+
value = join("", aws_sns_platform_application.default.*.arn)
1010
description = "The ARN of the SNS platform application."
1111
}

0 commit comments

Comments
 (0)