Skip to content

Commit bca03ea

Browse files
committed
update file
1 parent 717c266 commit bca03ea

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

terraform-aws-sns/main.tf

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
## Managed By : S3CloudHub
2+
## Description : This Script is used to create SNS Platform Application, SNS Topic, Topic Subscription and Sms Preferences.
3+
## Copyright @ S3CloudHub. All Right Reserved.
4+
5+
#Module : label
6+
#Description : This terraform module is designed to generate consistent label names and
7+
# tags for resources. You can use terraform-labels to implement a strict
8+
# naming convention.
9+
module "labels" {
10+
source = "F:/Office_Work/git-clone-easyaws/Terraform-Tutorial\terraform-aws-sns"
11+
version = "0.15.0"
12+
13+
name = var.name
14+
repository = var.repository
15+
environment = var.environment
16+
managedby = var.managedby
17+
attributes = var.attributes
18+
label_order = var.label_order
19+
}
20+
21+
#Module : SNS
22+
#Description : Terraform module is used to setup SNS service to manage notifications on
23+
# application.
24+
resource "aws_sns_platform_application" "default" {
25+
count = var.enabled && var.enable_sns ? 1 : 0
26+
27+
name = module.labels.id
28+
platform = var.platform
29+
platform_credential = length(var.gcm_key) > 0 ? var.gcm_key : file(var.key)
30+
platform_principal = length(var.gcm_key) > 0 ? var.gcm_key : file(var.certificate)
31+
event_delivery_failure_topic_arn = var.event_delivery_failure_topic_arn
32+
event_endpoint_created_topic_arn = var.event_endpoint_created_topic_arn
33+
event_endpoint_deleted_topic_arn = var.event_endpoint_deleted_topic_arn
34+
event_endpoint_updated_topic_arn = var.event_endpoint_updated_topic_arn
35+
failure_feedback_role_arn = var.failure_feedback_role_arn
36+
success_feedback_role_arn = var.success_feedback_role_arn
37+
success_feedback_sample_rate = var.success_feedback_sample_rate
38+
}
39+
40+
#Module : SNS TOPIC
41+
#Description : Terraform module which creates SNS Topic resources on AWS
42+
#tfsec:ignore:aws-sns-enable-topic-encryption
43+
resource "aws_sns_topic" "default" {
44+
count = var.enabled && var.enable_topic ? 1 : 0
45+
46+
name = module.labels.id
47+
display_name = var.display_name
48+
policy = var.policy
49+
delivery_policy = var.delivery_policy
50+
application_success_feedback_role_arn = var.application_success_feedback_role_arn
51+
application_success_feedback_sample_rate = var.application_success_feedback_sample_rate
52+
application_failure_feedback_role_arn = var.application_failure_feedback_role_arn
53+
http_success_feedback_role_arn = var.http_success_feedback_role_arn
54+
http_success_feedback_sample_rate = var.http_success_feedback_sample_rate
55+
http_failure_feedback_role_arn = var.http_failure_feedback_role_arn
56+
kms_master_key_id = var.kms_master_key_id
57+
lambda_success_feedback_role_arn = var.lambda_success_feedback_role_arn
58+
lambda_success_feedback_sample_rate = var.lambda_success_feedback_sample_rate
59+
lambda_failure_feedback_role_arn = var.lambda_failure_feedback_role_arn
60+
sqs_success_feedback_role_arn = var.sqs_success_feedback_role_arn
61+
sqs_success_feedback_sample_rate = var.sqs_success_feedback_sample_rate
62+
sqs_failure_feedback_role_arn = var.sqs_failure_feedback_role_arn
63+
tags = module.labels.tags
64+
}
65+
66+
#Module : SNS TOPIC SUBSCRIPTION
67+
#Description : Terraform module which creates SNS Topic Subscription resources on AWS
68+
resource "aws_sns_topic_subscription" "this" {
69+
for_each = var.subscribers
70+
topic_arn = join("", aws_sns_topic.default.*.arn)
71+
protocol = var.subscribers[each.key].protocol
72+
endpoint = var.subscribers[each.key].endpoint
73+
endpoint_auto_confirms = var.subscribers[each.key].endpoint_auto_confirms
74+
raw_message_delivery = var.subscribers[each.key].raw_message_delivery
75+
filter_policy = var.subscribers[each.key].filter_policy
76+
delivery_policy = var.subscribers[each.key].delivery_policy
77+
confirmation_timeout_in_minutes = var.subscribers[each.key].confirmation_timeout_in_minutes
78+
79+
}
80+
81+
82+
#Module : SNS SMS Preferences
83+
#Description : Terraform module which creates SNS SMS Preferences on AWS
84+
resource "aws_sns_sms_preferences" "default" {
85+
count = var.enabled && var.enable_sms_preference ? 1 : 0
86+
87+
monthly_spend_limit = var.monthly_spend_limit
88+
delivery_status_iam_role_arn = var.delivery_status_iam_role_arn
89+
delivery_status_success_sampling_rate = var.delivery_status_success_sampling_rate
90+
default_sender_id = var.default_sender_id
91+
default_sms_type = var.default_sms_type
92+
usage_report_s3_bucket = var.usage_report_s3_bucket
93+
}

0 commit comments

Comments
 (0)