Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

Commit ea54253

Browse files
committed
Fix typos and naming issues
1 parent 67072a5 commit ea54253

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ The configuration is done through Terraform variables. Example *tfvars* file is
3131

3232
| Option | Explanation | Example |
3333
|--------|-------------|---------|
34-
| `aws_region` | AWS region which should be used | `eu-central-1` |
35-
| `name` | Name of the Kubernetes cluster (used to find the resources for tagging but also to name resources created by this configuration) | `my-minikube` |
34+
| `aws_region` | AWS region which should be used | `eu-east-1` |
35+
| `lambda_name` | Will be used to name the tagging lambda, its roles etc. | `my-k8s` |
3636
| `search_tag_key` | The Key of the tag which determines resources belonging to the application. All resources with matching tag and its value will be tagged with additional tags. | `kubernetes.io/cluster/aws-k8s` |
3737
| `search_tag_value` | The Valur of the tag which determines resources belonging to the application. All resources with matching tag and its value will be tagged with additional tags. | `owned` |
3838
| `tags` | Tags which should be applied to all resources | `{ Hello = "World" }` |

example.tfvars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
aws_region = "eu-east-1"
22

33
# Used for naming related resources
4-
name = "my-k8s"
4+
lambda_name = "my-k8s"
55

66
# The Key of the tag which determines resources belonging to the application. All resources with matching tag and its value will be tagged with additional tags.
77
search_tag_key = "kubernetes.io/cluster/my-k8s"

main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ data "template_file" "policy_json" {
1818
}
1919

2020
resource "aws_iam_policy" "iam_role_policy" {
21-
name = "${var.cluster_name}-tagging-lambda"
21+
name = "${var.lambda_name}-tagging-lambda"
2222
path = "/"
23-
description = "Policy for role ${var.cluster_name}-tagging-lambda"
23+
description = "Policy for role ${var.lambda_name}-tagging-lambda"
2424
policy = "${data.template_file.policy_json.rendered}"
2525
}
2626

2727
resource "aws_iam_role" "iam_role" {
28-
name = "${var.cluster_name}-tagging-lambda"
28+
name = "${var.lambda_name}-tagging-lambda"
2929

3030
assume_role_policy = <<EOF
3131
{
@@ -45,7 +45,7 @@ EOF
4545
}
4646

4747
resource "aws_iam_policy_attachment" "lambda-attach" {
48-
name = "${var.cluster_name}-tagging-lambda-attachment"
48+
name = "${var.lambda_name}-tagging-lambda-attachment"
4949
roles = ["${aws_iam_role.iam_role.name}"]
5050
policy_arn = "${aws_iam_policy.iam_role_policy.arn}"
5151
}
@@ -61,7 +61,7 @@ data "template_file" "lambda" {
6161

6262
vars {
6363
aws_region = "${var.aws_region}"
64-
name = "${var.cluster_name}"
64+
name = "${var.lambda_name}"
6565
search_tag_key = "${var.search_tag_key}"
6666
search_tag_value = "${var.search_tag_value}"
6767
tags = "${jsonencode(var.tags)}"
@@ -89,7 +89,7 @@ resource "aws_lambda_function" "tagging" {
8989
depends_on = ["aws_iam_role.iam_role", "null_resource.zip_lambda"]
9090

9191
filename = "/tmp/tagging_lambda.zip"
92-
function_name = "${var.cluster_name}-tagging-lambda"
92+
function_name = "${var.lambda_name}-tagging-lambda"
9393
role = "${aws_iam_role.iam_role.arn}"
9494
handler = "tagging_lambda.lambda_handler"
9595
runtime = "python2.7"
@@ -100,13 +100,13 @@ resource "aws_lambda_function" "tagging" {
100100
}
101101

102102
resource "aws_cloudwatch_event_rule" "tagging" {
103-
name = "${var.cluster_name}-tagging-lambda"
103+
name = "${var.lambda_name}-tagging-lambda"
104104
description = "Trigger tagging lambda in periodical intervals"
105105
schedule_expression = "rate(5 minutes)"
106106
}
107107

108108
resource "aws_lambda_permission" "tagging" {
109-
statement_id = "${var.cluster_name}-AllowCloudWatchTrigger"
109+
statement_id = "${var.lambda_name}-AllowCloudWatchTrigger"
110110
action = "lambda:InvokeFunction"
111111
function_name = "${aws_lambda_function.tagging.function_name}"
112112
principal = "events.amazonaws.com"
@@ -115,6 +115,6 @@ resource "aws_lambda_permission" "tagging" {
115115

116116
resource "aws_cloudwatch_event_target" "tagging" {
117117
rule = "${aws_cloudwatch_event_rule.tagging.name}"
118-
target_id = "${var.cluster_name}-TriggerLambda"
118+
target_id = "${var.lambda_name}-TriggerLambda"
119119
arn = "${aws_lambda_function.tagging.arn}"
120120
}

variables.tf

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ variable "aws_region" {
33
default = "eu-east-1"
44
}
55

6-
variable "name" {
7-
description = "Name of the installation we are tagging - will be used to name all resources unless they already have a `Name` tag."
6+
variable "lambda_name" {
7+
description = "Will be used to name the tagging lambda, its roles etc."
88
}
99

1010
variable "search_tag_key" {
@@ -15,10 +15,6 @@ variable "search_tag_value" {
1515
description = "The Valur of the tag which determines resources belonging to the application. All resources with matching tag and its value will be tagged with additional tags."
1616
}
1717

18-
variable "name" {
19-
description = "Name of the installation we are tagging - will be used to name all resources unless they already have a `Name` tag."
20-
}
21-
2218
variable "tags" {
2319
description = "Tags used for the AWS resources created by this template"
2420
type = "map"

0 commit comments

Comments
 (0)