You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 29, 2021. It is now read-only.
When you operate Kubernetes cluster, you will sooner or later create some additional resources like volumes or load balancers. You might need to attach some tags to these resources. This repository contains installation of AWS Lambda function which will go through all your resources, identify them based on tag `KubernetesCluster` tag which should contain the name of your Kubernetes cluster. For every resource it find it will make sure that the desiredßß tags are attached.
3
+
When you operate complex applications in AWS, you will sooner or later create some additional resources like volumes or load balancers. You might need to attach some tags to these resources. This repository contains installation of AWS Lambda function which will go through all your resources, identify them based on a configured tag which should contain ta specific value. For every resource it find it will make sure that the desired tags are attached.
-[Using as a Terraform module](#using-as-a-terraform-module)
12
14
-[Tagged resources](#tagged-resources)
13
15
14
16
<!-- /TOC -->
@@ -19,26 +21,33 @@ When you operate Kubernetes cluster, you will sooner or later create some additi
19
21
* Generating of the lambda function from the template and packing it into ZIP archive expects `bash` and `zip` being available.
20
22
* This deployment might not work on Windows machine. Tested only on Linux and macOS
21
23
22
-
## Configuration
24
+
## Tagging Kubernetes clusters
25
+
26
+
This Lambda fucntion was originally developed for tagging Kubernetes cluster and their resources. But it should work with other applications as well.
27
+
28
+
## Using as standalone Terraform configuration
23
29
24
30
The configuration is done through Terraform variables. Example *tfvars* file is part of this repo and is named `example.tfvars`. Change the variables to match your environment / requirements before running `terraform apply ...`.
25
31
26
32
| Option | Explanation | Example |
27
33
|--------|-------------|---------|
28
34
|`aws_region`| AWS region which should be used |`eu-central-1`|
29
-
|`cluster_name`| Name of the Kubernetes cluster (used to find the resources for tagging but also to name resources created by this configuration) |`my-minikube`|
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`|
36
+
|`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`|
37
+
|`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`|
30
38
|`tags`| Tags which should be applied to all resources |`{ Hello = "World" }`|
31
39
32
-
## Deploying tagging lambda
40
+
###Deploying tagging lambda
33
41
34
42
To deploy the tagging lambda,
35
43
* Export AWS credentials into environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
36
44
* Apply Terraform configuration with tagging lambda:
37
45
```bash
46
+
terraform init
38
47
terraform apply --var-file example.tfvars
39
48
```
40
49
41
-
## Deleting tagging lambda
50
+
###Deleting tagging lambda
42
51
43
52
To delete tagging lambda,
44
53
* Export AWS credentials into environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
@@ -47,17 +56,38 @@ To delete tagging lambda,
47
56
terraform destroy --var-file example.tfvars
48
57
```
49
58
59
+
## Using as a Terraform module
60
+
61
+
Although it can be run on its own, the main value is that it can be included into another Terraform configuration.
62
+
63
+
```hcl
64
+
module "tagging-lambda" {
65
+
source = "scholzj/tagging-lambda/aws"
66
+
67
+
aws_region = "eu-east-1"
68
+
name = "my-application"
69
+
search_tag_key = "kubernetes.io/cluster/aws-k8s"
70
+
search_tag_value = "owned"
71
+
72
+
# Tags
73
+
tags = {
74
+
Hello = "World"
75
+
}
76
+
}
77
+
```
78
+
79
+
An example of how to include this can be found in the [examples](examples/) dir.
50
80
## Tagged resources
51
81
52
82
* EC2 instances
53
83
* Network interfaces
54
84
* EBS Volumes
55
85
* Security Groups
56
-
* Internet Gateways (*not applicable in ProductDev*)
57
-
* DHCP Option sets (*not applicable in ProductDev*)
Copy file name to clipboardExpand all lines: example.tfvars
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
aws_region="eu-east-1"
2
2
3
3
# Used for naming related resources
4
-
name="my-minikube"
4
+
name="my-k8s"
5
5
6
6
# 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.
0 commit comments