Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#103] Add AWS SNS as an optional module #236

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup node and restore cached dependencies
uses: actions/setup-node@v3
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.5
terraform_version: 1.6.1

- name: Terraform fmt
run: terraform fmt -check -recursive
2 changes: 1 addition & 1 deletion .github/workflows/publish-wiki.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nodejs 18.12.1
terraform 1.5.5
terraform 1.6.1
53 changes: 53 additions & 0 deletions templates/addons/aws/modules/sns/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
data "aws_iam_policy_document" "sns_platform_assume_role_policy" {
statement {
sid = "SnsPlatformAssumeRolePolicy"
effect = "Allow"
actions = ["sts:AssumeRole"]

principals {
type = "Service"
identifiers = ["sns.amazonaws.com"]
}
}
}

data "aws_iam_policy_document" "sns_platform_log_policy" {
statement {
sid = "LogMobilePushNotificationsPolicy"
effect = "Allow"

actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:PutMetricFilter",
"logs:PutRetentionPolicy"
]

resources = ["*"]
}
}

resource "aws_iam_role" "sns_platform_role" {
name = "${var.namespace}-sns-platform-log-role"

assume_role_policy = data.aws_iam_policy_document.sns_platform_assume_role_policy.json
}

resource "aws_iam_policy" "sns_platform_log_policy" {
name = "${var.namespace}-platform-log-policy"
policy = data.aws_iam_policy_document.sns_platform_log_policy.json
}

resource "aws_iam_role_policy_attachment" "sns_platform_log_policy" {
role = aws_iam_role.sns_platform_role.name
policy_arn = aws_iam_policy.sns_platform_log_policy.arn
}

resource "aws_sns_platform_application" "mobile_push_notifications" {
name = "${var.namespace}-mobile-push-notifications"
platform = "GCM"
failure_feedback_role_arn = aws_iam_role.sns_platform_role.arn
success_feedback_role_arn = aws_iam_role.sns_platform_role.arn
platform_credential = var.firebase_cloud_messaging_api_key
}
4 changes: 4 additions & 0 deletions templates/addons/aws/modules/sns/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "aws_sns_plaform_mobile_push_notifications_arn" {
description = "ARN of SNS Plaform for mobile push notifications"
value = aws_sns_platform_application.mobile_push_notifications.arn
}
9 changes: 9 additions & 0 deletions templates/addons/aws/modules/sns/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "namespace" {
description = "The namespace with environment for SNS"
type = string
}

variable "firebase_cloud_messaging_api_key" {
description = "Application Platform API key for FCM"
type = string
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:

env:
TERRAFORM_VERSION: "1.5.5"
TERRAFORM_VERSION:"1.6.1"
TFSEC_VERSION: "v1.28.1"

concurrency:
Expand Down
2 changes: 1 addition & 1 deletion templates/terraform/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
terraform 1.5.5
terraform 1.6.1
tfsec 1.28.1
2 changes: 1 addition & 1 deletion templates/terraform/core/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
terraform {
# Terraform version
required_version = "1.5.5"
required_version = "1.6.1"
}
2 changes: 1 addition & 1 deletion templates/terraform/shared/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
terraform {
# Terraform version
required_version = "1.5.5"
required_version ="1.6.1"
}
Loading