diff --git a/kms_policy.json.tpl b/kms_policy.json.tpl new file mode 100644 index 0000000..f956b2f --- /dev/null +++ b/kms_policy.json.tpl @@ -0,0 +1,13 @@ +{ + "Version": "2012-10-17", + "Id": "kms-key-policy", + "Statement": [ + { + "Sid": "Enable IAM User Permissions", + "Effect": "Allow", + "Principal": {"AWS": "arn:aws:iam::${account_id}:root","Service": "logs.us-east-1.amazonaws.com"}, + "Action": "kms:*", + "Resource": "*" + } + ] +} diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..9aa1984 --- /dev/null +++ b/main.tf @@ -0,0 +1,18 @@ +data "template_file" "kms_policy" { + template = "${file("${kms_policy.json.tpl")}" + + vars { + account_id = "${var.account_id}" + } +} + +resource "aws_kms_key" "key" { + policy = "${data.template_file.kms_policy.rendered}" +} + +resource "aws_cloudwatch_log_group" "yada" { + name = "vijay" + + kms_key_id = aws_kms_key.key.arn + +} diff --git a/terraform-aws-sns/example/.terraform.lock.hcl b/terraform-aws-sns/example/.terraform.lock.hcl new file mode 100644 index 0000000..f72ada9 --- /dev/null +++ b/terraform-aws-sns/example/.terraform.lock.hcl @@ -0,0 +1,22 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "4.22.0" + constraints = ">= 3.1.15" + hashes = [ + "h1:KOsejPSvd2eEfuhtbLilFMnQZlaOJ53p7/NR+4qSibo=", + "zh:299efb8ba733b7742f0ef1c5c5467819e0c7bf46264f5f36ba6b6674304a5244", + "zh:4db198a41d248491204d4ca644662c32f748177d5cbe01f3c7adbb957d4d77f0", + "zh:62ebc2b05b25eafecb1a75f19d6fc5551faf521ada9df9e5682440d927f642e1", + "zh:636b590840095b4f817c176034cf649f543c0ce514dc051d6d0994f0a05c53ef", + "zh:8594bd8d442288873eee56c0b4535cbdf02cacfcf8f6ddcf8cd5f45bb1d3bc80", + "zh:8e18a370949799f20ba967eec07a84aaedf95b3ee5006fe5af6eae13fbf39dc3", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:aa968514231e404fb53311d8eae2e8b6bde1fdad1f4dd5a592ab93d9cbf11af4", + "zh:af8e5c48bf36d4fff1a6fca760d5b85f14d657cbdf95e9cd5e898c68104bad31", + "zh:d8a75ba36bf8b6f2e49be5682f48eccb6c667a4484afd676ae347213ae208622", + "zh:dd7c419674a47e587dabe98b150a8f1f7e31c248c68e8bf5e9ca0a400b5e2c4e", + "zh:fdeb6314a2ce97489bbbece59511f78306955e8a23b02cbd1485bd04185a3673", + ] +} diff --git a/terraform-aws-sns/example/example.tf b/terraform-aws-sns/example/example.tf new file mode 100644 index 0000000..96c8f77 --- /dev/null +++ b/terraform-aws-sns/example/example.tf @@ -0,0 +1,13 @@ +provider "aws" { + region = "eu-west-1" +} + +module "sns_cloudwatch" { + source = "github.com/easyawslearn/Terraform-Tutorial/terraform-aws-sns" + cloudwatch_event_rule_name = "capture-aws-sign-in" + description = "Capture each AWS Console Sign In" + sns_name = "mysns" + sns_display_name = "demosns" + lambda_function_name = "S3cloudHub_Test_Lambda_Function" + lambda_function_runtime = "python3.8" +} diff --git a/terraform-aws-sns/example/version.tf b/terraform-aws-sns/example/version.tf new file mode 100644 index 0000000..966e0bc --- /dev/null +++ b/terraform-aws-sns/example/version.tf @@ -0,0 +1,12 @@ +# Terraform version +terraform { + required_version = ">= 0.14.11" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.1.15" + } + } +} + diff --git a/terraform-aws-sns/main.tf b/terraform-aws-sns/main.tf new file mode 100644 index 0000000..a94ca7b --- /dev/null +++ b/terraform-aws-sns/main.tf @@ -0,0 +1,132 @@ +provider "aws" { + region = var.region +} + +resource "aws_cloudwatch_event_rule" "default" { + count = var.enabled == true ? 1 : 0 + + name = var.cloudwatch_event_rule_name + description = var.description + event_pattern = <