Skip to content

Commit ead605e

Browse files
author
Richard Gutkowski
authored
Merge pull request #1 from osodevops/ami-lambda-update
Updating naming for resources and readme
2 parents 2a9e9c0 + def8d0f commit ead605e

File tree

5 files changed

+7
-11
lines changed

5 files changed

+7
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
---
66

7-
This Terraform module creates an encryption Lambda function that is triggered by a SNS notification on a successful AMI Packer build.
7+
This Terraform module creates an encryption Lambda function that is triggered by a SNS notification on a successful AMI Packer build. The module also creates a cloudwatch event that monitors build events and passes them to ami encryption lambda function. The cloudwatch even target is set to the ami encryption lambda, in order to run on any successful build.
88

99
This project is part of our open source DevOps adoption approach.
1010

aws_cloudwatch_event_rule_build_success.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
resource "aws_cloudwatch_event_rule" "build_alert" {
2-
# Create cloudwatch event that monitors build events and passes them to ami encryption lambda function
3-
name = "AMI-CODEBUILD-SUCESS-ALERT"
2+
name = "${upper(var.environment)}-AMI-CODEBUILD-SUCESS-ALERT"
43
description = "Send alerts to encrypt AMI on build success."
54

65
event_pattern = <<PATTERN
@@ -21,7 +20,6 @@ resource "aws_cloudwatch_event_rule" "build_alert" {
2120
}
2221

2322
resource "aws_cloudwatch_event_target" "lamba_alert" {
24-
# Create ami encryption target
2523
rule = aws_cloudwatch_event_rule.build_alert.name
2624
target_id = "ami-encryption-lambda"
2725
arn = aws_lambda_function.ami_encryption_lambda.arn
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_iam_policy_attachment" "ami_encryption_policy" {
2-
name = "ami-encryption-attachment"
2+
name = "${var.environment}-ami-encryption-attachment"
33
roles = [aws_iam_role.ami_encrypt_lambda.name]
44
policy_arn = aws_iam_policy.ami_encryption_policy.arn
55
}

variables.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
variable "environment" {}
1+
variable "environment" {
2+
description = "Set the environment for where the ami encryption lambda is deployed."
3+
type = string
4+
}
25

36
variable "kms_key_arn" {
47
description = "If Encrypt_ami set to true then you must pass in the arn of the key you wish to encrypt disk with."

±!

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)